https://github.com/guilt/reimportlib
reimportlib: Refactored Imports.
https://github.com/guilt/reimportlib
Last synced: over 1 year ago
JSON representation
reimportlib: Refactored Imports.
- Host: GitHub
- URL: https://github.com/guilt/reimportlib
- Owner: guilt
- License: bsd-3-clause
- Created: 2019-06-24T18:45:43.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-05-26T07:12:47.000Z (about 6 years ago)
- Last Synced: 2025-02-24T10:13:51.260Z (over 1 year ago)
- Language: Python
- Homepage: https://pypi.org/project/reimportlib/
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# reimportlib: refactored imports
reimportlib is used to help with refactored old code
where the imports were moved out, but you still wish
to get legacy packages/classes to work, because you
had serialized them at a point in time but they aren't
available today.
## Main Features
* Very compact
* Few Dependencies
## Usage
```python
import reimportlib
__import__ = reimportlib.import_
reimportlib.configure() # Reads mappings in .reimport.json
reimportlib.remap('foo.bar.', 'examples.foo.') # Notice the . at the end
print(reimportlib.get_remapped_name('foo.bar.C')) # 'examples.foo.C'
print(reimportlib.import_module('foo.bar.B'))
print(reimportlib.import_from('foo.bar.D', 'c'))
reimportlib.instantiate('foo.bar.D', 'Foo', *[4], val=True)
```
And then it should automatically be able to import or instantiate
the new classes as required. Do check the provided test.py with
this distribution.