Skip to content

Commit

Permalink
Another update
Browse files Browse the repository at this point in the history
  • Loading branch information
KazukiPrzyborowski committed Jan 24, 2025
1 parent 724126f commit ea3fb9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions catfile.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[config]
default = CatFile
proname = PyCatFile

[CatFile]
len = 7
Expand Down
15 changes: 8 additions & 7 deletions pycatfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ def get_default_threads():
__use_http_lib__ = "urllib"
__file_format_multi_dict__ = {}
__file_format_default__ = "CatFile"
__program_name__ = "Py".__file_format_default__
if os.path.exists(__config_file__) and __use_ini_file__:
config = configparser.ConfigParser()
config.read(__config_file__)
Expand All @@ -293,23 +294,23 @@ def decode_unicode_escape(value):
else: # Python 3
return bytes(value, 'UTF-8').decode('unicode_escape')
__file_format_default__ = decode_unicode_escape(config.get('config', 'default'))
__program_name__ = decode_unicode_escape(config.get('config', 'proname'))
# Loop through all sections
for section in config.sections():
required_keys = [
"len", "hex", "ver", "name", "proname",
"lower", "magic", "delimiter", "extension",
"len", "hex", "ver", "name", "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': decode_unicode_escape(config.get(section, 'extension')), 'program_name': decode_unicode_escape(config.get(section, 'proname'))} } )
__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': decode_unicode_escape(config.get(section, 'extension')) } } )
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"} } )
__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" } } )
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': ".ねこ", 'program_name': "PyNekoFile"} } )
__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': ".ねこ" } } )
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': ".네코", 'program_name': "PyNekoFile"} } )
__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': ".네코" } } )
__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']
Expand Down

0 comments on commit ea3fb9e

Please sign in to comment.