@@ -282,60 +282,45 @@ def get_default_threads():
282282 __use_http_lib__ = "httpx"
283283if ((__use_http_lib__ == "httpx" or __use_http_lib__ == "requests" ) and not havehttpx and not haverequests ):
284284 __use_http_lib__ = "urllib"
285+ __file_format_multi_dict__ = {}
286+ __file_format_default__ = "CatFile"
285287if os .path .exists (__config_file__ ) and __use_ini_file__ :
286288 config = configparser .ConfigParser ()
287289 config .read (__config_file__ )
288- __use_alt_format__ = config .getboolean ('config' , 'usealt' )
289- main_fmt = config .get ('config' , 'mainfmt' )
290- alt_fmt = config .get ('config' , 'altfmt' )
291290 def decode_unicode_escape (value ):
292291 if sys .version_info [0 ] < 3 : # Python 2
293292 return value .decode ('unicode_escape' )
294293 else : # Python 3
295294 return bytes (value , 'UTF-8' ).decode ('unicode_escape' )
296- __file_format_main__ = {'format_name' : config .get (main_fmt , 'name' ), 'format_magic' : decode_unicode_escape (config .get (main_fmt , 'magic' )), 'format_lower' : config .get (main_fmt , 'lower' ), 'format_len' : config .getint (main_fmt , 'len' ), 'format_hex' : config .get (main_fmt , 'hex' ), 'format_delimiter' : decode_unicode_escape (config .get (main_fmt , 'delimiter' )), 'format_ver' : config .get (main_fmt , 'ver' ), 'new_style' : config .getboolean (main_fmt , 'newstyle' ), 'use_advanced_list' : config .getboolean (main_fmt , 'advancedlist' ), 'use_alt_inode' : config .getboolean (main_fmt , 'altinode' ), 'format_extension' : config .get (main_fmt , 'extension' ), 'program_name' : config .get (main_fmt , 'proname' )}
297- __file_format_alt__ = {'format_name' : config .get (alt_fmt , 'name' ), 'format_magic' : decode_unicode_escape (config .get (alt_fmt , 'magic' )), 'format_lower' : config .get (alt_fmt , 'lower' ), 'format_len' : config .getint (alt_fmt , 'len' ), 'format_hex' : config .get (alt_fmt , 'hex' ), 'format_delimiter' : decode_unicode_escape (config .get (alt_fmt , 'delimiter' )), 'format_ver' : config .get (alt_fmt , 'ver' ), 'new_style' : config .getboolean (alt_fmt , 'newstyle' ), 'use_advanced_list' : config .getboolean (alt_fmt , 'advancedlist' ), 'use_alt_inode' : config .getboolean (alt_fmt , 'altinode' ), 'format_extension' : config .get (alt_fmt , 'extension' ), 'program_name' : config .get (alt_fmt , 'proname' )}
298- else :
299- __file_format_main__ = {'format_name' : "CatFile" , 'format_magic' : "CatFile" , 'format_lower' : "catfile" , 'format_len' : 7 , 'format_hex' : "43617446696c65" , 'format_delimiter' : "\x00 " , 'format_ver' : "001" , 'new_style' : True , 'use_advanced_list' : True , 'use_alt_inode' : False , 'format_extension' : ".cat" , 'program_name' : "PyCatFile" }
300- __file_format_alt_eng__ = __file_format_main__
301- __file_format_alt__ = {'format_name' : "NekoFile" , 'format_magic' : "ねこファイル" , 'format_lower' : "nekofile" , 'format_len' : 21 , 'format_hex' : "e381ade38193e38395e382a1e382a4e383abe" , 'format_delimiter' : "\x00 " , 'format_ver' : "001" , 'new_style' : True , 'use_advanced_list' : True , 'use_alt_inode' : False , 'format_extension' : ".neko" , 'program_name' : "PyNekoFile" }
302- __file_format_alt_jpn__ = __file_format_alt__
303- __file_format_alt_kor__ = {'format_name' : "NekoFile" , 'format_magic' : "네코파일" , 'format_lower' : "nekofile" , 'format_len' : 15 , 'format_hex' : "eb84a4ecbd94ed8c8c" , 'format_delimiter' : "\x00 " , 'format_ver' : "001" , 'new_style' : True , 'use_advanced_list' : True , 'use_alt_inode' : False , 'format_extension' : ".neko" , 'program_name' : "PyNekoFile" }
304- if not __use_alt_format__ :
305- __file_format_name__ = __file_format_main__ ['format_name' ]
306- __program_name__ = __file_format_main__ ['program_name' ]
307- __file_format_lower__ = __file_format_main__ ['format_lower' ]
308- __file_format_magic__ = __file_format_main__ ['format_magic' ]
309- __file_format_len__ = __file_format_main__ ['format_len' ]
310- __file_format_hex__ = __file_format_main__ ['format_hex' ]
311- __file_format_delimiter__ = __file_format_main__ ['format_delimiter' ]
312- __file_format_ver__ = __file_format_main__ ['format_ver' ]
313- __use_new_style__ = __file_format_main__ ['new_style' ]
314- __use_advanced_list__ = __file_format_main__ ['use_advanced_list' ]
315- __use_alt_inode__ = __file_format_main__ ['use_alt_inode' ]
316- __file_format_extension__ = __file_format_main__ ['format_extension' ]
317- else :
318- __file_format_name__ = __file_format_alt__ ['format_name' ]
319- __program_name__ = __file_format_alt__ ['program_name' ]
320- __file_format_lower__ = __file_format_alt__ ['format_lower' ]
321- __file_format_magic__ = __file_format_alt__ ['format_magic' ]
322- __file_format_len__ = __file_format_alt__ ['format_len' ]
323- __file_format_hex__ = __file_format_alt__ ['format_hex' ]
324- __file_format_delimiter__ = __file_format_alt__ ['format_delimiter' ]
325- __file_format_ver__ = __file_format_alt__ ['format_ver' ]
326- __use_new_style__ = __file_format_alt__ ['new_style' ]
327- __use_advanced_list__ = __file_format_alt__ ['use_advanced_list' ]
328- __use_alt_inode__ = __file_format_alt__ ['use_alt_inode' ]
329- __file_format_extension__ = __file_format_alt__ ['format_extension' ]
330- __file_format_default__ = __file_format_magic__
331- __file_format_multi_dict__ = {}
332- __file_format_multi_dict__ .update ({__file_format_main__ ['format_magic' ]: __file_format_main__ })
333- __file_format_multi_dict__ .update ({__file_format_alt__ ['format_magic' ]: __file_format_alt__ })
334- try :
335- __file_format_multi_dict__ .update ({__file_format_alt_kor__ ['format_magic' ]: __file_format_alt_kor__ })
336- except :
337- pass
338- __file_format_dict__ = {'format_name' : __file_format_name__ , 'format_magic' : __file_format_magic__ , 'format_lower' : __file_format_lower__ , 'format_len' : __file_format_len__ , 'format_hex' : __file_format_hex__ , 'format_delimiter' : __file_format_delimiter__ , 'format_ver' : __file_format_ver__ , 'new_style' : __use_new_style__ , 'use_advanced_list' : __use_advanced_list__ , 'use_alt_inode' : __use_alt_inode__ , 'format_extension' : __file_format_extension__ , 'program_name' : __program_name__ }
295+ __file_format_default__ = decode_unicode_escape (config .get ('config' , 'default' ))
296+ # Loop through all sections
297+ for section in config .sections ():
298+ required_keys = [
299+ "len" , "hex" , "ver" , "name" , "proname" ,
300+ "lower" , "magic" , "delimiter" , "extension" ,
301+ "newstyle" , "advancedlist" , "altinode"
302+ ]
303+ if all (key in config [section ] for key in required_keys ):
304+ __file_format_multi_dict__ .update ({decode_unicode_escape (config .get (section , 'magic' )): {'format_name' : config .get (section , 'name' ), 'format_magic' : decode_unicode_escape (config .get (section , 'magic' )), 'format_lower' : config .get (section , 'lower' ), 'format_len' : config .getint (section , 'len' ), 'format_hex' : config .get (section , 'hex' ), 'format_delimiter' : decode_unicode_escape (config .get (section , 'delimiter' )), 'format_ver' : config .get (section , 'ver' ), 'new_style' : config .getboolean (section , 'newstyle' ), 'use_advanced_list' : config .getboolean (section , 'advancedlist' ), 'use_alt_inode' : config .getboolean (section , 'altinode' ), 'format_extension' : config .get (section , 'extension' ), 'program_name' : config .get (section , 'proname' )} } )
305+ if ("CatFile" not in __file_format_multi_dict__ ):
306+ __file_format_multi_dict__ .update ({'CatFile' : {'format_name' : "CatFile" , 'format_magic' : "CatFile" , 'format_lower' : "catfile" , 'format_len' : 7 , 'format_hex' : "43617446696c65" , 'format_delimiter' : "\x00 " , 'format_ver' : "001" , 'new_style' : True , 'use_advanced_list' : True , 'use_alt_inode' : False , 'format_extension' : ".cat" , 'program_name' : "PyCatFile" } } )
307+ if ("ねこファイル" not in __file_format_multi_dict__ ):
308+ __file_format_multi_dict__ .update ({'ねこファイル' : {'format_name' : "NekoFile" , 'format_magic' : "ねこファイル" , 'format_lower' : "nekofile" , 'format_len' : 21 , 'format_hex' : "e381ade38193e38395e382a1e382a4e383abe" , 'format_delimiter' : "\x00 " , 'format_ver' : "001" , 'new_style' : True , 'use_advanced_list' : True , 'use_alt_inode' : False , 'format_extension' : ".neko" , 'program_name' : "PyNekoFile" } } )
309+ if ("네코파일" not in __file_format_multi_dict__ ):
310+ __file_format_multi_dict__ .update ({'네코파일' : {'format_name' : "NekoFile" , 'format_magic' : "네코파일" , 'format_lower' : "nekofile" , 'format_len' : 15 , 'format_hex' : "eb84a4ecbd94ed8c8c" , 'format_delimiter' : "\x00 " , 'format_ver' : "001" , 'new_style' : True , 'use_advanced_list' : True , 'use_alt_inode' : False , 'format_extension' : ".neko" , 'program_name' : "PyNekoFile" } } )
311+ __file_format_name__ = __file_format_multi_dict__ [__file_format_default__ ]['format_name' ]
312+ __program_name__ = __file_format_multi_dict__ [__file_format_default__ ]['program_name' ]
313+ __file_format_lower__ = __file_format_multi_dict__ [__file_format_default__ ]['format_lower' ]
314+ __file_format_magic__ = __file_format_multi_dict__ [__file_format_default__ ]['format_magic' ]
315+ __file_format_len__ = __file_format_multi_dict__ [__file_format_default__ ]['format_len' ]
316+ __file_format_hex__ = __file_format_multi_dict__ [__file_format_default__ ]['format_hex' ]
317+ __file_format_delimiter__ = __file_format_multi_dict__ [__file_format_default__ ]['format_delimiter' ]
318+ __file_format_ver__ = __file_format_multi_dict__ [__file_format_default__ ]['format_ver' ]
319+ __use_new_style__ = __file_format_multi_dict__ [__file_format_default__ ]['new_style' ]
320+ __use_advanced_list__ = __file_format_multi_dict__ [__file_format_default__ ]['use_advanced_list' ]
321+ __use_alt_inode__ = __file_format_multi_dict__ [__file_format_default__ ]['use_alt_inode' ]
322+ __file_format_extension__ = __file_format_multi_dict__ [__file_format_default__ ]['format_extension' ]
323+ __file_format_dict__ = __file_format_multi_dict__ [__file_format_default__ ]
339324__project__ = __program_name__
340325__project_url__ = "https://github.com/GameMaker2k/PyCatFile"
341326__version_info__ = (0 , 16 , 4 , "RC 1" , 1 )
0 commit comments