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. Test environments available:
pep8 py27 py34 py35 py36 pypy pypy3 pylint pep257
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-0.5.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68b02c42b45dbe4e99eaa54f8fd914ebbee6500db44b5834f0a22362594f2c91 |
|
MD5 | ba8bcf5dd68f01e9706e4f0a29606c78 |
|
BLAKE2b-256 | 52ab1a583b7ba14666fb73c47063d12b0ed1472af9daac763e8ffa7df2f4673d |
Hashes for Advanced_Descriptors-0.5.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d6ddb16d7f0bac827da4fe1db9f473601a8e27d678d2ff0a29c457573ec183 |
|
MD5 | c885f76dd6f41d709ae02b3b00007859 |
|
BLAKE2b-256 | 3cd8bbece7b938c64ea08058bd7339750bad95aceb35a693ed828b9cdb6c0480 |
Hashes for Advanced_Descriptors-0.5.2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f308dfc54694ad4dabb5dc7879421df2f90ec4e9924d874f4238cd00ec098def |
|
MD5 | 9b632d246b31d5fc4aee696a0301a8a1 |
|
BLAKE2b-256 | 7d70cb964b7cd92bebddd2be833be7b8b170464e9c9e97031d526d9db298bd33 |
Hashes for Advanced_Descriptors-0.5.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb69d896c71328a20c769546bc634a03a652e21053537260d33b985583b48ab4 |
|
MD5 | 7edf7f2c7559c1f2502ed42467c1121f |
|
BLAKE2b-256 | 8c8ece9ea1a9866306dd70dbd173551f7e92dd5e923f51113224fe14e302ab37 |
Hashes for Advanced_Descriptors-0.5.2-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80fe12041c92e00cea09cffa998cd5d5000c15d70a4811cbba2e913e4f5c6586 |
|
MD5 | 494dded71b31644cc66dd7451aa8a97e |
|
BLAKE2b-256 | 542ba88166becedca76d297a2db1693ff1827423756a39672cb0e5d1daed026f |
Hashes for Advanced_Descriptors-0.5.2-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61fdda08e482926ed51c339f7d4c23c87069ac9601d341a0abe7d42f513c28aa |
|
MD5 | fa5399f506fa3ebbb2c74a228bf33290 |
|
BLAKE2b-256 | a7096bca75ade3942d203b93c64b5458779af17bf53c884cfa096e38e35bfa1a |
Hashes for Advanced_Descriptors-0.5.2-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8604b0ccd3c81985b3ae7ddafc381dad5de44173a428ca6b60e3ddb9142eccd7 |
|
MD5 | 09ca01b7669fe1184715d9883f23ae00 |
|
BLAKE2b-256 | f489a4b07befd307ffd7e371977bddf1beb03db635602783346e774a993a4a52 |
Hashes for Advanced_Descriptors-0.5.2-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64e46ed4552f846fde924f52d16e41da85336b1e7d588fd448f5f8babcf53831 |
|
MD5 | a6448cb5fbfd1a78fc479179ed973e12 |
|
BLAKE2b-256 | cecedb19a2599d058b03aef58134a4b60868a0e041d41eecf58f43b949459e1d |
Hashes for Advanced_Descriptors-0.5.2-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac7635dc75f2ac987f908836ba9662475a1ee2ef95b454fc0c761752dc1c5b15 |
|
MD5 | 98c07fd4c128454cd8835c34a1f0f4c9 |
|
BLAKE2b-256 | e9a2186d1f92d104059e43867e048140d4b0e23edf56707ddcd866ddeba5c86b |
Hashes for Advanced_Descriptors-0.5.2-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d97704f412a3bb8b54216f2b7d54983a050c752414af2a8e7e9c13c78c186f41 |
|
MD5 | e265e041c51d614d168556e011bc2567 |
|
BLAKE2b-256 | c51a000854dbbed3f36fdf9ce6df80347ad57bbd4f9e375d8167a23c7b66dcb0 |
Hashes for Advanced_Descriptors-0.5.2-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30d358dee7e31941072487018b128e921395c0e101784bc4319032af9fa13e47 |
|
MD5 | fc721638bc422008db76e15810f6c0d6 |
|
BLAKE2b-256 | 6d811fe004d2913088ba2d194c990415bb14422ffb9cb69985d6c5a17ddd818d |