@@ -40,7 +40,10 @@ class Magic:
4040
4141 def __init__ (self , mime = False , magic_file = None , mime_encoding = False ,
4242 keep_going = False , uncompress = False , raw = False , extension = False ,
43- follow_symlinks = False ):
43+ follow_symlinks = False , check_tar = True , check_soft = True ,
44+ check_apptype = True , check_elf = True , check_text = True ,
45+ check_cdf = True , check_csv = True , check_encoding = True ,
46+ check_json = True , check_simh = True ):
4447 """
4548 Create a new libmagic wrapper.
4649
@@ -69,6 +72,27 @@ def __init__(self, mime=False, magic_file=None, mime_encoding=False,
6972 if follow_symlinks :
7073 self .flags |= MAGIC_SYMLINK
7174
75+ if not check_tar :
76+ self .flags |= MAGIC_NO_CHECK_TAR
77+ if not check_soft :
78+ self .flags |= MAGIC_NO_CHECK_SOFT
79+ if not check_apptype :
80+ self .flags |= MAGIC_NO_CHECK_APPTYPE
81+ if not check_elf :
82+ self .flags |= MAGIC_NO_CHECK_ELF
83+ if not check_text :
84+ self .flags |= MAGIC_NO_CHECK_TEXT
85+ if not check_cdf :
86+ self .flags |= MAGIC_NO_CHECK_CDF
87+ if not check_csv :
88+ self .flags |= MAGIC_NO_CHECK_CSV
89+ if not check_encoding :
90+ self .flags |= MAGIC_NO_CHECK_ENCODING
91+ if not check_json :
92+ self .flags |= MAGIC_NO_CHECK_JSON
93+ if not check_simh :
94+ self .flags |= MAGIC_NO_CHECK_SIMH
95+
7296 self .cookie = magic_open (self .flags )
7397 self .lock = threading .Lock ()
7498
@@ -411,10 +435,16 @@ def version():
411435MAGIC_NO_CHECK_SOFT = 0x004000 # Don't check magic entries
412436MAGIC_NO_CHECK_APPTYPE = 0x008000 # Don't check application type
413437MAGIC_NO_CHECK_ELF = 0x010000 # Don't check for elf details
414- MAGIC_NO_CHECK_ASCII = 0x020000 # Don't check for ascii files
415- MAGIC_NO_CHECK_TROFF = 0x040000 # Don't check ascii/troff
416- MAGIC_NO_CHECK_FORTRAN = 0x080000 # Don't check ascii/fortran
417- MAGIC_NO_CHECK_TOKENS = 0x100000 # Don't check ascii/tokens
438+ MAGIC_NO_CHECK_TEXT = 0x020000 # Don't check for ascii files
439+ MAGIC_NO_CHECK_ASCII = 0x020000 # Deprecated alias for MAGIC_NO_CHECK_TEXT
440+ MAGIC_NO_CHECK_TROFF = 0x040000 # Don't check ascii/troff (deprecated)
441+ MAGIC_NO_CHECK_FORTRAN = 0x080000 # Don't check ascii/fortran (deprecated)
442+ MAGIC_NO_CHECK_TOKENS = 0x100000 # Don't check ascii/tokens (deprecated)
443+ MAGIC_NO_CHECK_CDF = 0x0040000 # Don't check for CDF files
444+ MAGIC_NO_CHECK_CSV = 0x0080000 # Don't check for CSV files
445+ MAGIC_NO_CHECK_ENCODING = 0x0200000 # Don't check text encodings
446+ MAGIC_NO_CHECK_JSON = 0x0400000 # Don't check for JSON files
447+ MAGIC_NO_CHECK_SIMH = 0x0800000 # Don't check for SIMH tape files
418448
419449MAGIC_PARAM_INDIR_MAX = 0 # Recursion limit for indirect magic
420450MAGIC_PARAM_NAME_MAX = 1 # Use count limit for name/use magic
0 commit comments