@@ -206,6 +206,21 @@ class MetadataBox(QtWidgets.QTableWidget):
206206    COLUMN_ORIG  =  1 
207207    COLUMN_NEW  =  2 
208208
209+     # keys are tags 
210+     # values are FileLookup methods (as string) 
211+     # to use to look up for the matching tag 
212+     LOOKUP_TAGS  =  {
213+         'acoustid_id' : 'acoust_lookup' ,
214+         'musicbrainz_albumartistid' : 'artist_lookup' ,
215+         'musicbrainz_albumid' : 'album_lookup' ,
216+         'musicbrainz_artistid' : 'artist_lookup' ,
217+         'musicbrainz_discid' : 'discid_lookup' ,
218+         'musicbrainz_recordingid' : 'recording_lookup' ,
219+         'musicbrainz_releasegroupid' : 'release_group_lookup' ,
220+         'musicbrainz_trackid' : 'track_lookup' ,
221+         'musicbrainz_workid' : 'work_lookup' ,
222+     }
223+ 
209224    def  __init__ (self , parent ):
210225        super ().__init__ (parent )
211226        self .tagger  =  QtCore .QCoreApplication .instance ()
@@ -261,24 +276,12 @@ def _get_file_lookup(self):
261276                          config .setting ['server_port' ],
262277                          self .tagger .browser_integration .port )
263278
264-     def  _lookup_tags (self ):
279+     def  _lookup_tag (self ,  tag ):
265280        lookup  =  self ._get_file_lookup ()
266-         LOOKUP_TAGS  =  {
267-             'musicbrainz_recordingid' : lookup .recording_lookup ,
268-             'musicbrainz_trackid' : lookup .track_lookup ,
269-             'musicbrainz_albumid' : lookup .album_lookup ,
270-             'musicbrainz_workid' : lookup .work_lookup ,
271-             'musicbrainz_artistid' : lookup .artist_lookup ,
272-             'musicbrainz_albumartistid' : lookup .artist_lookup ,
273-             'musicbrainz_releasegroupid' : lookup .release_group_lookup ,
274-             'musicbrainz_discid' : lookup .discid_lookup ,
275-             'acoustid_id' : lookup .acoust_lookup 
276-         }
277-         return  LOOKUP_TAGS 
281+         return  getattr (lookup , self .LOOKUP_TAGS [tag ])
278282
279283    def  _open_link (self , values , tag ):
280-         lookup  =  self ._lookup_tags ()
281-         lookup_func  =  lookup [tag ]
284+         lookup_func  =  self ._lookup_tag (tag )
282285        for  v  in  values :
283286            lookup_func (v )
284287
@@ -388,7 +391,7 @@ def contextMenuEvent(self, event):
388391            if  item :
389392                column  =  item .column ()
390393                for  tag  in  tags :
391-                     if  tag  in  self ._lookup_tags (). keys () :
394+                     if  tag  in  self .LOOKUP_TAGS :
392395                        if  (column  ==  self .COLUMN_ORIG  or  column  ==  self .COLUMN_NEW ) and  single_tag  and  item .text ():
393396                            if  column  ==  self .COLUMN_ORIG :
394397                                values  =  self .tag_diff .orig [tag ]
0 commit comments