Get the path of a file relative to the current module. Import a Python module relative to the current module. Temporarily change sys.path for imports. Get the path of a file relative to the module of the current caller.
Links
GitHub: https://github.com/xflr6/current
Issue Tracker: https://github.com/xflr6/current/issues
Installation
This package runs under Python 2.7 and 3.3+, use pip to install:
$ pip install current
Usage
Get paths relative to the current module:
>>> import current
>>> here = current.current_path()
>>> parent = current.current_path('..')
>>> bruces = current.current_path('..', 'australia', 'bruces', 'bruces.ini')
Temporarily add the parent directory to sys.path:
>>> with current.inserted_path()
... import australia
Get paths relative to the module of the callers of the current code:
>>> caller = current.caller_path()
>>> callercaller = current.caller_path(steps=2)
Potential issues
This package uses sys._getframe (which is almost the same as inspect.currentframe, see docs). Under IronPython this might require enabling the FullFrames option of the interpreter.
License
Changelog
- Version 0.3.2 Port tests from nose/unittest to pytest.
Update meta data, tag Python 3.5/3.6 support.
Version 0.3.1: Added wheel.
Version 0.3: Added Python 3.3+ support.
Version 0.2.1: Fixed caller_path. Documented sys._getframe dependency.
Version 0.2: Added caller_path.
Version 0.1: First public release.
Metadata
Release files for current 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| current-0.3.2.zip | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| current-0.3.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 13.1 kB
Release files / current-0.3.2.zip
| Download URL | current-0.3.2.zip |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
254e5e95a9cf2029b3543bc076b61dc80a5eb6fcc06874a8651d64de4fce061f
|
|
BLAKE2b-256 checksum How to use checksums |
35a4415b5c12e2ad2cdcd5a9194e2ec1839d42b0bb56de957bed726cd7070683
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / current-0.3.2-py2.py3-none-any.whl
| Download URL | current-0.3.2-py2.py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
bfe0b41fa617ef9f24a2bc976b66d198a55524f193c7f565c0cf1c3b8c8077f5
|
|
BLAKE2b-256 checksum How to use checksums |
266dea4dde1509c86db26f8d0f50c26f7485094bb3ef9f470928754805ca9981
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |