Skip to content

Commit 618fa4c

Browse files
Add files via upload
1 parent 91f0682 commit 618fa4c

1 file changed

Lines changed: 36 additions & 23 deletions

File tree

pycatfile.py

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,24 @@ def get_default_threads():
355355
# os.cpu_count() might not be available in some environments
356356
return 1
357357

358+
def add_format(reg, key, magic, ext, name=None, ver="001",
359+
new_style=True, use_advanced_list=True, use_alt_inode=False, delim="\x00"):
360+
if key in reg:
361+
return
362+
magic_bytes = magic.encode("utf-8")
363+
reg[key] = {
364+
"format_name": name or key,
365+
"format_magic": magic,
366+
"format_len": len(magic_bytes),
367+
"format_hex": magic_bytes.hex(),
368+
"format_delimiter": delim,
369+
"format_ver": ver,
370+
"new_style": new_style,
371+
"use_advanced_list": use_advanced_list,
372+
"use_alt_inode": use_alt_inode,
373+
"format_extension": ext,
374+
}
375+
358376
__upload_proto_support__ = "^(http|https|ftp|ftps|sftp|scp|tcp|udp)://"
359377
__download_proto_support__ = "^(http|https|ftp|ftps|sftp|scp|tcp|udp)://"
360378
__use_pysftp__ = False
@@ -585,24 +603,19 @@ def _get(section_dict, key, default=None):
585603
__include_defaults__ = True
586604
if not __use_ini_file__ and not __include_defaults__:
587605
__include_defaults__ = True
588-
if(__include_defaults__):
589-
if("CatFile" not in __file_format_multi_dict__):
590-
__file_format_multi_dict__.update( { 'CatFile': {'format_name': "CatFile", 'format_magic': "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" } } )
591-
if("NekoFile" not in __file_format_multi_dict__):
592-
__file_format_multi_dict__.update( { 'NekoFile': {'format_name': "NekoFile", 'format_magic': "NekoFile", 'format_len': 8, 'format_hex': "4e656b6f46696c65", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".neko" } } )
593-
if("ねこファイル" not in __file_format_multi_dict__):
594-
__file_format_multi_dict__.update( { 'ねこファイル': {'format_name': "NekoFairu", 'format_magic': "ねこファイル", 'format_len': 18, 'format_hex': "e381ade38193e38395e382a1e382a4e383ab", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".ねこ" } } )
595-
if("ネコファイル" not in __file_format_multi_dict__):
596-
__file_format_multi_dict__.update( { 'ネコファイル': {'format_name': "NekoFairu", 'format_magic': "ネコファイル", 'format_len': 18, 'format_hex': "e381ade38193e38395e382a1e382a4e383ab", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".ネコ" } } )
597-
if("네코파일" not in __file_format_multi_dict__):
598-
__file_format_multi_dict__.update( { '네코파일': {'format_name': "NekoPa-il", 'format_magic': "네코파일", 'format_len': 12, 'format_hex': "eb84a4ecbd94ed8c8cec9dbc", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".네코" } } )
599-
if("고양이파일" not in __file_format_multi_dict__):
600-
__file_format_multi_dict__.update( { '고양이파일': {'format_name': "GoyangiPa-il", 'format_magic': "고양이파일", 'format_len': 15, 'format_hex': "eab3a0ec9691ec9db4ed8c8cec9dbc", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".고양이" } } )
601-
if("内酷法伊鲁" not in __file_format_multi_dict__):
602-
__file_format_multi_dict__.update( { '内酷法伊鲁': {'format_name': "NèiKùFǎYīLǔ", 'format_magic': "内酷法伊鲁", 'format_len': 15, 'format_hex': "e58685e985b7e6b395e4bc8ae9b281", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".内酷" } } )
603-
if("猫文件" not in __file_format_multi_dict__):
604-
__file_format_multi_dict__.update( { '猫文件': {'format_name': "MāoWénjiàn", 'format_magic': "猫文件", 'format_len': 9, 'format_hex': "e78cabe69687e4bbb6", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".猫" } } )
605-
if(__file_format_default__ not in __file_format_multi_dict__):
606+
if __include_defaults__:
607+
# Cat / Neko
608+
add_format(__file_format_multi_dict__, "CatFile", "CatFile", ".cat", "CatFile")
609+
add_format(__file_format_multi_dict__, "NekoFile", "NekoFile", ".neko", "NekoFile")
610+
add_format(__file_format_multi_dict__, "ねこファイル", "ねこファイル", ".ねこ", "NekoFairu")
611+
add_format(__file_format_multi_dict__, "ネコファイル", "ネコファイル", ".ネコ", "NekoFairu")
612+
add_format(__file_format_multi_dict__, "네코파일", "네코파일", ".네코", "NekoPa-il")
613+
add_format(__file_format_multi_dict__, "고양이파일", "고양이파일", ".고양이", "GoyangiPa-il")
614+
add_format(__file_format_multi_dict__, "内酷法伊鲁", "内酷法伊鲁", ".内酷", "NèiKùFǎYīLǔ")
615+
add_format(__file_format_multi_dict__, "猫文件", "猫文件", ".猫", "MāoWénjiàn")
616+
617+
# Pick a default if current default key is not present
618+
if __file_format_default__ not in __file_format_multi_dict__:
606619
__file_format_default__ = next(iter(__file_format_multi_dict__))
607620
__file_format_name__ = __file_format_multi_dict__[__file_format_default__]['format_name']
608621
__file_format_magic__ = __file_format_multi_dict__[__file_format_default__]['format_magic']
@@ -691,7 +704,7 @@ def _get(section_dict, key, default=None):
691704

