Skip to content

Commit

Permalink
Small update
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski committed Jan 24, 2025
1 parent 501c07e commit 172996c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 52 deletions.
10 changes: 4 additions & 6 deletions catfile.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
; $FileInfo: catfile.ini - Last Update: 1/21/2025 Ver. 0.16.6 RC 1 - Author: cooldude2k $

[config]
usealt = false
mainfmt = main
altfmt = alt
default = CatFile

[main]
[CatFile]
len = 7
hex = 43617446696c65
ver = 001
Expand All @@ -19,7 +17,7 @@ newstyle = true
advancedlist = true
altinode = true

[alt]
[\u306d\u3053\u30d5\u30a1\u30a4\u30eb]
len = 18
hex = e381ade38193e38395e382a1e382a4e383ab
ver = 001
Expand All @@ -33,7 +31,7 @@ newstyle = true
advancedlist = true
altinode = true

[altkr]
[\ub124\ucf54\ud30c\uc77c]
len = 12
hex = eb84a4ecbd94ed8c8cec9dbc
ver = 001
Expand Down
77 changes: 31 additions & 46 deletions pycatfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,60 +282,45 @@ def get_default_threads():
__use_http_lib__ = "httpx"
if((__use_http_lib__ == "httpx" or __use_http_lib__ == "requests") and not havehttpx and not haverequests):
__use_http_lib__ = "urllib"
__file_format_multi_dict__ = {}
__file_format_default__ = "CatFile"
if os.path.exists(__config_file__) and __use_ini_file__:
config = configparser.ConfigParser()
config.read(__config_file__)
__use_alt_format__ = config.getboolean('config', 'usealt')
main_fmt = config.get('config', 'mainfmt')
alt_fmt = config.get('config', 'altfmt')
def decode_unicode_escape(value):
if sys.version_info[0] < 3: # Python 2
return value.decode('unicode_escape')
else: # Python 3
return bytes(value, 'UTF-8').decode('unicode_escape')
__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')}
__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')}
else:
__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"}
__file_format_alt_eng__ = __file_format_main__
__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"}
__file_format_alt_jpn__ = __file_format_alt__
__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"}
if not __use_alt_format__:
__file_format_name__ = __file_format_main__['format_name']
__program_name__ = __file_format_main__['program_name']
__file_format_lower__ = __file_format_main__['format_lower']
__file_format_magic__ = __file_format_main__['format_magic']
__file_format_len__ = __file_format_main__['format_len']
__file_format_hex__ = __file_format_main__['format_hex']
__file_format_delimiter__ = __file_format_main__['format_delimiter']
__file_format_ver__ = __file_format_main__['format_ver']
__use_new_style__ = __file_format_main__['new_style']
__use_advanced_list__ = __file_format_main__['use_advanced_list']
__use_alt_inode__ = __file_format_main__['use_alt_inode']
__file_format_extension__ = __file_format_main__['format_extension']
else:
__file_format_name__ = __file_format_alt__['format_name']
__program_name__ = __file_format_alt__['program_name']
__file_format_lower__ = __file_format_alt__['format_lower']
__file_format_magic__ = __file_format_alt__['format_magic']
__file_format_len__ = __file_format_alt__['format_len']
__file_format_hex__ = __file_format_alt__['format_hex']
__file_format_delimiter__ = __file_format_alt__['format_delimiter']
__file_format_ver__ = __file_format_alt__['format_ver']
__use_new_style__ = __file_format_alt__['new_style']
__use_advanced_list__ = __file_format_alt__['use_advanced_list']
__use_alt_inode__ = __file_format_alt__['use_alt_inode']
__file_format_extension__ = __file_format_alt__['format_extension']
__file_format_default__ = __file_format_magic__
__file_format_multi_dict__ = {}
__file_format_multi_dict__.update({__file_format_main__['format_magic']: __file_format_main__})
__file_format_multi_dict__.update({__file_format_alt__['format_magic']: __file_format_alt__})
try:
__file_format_multi_dict__.update({__file_format_alt_kor__['format_magic']: __file_format_alt_kor__})
except:
pass
__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__}
__file_format_default__ = decode_unicode_escape(config.get('config', 'default'))
# Loop through all sections
for section in config.sections():
required_keys = [
"len", "hex", "ver", "name", "proname",
"lower", "magic", "delimiter", "extension",
"newstyle", "advancedlist", "altinode"
]
if all(key in config[section] for key in required_keys):
__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')} } )
if("CatFile" not in __file_format_multi_dict__):
__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"} } )
if("ねこファイル" not in __file_format_multi_dict__):
__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"} } )
if("네코파일" not in __file_format_multi_dict__):
__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"} } )
__file_format_name__ = __file_format_multi_dict__[__file_format_default__]['format_name']
__program_name__ = __file_format_multi_dict__[__file_format_default__]['program_name']
__file_format_lower__ = __file_format_multi_dict__[__file_format_default__]['format_lower']
__file_format_magic__ = __file_format_multi_dict__[__file_format_default__]['format_magic']
__file_format_len__ = __file_format_multi_dict__[__file_format_default__]['format_len']
__file_format_hex__ = __file_format_multi_dict__[__file_format_default__]['format_hex']
__file_format_delimiter__ = __file_format_multi_dict__[__file_format_default__]['format_delimiter']
__file_format_ver__ = __file_format_multi_dict__[__file_format_default__]['format_ver']
__use_new_style__ = __file_format_multi_dict__[__file_format_default__]['new_style']
__use_advanced_list__ = __file_format_multi_dict__[__file_format_default__]['use_advanced_list']
__use_alt_inode__ = __file_format_multi_dict__[__file_format_default__]['use_alt_inode']
__file_format_extension__ = __file_format_multi_dict__[__file_format_default__]['format_extension']
__file_format_dict__ = __file_format_multi_dict__[__file_format_default__]
__project__ = __program_name__
__project_url__ = "https://github.com/GameMaker2k/PyCatFile"
__version_info__ = (0, 16, 4, "RC 1", 1)
Expand Down

0 comments on commit 172996c

Please sign in to comment.