Local Resources
This project is easy attempt to emulate Java's Class.getResource() method.
It provides simple access to files that are 'reachable' from directories and/or zip files referenced in PYTHONPATH.
Usage
Example:
from local_resources import Resource
with Resource("VERSION") as f:
version = f.read()
It returns read-only file object in binary mode.
Aside of reading knowing files it provides 'list' method which is similar to os.listdir(path) with one
caveat - directories are always returned with '/' appended:
from local_resources import Resource
files_and_dirs = Resource("").list()
for f in files_and_dirs:
if f.endswith("myfiles/to_print_on_screen"):
print(f"Do something with path {f}")
else:
with Resource(f) as file:
print(f"File {f}:")
print(file.read().decode('utf-8'))
Note: when list()' method is called there are no resources held after it finished, so there is no need for with` statement, nor cleaning up/closing resources at the end.
Note: for root of PYTHONPATH directories use """ or "/": Resource("").list().
Metadata
Release files for local-resources 1.0.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 | Provenance | Actions |
|---|---|---|---|---|
| local_resources-1.0.2.tar.gz | 6.7 kB | Without provenance | Details for local_resources-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| local_resources-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for local_resources-1.0.2-py3-none-any.whl |
Total release size: 14.3 kB
Release files / local_resources-1.0.2.tar.gz
| Download URL | local_resources-1.0.2.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4545cd2170767a20403c70ecac4b36089564965f2151d3eaf80e3ac6dbd954c1
|
|
BLAKE2b-256 checksum How to use checksums |
bf1715a6dbfbbb84b6e658ba49c072e87c0d35f1d57b0c54de0c5632b474565a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1
|
Release files / local_resources-1.0.2-py3-none-any.whl
| Download URL | local_resources-1.0.2-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e22517ab88d6a93d4ddf799050cd82d2c1e7d308d9acb8442ff3bddb15c4613
|
|
BLAKE2b-256 checksum How to use checksums |
add116c197fa3fafa5b44be2d7bc9492fe0428f92b1254907c84df8e489d715f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1
|
Security for local-resources 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.