(files=None)
| 403 | |
| 404 | |
| 405 | def 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 | |
| 436 | def read_mime_types(file): |
no test coverage detected
searching dependent graphs…