MCPcopy Index your code
hub / github.com/python/cpython / init

Function init

Lib/mimetypes.py:405–433  ·  view source on GitHub ↗
(files=None)

Source from the content-addressed store, hash-verified

403
404
405def init(files=None):
406 global suffix_map, types_map, encodings_map, common_types
407 global inited, _db
408 inited = True # so that MimeTypes.__init__() doesn't call us again
409
410 if files is None or _db is None:
411 db = MimeTypes()
412 # Quick return if not supported
413 db.read_windows_registry()
414
415 if files is None:
416 files = knownfiles
417 else:
418 files = knownfiles + list(files)
419 else:
420 db = _db
421
422 # Lazy import to improve module import time
423 import os
424
425 for file in files:
426 if os.path.isfile(file):
427 db.read(file)
428 encodings_map = db.encodings_map
429 suffix_map = db.suffix_map
430 types_map = db.types_map[True]
431 common_types = db.types_map[False]
432 # Make the DB a global variable now that it is fully initialized
433 _db = db
434
435
436def read_mime_types(file):

Callers 6

__init__Method · 0.70
guess_typeFunction · 0.70
guess_file_typeFunction · 0.70
guess_all_extensionsFunction · 0.70
guess_extensionFunction · 0.70
add_typeFunction · 0.70

Calls 5

read_windows_registryMethod · 0.95
readMethod · 0.95
MimeTypesClass · 0.85
listClass · 0.85
isfileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…