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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cca90f5fba640a9ee6c419f29e5e79363f0c739cd1afeaa16e1f23e782287b6e |
|
MD5 | 16996a5af119c7b076d7619f210abdb1 |
|
BLAKE2b-256 | ab8ded036fcf48c732db56a2882ce7ac1aeb77e5ce658d732547bda25297f0f8 |
Hashes for Advanced_Descriptors-1.0.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b99f4fbe208e96450c4883aaf507b2face301dac570373d57f0b177c144d0db |
|
MD5 | 4e0805f818ab14ab5e2a0f8caf9dff5e |
|
BLAKE2b-256 | 73bd8513d15202736cff54f43f14535cb0827cc528b807cd35e42fdab6db14b6 |
Hashes for Advanced_Descriptors-1.0.1-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d19fa274686274f1db661189d4723f446671fcd2f2df959dade2c436f2db403 |
|
MD5 | 28ae142651d216a8c348f892eb51ba3d |
|
BLAKE2b-256 | d3a0ebdbc0342771342be7da54c89293a99534e953b2be6d7e22506acd06412d |
Hashes for Advanced_Descriptors-1.0.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf2a995516f87501f92650828dc742c5481b722b8bebefea8f9818e889f0fd79 |
|
MD5 | 509e55acb813aa82b6be919e1253c1cf |
|
BLAKE2b-256 | 1ae2dedb9efd71f20d20992b3d4b8d3dbf67eaa75cf653bd5e79af44954e3c97 |
Hashes for Advanced_Descriptors-1.0.1-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0adcbe93a1ab96bf8ed1b8fa2b092bf20619879978d27a3cd1f4f10789b82e1c |
|
MD5 | 57eda5742fe8637d959b89b15fbe9ba1 |
|
BLAKE2b-256 | 42a9e4a97893e3e854db704286d38d9e98e2f6f607b7fb56e847c7dc98746dbb |
Hashes for Advanced_Descriptors-1.0.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cb80df8c664242bf46b4e36b9cd3550f3591f50d65ebcee670674bc80101de0 |
|
MD5 | d5dc003f6cfa252842ce64b4284670fc |
|
BLAKE2b-256 | ed7cac9b459d97db3e6f7bda09c091094e5abb783fa75ab75ef2a589bdec3de6 |
Hashes for Advanced_Descriptors-1.0.1-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1c886c951f9a706ae122c1d42b412f4d1f8b99733e56aaef3ce5a464716810b |
|
MD5 | fa5059613371b99f10b15325bf881fcf |
|
BLAKE2b-256 | 16c4345e24e0fc71930e0ed6ac68c4f8afe19f19eff6d4051d30b850607c415f |
Hashes for Advanced_Descriptors-1.0.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 471f7b9fe4c29cae25dc506de8018456d02f0a7a37fd833dd0cee2bb444f8aee |
|
MD5 | 0294b8b12b4041122a520c48e857ae0e |
|
BLAKE2b-256 | b94ce131c979a52f3725ac8731c3bda5694e3782bb2707631c3342ec88be67fa |
Hashes for Advanced_Descriptors-1.0.1-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71df3d033a97305f9d18201a507d27cbf79a739b7db54ceefa04a3e9b6b34f00 |
|
MD5 | 2bfda47a98e77c0860cd069259c21e08 |
|
BLAKE2b-256 | cecbf78bc5ce12cf6c84f84b507f04bef5cd5c2448995f21c2dde444e046bb8d |
Hashes for Advanced_Descriptors-1.0.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e0cf4f6a814a392260eb8b27e97a4c1d705ab92602140deeab6572bf0d0df59 |
|
MD5 | 876727346c4be7ef37c5836bdd61fe94 |
|
BLAKE2b-256 | 9887c016b20d8a64452fac35c5d0e9b01473c63898dfeab24363d86ab567cd5a |
Hashes for Advanced_Descriptors-1.0.1-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4671cc18285cdf35aa96a676ec5a6f6ff9f87ff498062fe22f2320b66e01449f |
|
MD5 | d7d3e2557915f8fdb73fcf07f1c9944f |
|
BLAKE2b-256 | 15d3941bf73a0a9a0e5e97fcce6cc042ecb9f28b6de6802209ba1a4ad3f397ea |