Advanded 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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8f9c76272de4b52851fd308c80739affea5659c583108fba4429bb7df727a7a |
|
MD5 | b7760d06d262ed20d18f3e70712c7c12 |
|
BLAKE2b-256 | d4e10681f740c2e43c2a289b15a6248b733a622d3ec8646f48a45e8c0560c7a6 |
Hashes for Advanced_Descriptors-1.0.4-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4392e0253b97039028e19c8e792decd58a55c61096ac56c81fdb7053bb75e30 |
|
MD5 | 06a0774ce0deddc701c975661f014e58 |
|
BLAKE2b-256 | 0d158d9bf29361fab2f174b7534753dac13cfb91eb89a2bc01d8865bc69540e8 |
Hashes for Advanced_Descriptors-1.0.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e93de798d3ee067121769c5ebb61fbb8044c92d31c0dad15120e96a14f758093 |
|
MD5 | 9735d62ddf1dd3c28df061034d4c885d |
|
BLAKE2b-256 | 5842009be25389cfc0fba058a8be453352ce64f78db4bea20953581e5123cae1 |
Hashes for Advanced_Descriptors-1.0.4-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1797cdbbdb5038a6c62ae98c59e0c13d46c2c2ca52058aaf872066159606227 |
|
MD5 | 8feac5f7391ef4bcd652cf8cf4cfb08e |
|
BLAKE2b-256 | ab5a473b1663d130705f0e3df23a132f31d75522486ceec33beddcadbbf74424 |
Hashes for Advanced_Descriptors-1.0.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c49e856fc771674ce628e90740a4d5b2fd31d491172dfe33d3865df22c0f6471 |
|
MD5 | 3b222cf4fd930c21bf8da2fb7a825f29 |
|
BLAKE2b-256 | b048f51c36cab5eabcd7e4d0d0535abd0947536febc04fd523f67549f5daf64d |
Hashes for Advanced_Descriptors-1.0.4-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a039a546e253135364f5bd251c3ef11621711f735d20ea33dd246875f3a3848d |
|
MD5 | 678db102a4e290c2f460d32826c3c61c |
|
BLAKE2b-256 | ccd577f9f9e8bd5dc932904779ca897839fa937690361336f3ba9409ffcbaa69 |
Hashes for Advanced_Descriptors-1.0.4-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2426dcd7f505fcde2148e506e4db91ce7bfa90a8e5d61c350345854fff709aa6 |
|
MD5 | 7d3a43f2dbe21b89fed0d52cd944698e |
|
BLAKE2b-256 | 77c58048824943b3193908856f917b13689f8d4d12b16ac3faa04d2c516844d1 |
Hashes for Advanced_Descriptors-1.0.4-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f56bcbe1492ada3b8ae51d4b0533ee816b33a9b04977e0fe3d65e287ad081b0 |
|
MD5 | 11c58931e1ddd2440d63f291cafad139 |
|
BLAKE2b-256 | 3f08533781f38201097d64fa3fd70b37f9aa4ba51af2ee0eaa4a9ca6bdbd61b4 |
Hashes for Advanced_Descriptors-1.0.4-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c59fcc7e4929953fb4fb9e7e50c2a7211757d6dbd5688b79c7b8b4edb541a623 |
|
MD5 | 5aa22d61fc5bb3eb2415e4df20c9a916 |
|
BLAKE2b-256 | 20d296df332007c9ccdc6c8e0c13ca719b766c3214611c1ee53877ee43a54bce |
Hashes for Advanced_Descriptors-1.0.4-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31bf15cdca6c3773c8300cc3fec0a114a4c168992754d298f1e2f72210a26d37 |
|
MD5 | a61c5f62e1bf6ed9d1022d958638a57e |
|
BLAKE2b-256 | 7047461dd0a26ab8ce5d77acd4b8b0e38b5ffe097e1aa887b3761208dfffee6d |