a small package for enforcing package requirements at the class- or function-level
Project description
Overview
force-dependencies is a small package for enforcing package requirements at the class- or function-level.
Simply use:
from force_deps import requires, requires_any, requires_all
@requires("sqlalchemy")
class SQLHandler(object):
def __init__(self):
pass
db = SQLHandler()
Traceback (most recent call last):
...
ImportError: You must import `sqlalchemy` in order to run `SQLHandler`
to require users to have a package installed in order to use your class or function,
@requires_any(["sqlalchemy", "sqlite3"])
...
to require that users have at least one of a number of packages installed, or
@requires_all(["sqlalchemy", "pandas"])
...
to require that users have all of a number of packages installed in order to use a class or function.
Finally, you can combine the decorators together in pretty much any way you please:
@requires_any(["sqlalchemy", "sqlite3"])
@requires("pandas")
...
Installation / Usage
To install use pip:
$ pip install force_deps
Or clone the repo:
$ git clone https://github.com/maxblee/force_deps.git
$ python setup.py install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file force_deps-0.1.0.tar.gz.
File metadata
- Download URL: force_deps-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9bb1510aea2a952f7b06bcf4bd7a1971bbc42c461551d0a64e2220f96ae28e7
|
|
| MD5 |
db5d85719ad0577f93e744ea6f754bc8
|
|
| BLAKE2b-256 |
bd14dc652bf7ebf6ed0b58614d41053bbf442ec5887a16d381e0a639d7f84805
|
File details
Details for the file force_deps-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: force_deps-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.36.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98340b5e29934eec854a99e07f64fd32a5d3d6073a12671c7c4520bb688c8cd9
|
|
| MD5 |
fb8f4a9eca8de7ea1bfb1b592c704b58
|
|
| BLAKE2b-256 |
d2291a5bcb045642c05b4cca211f39c22a907e5cf8c755bfc7496618b8d0ea6e
|