@@ -115,9 +115,11 @@ def setup(self):
115115 self .import_stages = [self .imported ]
116116
117117 self ._genre_cache = {}
118+ self .whitelist = self ._load_whitelist ()
119+ self .c14n_branches , self .canonicalize = self ._load_c14n_tree ()
118120
119- # Read the whitelist file if enabled.
120- self . whitelist = set ()
121+ def _load_whitelist ( self ):
122+ whitelist = set ()
121123 wl_filename = self .config ["whitelist" ].get ()
122124 if wl_filename in (True , "" ): # Indicates the default whitelist.
123125 wl_filename = WHITELIST
@@ -127,27 +129,27 @@ def setup(self):
127129 for line in f :
128130 line = line .decode ("utf-8" ).strip ().lower ()
129131 if line and not line .startswith ("#" ):
130- self .whitelist .add (line )
132+ whitelist .add (line )
133+ return whitelist
131134
132- # Read the genres tree for canonicalization if enabled.
133- self . c14n_branches = []
135+ def _load_c14n_tree ( self ):
136+ c14n_branches = []
134137 c14n_filename = self .config ["canonical" ].get ()
135- self .canonicalize = c14n_filename is not False
136-
138+ canonicalize = c14n_filename is not False
137139 # Default tree
138140 if c14n_filename in (True , "" ):
139141 c14n_filename = C14N_TREE
140- elif not self . canonicalize and self .config ["prefer_specific" ].get ():
142+ elif not canonicalize and self .config ["prefer_specific" ].get ():
141143 # prefer_specific requires a tree, load default tree
142144 c14n_filename = C14N_TREE
143-
144145 # Read the tree
145146 if c14n_filename :
146147 self ._log .debug ("Loading canonicalization tree {0}" , c14n_filename )
147148 c14n_filename = normpath (c14n_filename )
148149 with codecs .open (c14n_filename , "r" , encoding = "utf-8" ) as f :
149150 genres_tree = yaml .safe_load (f )
150- flatten_tree (genres_tree , [], self .c14n_branches )
151+ flatten_tree (genres_tree , [], c14n_branches )
152+ return c14n_branches , canonicalize
151153
152154 @property
153155 def sources (self ) -> tuple [str , ...]:
0 commit comments