Advanced descriptors for special cases.
Project description
Advanced descriptors
This package includes helpers for special cases:
SeparateClassMethod - allow to have classmethod and normal method both with the same name.
AdvancedProperty - property with possibility to set class wide getter.
SeparateClassMethod
This descriptor can be set using standard decorator syntax. Create instance with arguments:
def imeth(instance):
return instance.value
def cmeth(owner):
return owner.value
class Target(object):
value = 1
def __init__(self):
self.value = 2
getval = advanced_descriptors.SeparateClassMethod(
imeth, cmeth
)
Create instance wrapping as decorator:
class Target(object):
value = 1
def __init__(self):
self.value = 2
@advanced_descriptors.SeparateClassMethod
def getval(self):
return self.value
@getval.class_method
def getval(cls):
return cls.value
Cases with method only and classmethod only is useless: method as-is and @classmethod should be used in corresponding cases.
AdvancedProperty
This descriptor should be used in cases, when in addition to normal property API, class getter is required. If class-wide setter and deleter also required - you should use standard propery in metaclass.
Usage examples:
In addition to normal property API:
class Target(object): _value = 777 def __init__(self): self._value = 42 @advanced_descriptors.AdvancedProperty def val(self): return self._value @val.setter def val(self, value): self._value = value @val.deleter def val(self): self._value = 0 @val.cgetter def val(cls): return cls._value
Use class-wide getter for instance too:
class Target(object): _value = 1 val = advanced_descriptors.AdvancedProperty() @val.cgetter def val(cls): return cls._value
Testing
The main test mechanism for the package advanced-descriptors is using tox. Available environments can be collected via tox -l
CI systems
For code checking several CI systems is used in parallel:
Travis CI: is used for checking: PEP8, pylint, bandit, installation possibility and unit tests. Also it’s publishes coverage on coveralls.
coveralls: is used for coverage display.
CD system
Travis CI: is used for package delivery on PyPI.
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 Distributions
Hashes for Advanced-Descriptors-1.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa1918d45427a7da817d7b41737a3ad0c63dd0039dfffe712a214a5c27c19c54 |
|
MD5 | 7b31542bb8a791bcc2171b7f643ca1ad |
|
BLAKE2b-256 | d0fd779d8611a58a8d833d83c1921b03c6514e47a4a87654087bf5a5cb821807 |
Hashes for Advanced_Descriptors-1.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb78b547eb8f517d6e4d30ea07a319cf9d156744f6c34cec4aab7d5a918bb16a |
|
MD5 | 33e35a06e908ad6fa7a3e62642d4abef |
|
BLAKE2b-256 | c5a6d495fce94eccbf2b951764107824f376ad4b05bc35a59030c2325d395b49 |
Hashes for Advanced_Descriptors-1.0.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf865d8ea253d47a21f39696796c780adfa3a1bf622f0e9c2ca5b21fca7bf222 |
|
MD5 | 10810d8770b8bebc837871d7d6bdd10c |
|
BLAKE2b-256 | 0c480f1fb506d303e7db7942688ad06725eb63e9bfbf1ac9283cab15011d69bd |
Hashes for Advanced_Descriptors-1.0.6-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 167ae1a098f897a0e0b7b281a599aeaf0a0e49e41ba8d31a915c23e5c3252bb9 |
|
MD5 | 06ff90e1bc08bc427ca366aa2c98d316 |
|
BLAKE2b-256 | 13b616f6111edfdadb36f376a1d85ec336e08de7232274f206e93ee99644e687 |
Hashes for Advanced_Descriptors-1.0.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e3af6086ab3b0be60c61376059d771cdffa82235573f5c41ebb50e7858e219d |
|
MD5 | 7765f38949ab6dc30be193b5207ea70b |
|
BLAKE2b-256 | 5af4864b58e45ab3e8e5d9b4fb251e9b3b5a5b2f536e7274dbfc2d9c46a520e6 |
Hashes for Advanced_Descriptors-1.0.6-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 610ba912be556267739512570f5a0e4cda3cdaa31b9b663c0ef589c2954101f8 |
|
MD5 | 9b78e9486f6b8dd2f357aff9eee5c97f |
|
BLAKE2b-256 | 894ef92b55bbd231ecac3bf869fc37c149e185bfab301d7f519f8b3628f74e77 |
Hashes for Advanced_Descriptors-1.0.6-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d365cd3ee7a16775efa38a94e64feaf4136d00b649942374ca72a656e938ccc3 |
|
MD5 | cca5ab50503f46a0b86ce06a30368f8f |
|
BLAKE2b-256 | 64e2dab6e709fd866ae8b1ef34126b732469a81bd3b667ac64c6d30edecc78f8 |
Hashes for Advanced_Descriptors-1.0.6-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0acdc591155eac52f2d213240d4f48d0749a24c6d816ded5cd8764a1c24f78c8 |
|
MD5 | 098c82f461b734da025ca0c0698758bf |
|
BLAKE2b-256 | f5122a588b95c3373cbfdde5a72433eb537dd6731e2c1bbe8323a07048af1268 |
Hashes for Advanced_Descriptors-1.0.6-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7556023203a145c17e2490eafe8544dba9742686ddffce8b132c1f4388314879 |
|
MD5 | 6281f9b4ae3406840a05200ff7878871 |
|
BLAKE2b-256 | c6d46ce11be9b6a6a270606bb299bfd3f4ff62509c5c7eeff56ca208566f06ef |
Hashes for Advanced_Descriptors-1.0.6-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58ba8e0d584c23ee8c90233af6cd90844ea4828615e7dbed548e8ed33de0a602 |
|
MD5 | 26af5bd96e742cd48c85f4b4e2b59571 |
|
BLAKE2b-256 | cae5f6ada66e4e94cc4ed9654d8f3e7ed95c1dab1e76d23649c6a587389d9ea1 |