dependencies helper
Project description
dependency helper
Dependency helper for properties of python class
$ pip install deps_helper
from deps_helper import Dependencies
class A(deps := Dependencies.new()):
@deps.register(_for="operation")
def requested_by(self, user):
print(f"operation requested by {user}.")
return f"requested by {user}"
@deps.register(_for=["check_validity", "operation"])
def validity(*_):
...
@deps.guard()
def operation(self):
print("execute operation...")
@deps.guard()
def check_validity(self):
if self.validity:
print("Ok")
>>> a = A()
>>> a.check_validity()
Traceback (most recent call last):
...
AttributeError: ("follow attributes are not assigned for check_validity => ", [validity])
>>> a.operation()
Traceback (most recent call last):
...
AttributeError: ("follow attributes are not assigned for operation => ", [requested_by, validity])
>>> a.validity = True
>>> a.check_validity()
Ok
>>> a.requested_by = "admin"
operation requested by admin.
>>> a.operation()
execute operation...
>>> print(a.requested_by)
requested by admin
>>>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
deps_helper-0.1.6.tar.gz
(1.8 kB
view hashes)
Built Distribution
Close
Hashes for deps_helper-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97849a25e118b8df30f263d883ef7b8a022678b7b463db12782830da12583e7f |
|
MD5 | 7cdb3c81b10eeede31b775863c69cada |
|
BLAKE2b-256 | a5f0e983537ebe8341868d20f7fdaf34e7bbe6bd538c23dae568bd70206148d8 |