File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55'''
66
77import ctypes
8+ import os
89
910from collections import namedtuple
1011
1617
1718_libraries = {}
1819_libraries ['magic' ] = loader .load_lib ()
20+ magic_file = None
21+ if not os .environ .get ("MAGIC" ):
22+ # wheels package the mime database in this directory
23+ # prefer it when no magic file is specified by the user
24+ mime_db = os .path .join (os .path .dirname (__file__ ), 'magic.mgc' )
25+ if os .path .exists (mime_db ):
26+ magic_file = mime_db
1927
2028# Flag constants for open and setflags
2129MAGIC_NONE = NONE = 0
@@ -178,7 +186,7 @@ def setflags(self, flags):
178186 """
179187 return _setflags (self ._magic_t , flags )
180188
181- def load (self , filename = None ):
189+ def load (self , filename = magic_file ):
182190 """
183191 Must be called to load entries in the colon separated list of database
184192 files passed as argument or the default database file if no argument
You can’t perform that action at this time.
0 commit comments