@@ -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,12 +603,12 @@ def _get(section_dict, key, default=None):
585603 __include_defaults__ = True
586604if not __use_ini_file__ and not __include_defaults__:
587605 __include_defaults__ = True
588- if( __include_defaults__) :
589- if( "ArchiveFile" not in __file_format_multi_dict__):
590- __file_format_multi_dict__.update( { 'ArchiveFile': {'format_name': "ArchiveFile", 'format_magic': "ArchiveFile ", 'format_len': 11, 'format_hex': "4172636869766546696c65", 'format_delimiter': "\x00 ", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".arc" } } )
591- if("NeoFile" not in __file_format_multi_dict__):
592- __file_format_multi_dict__.update( { 'NeoFile': {'format_name': "NeoFile", 'format_magic': "NeoFile", 'format_len': 7, 'format_hex': "4e656f46696c65", 'format_delimiter': "\x00", 'format_ver': "001", 'new_style': True, 'use_advanced_list': True, 'use_alt_inode': False, 'format_extension': ".neo" } } )
593- if( __file_format_default__ not in __file_format_multi_dict__) :
606+ if __include_defaults__:
607+ add_format(__file_format_multi_dict__, "ArchiveFile", "ArchiveFile", ".arc", "ArchiveFile")
608+ add_format(__file_format_multi_dict__, "NeoFile ", "NeoFile ", ".neo", "NeoFile" )
609+
610+ # Pick a default if current default key is not present
611+ if __file_format_default__ not in __file_format_multi_dict__:
594612 __file_format_default__ = next(iter(__file_format_multi_dict__))
595613__file_format_name__ = __file_format_multi_dict__[__file_format_default__]['format_name']
596614__file_format_magic__ = __file_format_multi_dict__[__file_format_default__]['format_magic']
0 commit comments