692705
# Operating system bitness
693706
try:
694-
OSBitness = platform.architecture()[0].replace("bit", "")
707+
OSBitness = platform.cathitecture()[0].replace("bit", "")
695708
except Exception:
696709
m = platform.machine().lower()
697710
OSBitness = "64" if "64" in m else "32"
@@ -13734,7 +13747,7 @@ def run_tcp_file_server(fileobj, url, on_progress=None):
1373413747
Ends after serving exactly one client or wait window elapses.
1373513748

1373613749
URL example:
13737-
tcp://user:pass@0.0.0.0:5000/path/my.arc?
13750+
tcp://user:pass@0.0.0.0:5000/path/my.cat?
1373813751
auth=1&enforce_path=1&rate=200000&timeout=5&wait=30&ssl=0
1373913752
"""
1374013753
parts, o = _parse_net_url(url) # already returns proto/host/port/timeout/ssl/etc.
@@ -13936,7 +13949,7 @@ def run_udp_file_server(fileobj, url, on_progress=None):
1393613949
Ends after serving exactly one client or wait window elapses.
1393713950

1393813951
URL example:
13939-
udp://user:pass@0.0.0.0:5001/path/my.arc?
13952+
udp://user:pass@0.0.0.0:5001/path/my.cat?
1394013953
auth=1&enforce_path=1&rate=250000&timeout=5&wait=30
1394113954
"""
1394213955
parts, o = _parse_net_url(url)
@@ -14360,7 +14373,7 @@ def run_tcp_file_server(fileobj, url, on_progress=None):
1436014373
Ends after serving exactly one client or wait window elapses.
1436114374

1436214375
URL example:
14363-
tcp://user:pass@0.0.0.0:5000/path/my.arc?
14376+
tcp://user:pass@0.0.0.0:5000/path/my.cat?
1436414377
auth=1&enforce_path=1&rate=200000&timeout=5&wait=30&ssl=0
1436514378
"""
1436614379
parts, o = _parse_net_url(url) # already returns proto/host/port/timeout/ssl/etc.
@@ -14912,7 +14925,7 @@ def run_udp_file_server(fileobj, url, on_progress=None):
1491214925
Ends after serving exactly one client or wait window elapses.
1491314926

1491414927
URL example:
14915-
udp://user:pass@0.0.0.0:5001/path/my.arc?
14928+
udp://user:pass@0.0.0.0:5001/path/my.cat?
1491614929
auth=1&enforce_path=1&rate=250000&timeout=5&wait=30
1491714930
"""
1491814931
parts, o = _parse_net_url(url)

0 commit comments

Comments
 (0)