|
1 | | -"""A pure Python implementation of import. |
2 | | -
|
3 | | -References on import: |
4 | | -
|
5 | | - * Language reference |
6 | | - http://docs.python.org/ref/import.html |
7 | | - * __import__ function |
8 | | - http://docs.python.org/lib/built-in-funcs.html |
9 | | - * Packages |
10 | | - http://www.python.org/doc/essays/packages.html |
11 | | - * PEP 235: Import on Case-Insensitive Platforms |
12 | | - http://www.python.org/dev/peps/pep-0235 |
13 | | - * PEP 275: Import Modules from Zip Archives |
14 | | - http://www.python.org/dev/peps/pep-0273 |
15 | | - * PEP 302: New Import Hooks |
16 | | - http://www.python.org/dev/peps/pep-0302/ |
17 | | - * PEP 328: Imports: Multi-line and Absolute/Relative |
18 | | - http://www.python.org/dev/peps/pep-0328 |
19 | | -
|
20 | | -""" |
| 1 | +"""A pure Python implementation of import.""" |
21 | 2 | __all__ = ['__import__', 'import_module', 'invalidate_caches'] |
22 | 3 |
|
23 | 4 | from . import _bootstrap |
|
37 | 18 |
|
38 | 19 | # Public API ######################################################### |
39 | 20 |
|
40 | | -from ._bootstrap import __import__, invalidate_caches |
| 21 | +from ._bootstrap import __import__ |
| 22 | + |
| 23 | + |
| 24 | +def invalidate_caches(): |
| 25 | + """Call the invalidate_caches() method on all finders stored in |
| 26 | + sys.path_importer_caches (where implemented).""" |
| 27 | + for finder in sys.path_importer_cache.values(): |
| 28 | + if hasattr(finder, 'invalidate_caches'): |
| 29 | + finder.invalidate_caches() |
41 | 30 |
|
42 | 31 |
|
43 | 32 | def import_module(name, package=None): |
|
0 commit comments