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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 764eef5062e48b130bcfd110cf16efa3e495f5c6c5904c101379c41a8548e083 |
|
MD5 | baf930324fbd9bc3e31e70ef09ee94a4 |
|
BLAKE2b-256 | fa596f3cffec0c78e21990b89e2b7b02f543204a684afb846c937f5094ac6938 |
Hashes for Advanced_Descriptors-1.0.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 720dab9bff814504699588b2264355397e10f1784b1ca4be788bf2d64257d677 |
|
MD5 | 74d57ecbb165091a1e0a01a7042038d0 |
|
BLAKE2b-256 | eee65ca600426cb2d0828e9a0a167acffbc2024bfcd8c52829b04ab0a337bf4d |
Hashes for Advanced_Descriptors-1.0.3-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3728ca61bf01899589036c1c36805dd6832b323ce3f0d6e267d54b85e0678d0 |
|
MD5 | 295bacc74a4c4ca3c6cd006356903803 |
|
BLAKE2b-256 | f9e59976ff8d800501bc07366a883a87d10b71fa9519329f1f6eec4e415a9728 |
Hashes for Advanced_Descriptors-1.0.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6c18812f62ffa00be4f48c13312374b9393a5c7c12c14cfa1c2c050c54885fa |
|
MD5 | e09fad4aa0dba8a8fb0ece7cf776c7b3 |
|
BLAKE2b-256 | 3552e23ee2e5398be54deeafcb3495a1487151e8c89d3f60d4a9164660326565 |
Hashes for Advanced_Descriptors-1.0.3-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d284ad9e187aab6873c06eb76f9b1c87071bc264e5498099674edba4448c8de |
|
MD5 | ae17c781e0a2dbc9dbb7cc76173ab347 |
|
BLAKE2b-256 | e73f6fd542b0df53bf1409e77c62f7625a50029061290dcf6131504310f4a6c3 |
Hashes for Advanced_Descriptors-1.0.3-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aab4e14a929bfbde2f7923b64ba3cc66f879c437ae6e8e490407c28f2025cb1 |
|
MD5 | 0417e4496db3054114dca1125df4335e |
|
BLAKE2b-256 | 9bada95c3b5e9c8dada05154f82147bcefcca678edbeab54ccac844fe563be55 |
Hashes for Advanced_Descriptors-1.0.3-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f9b6f9e8201f9a9672bd275e42c88cde5e58abd9def5cc91afa7dc4e8eac731 |
|
MD5 | f4df177af8cb7677e50f2e3a084d0d96 |
|
BLAKE2b-256 | 7c191ba1fbacc3d704d39a7c5a5846c4d4a6433163e9c527231f12947685c2f5 |
Hashes for Advanced_Descriptors-1.0.3-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3977b7649f81125174681f8a238c2201724db796abb17c745de20c4ec1cf4f4 |
|
MD5 | 83cbdea90b36cb9b1add6a5ff4d302bc |
|
BLAKE2b-256 | ccd45fec7df2e139d3dff3ec185a287f30ba575f49f1a7bc537b6315084b29ff |
Hashes for Advanced_Descriptors-1.0.3-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f58701f4153b301283b5b99eeabd89821da265f65cade47580fb16ea9fe7a4f |
|
MD5 | 380eeade9b820e4bb68dd919184a9885 |
|
BLAKE2b-256 | e5b2be4c2c99adee8c0b5a109913199ad763ff2a87f73d5160409fef8796cece |
Hashes for Advanced_Descriptors-1.0.3-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d893cc5e8895d24b565026c7a1d3186416d06cb82c11355239283b87f1346e2 |
|
MD5 | 3b0a3746bbb48d545226e551a8065456 |
|
BLAKE2b-256 | e15819922e080d4c2213584d44c6ba5718b9a6cc4bde4d0949c3cb7dbaa51b61 |
Hashes for Advanced_Descriptors-1.0.3-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75ae53debd557e082fc8b0665ce8bb93c79d3c75a2b46716a3451de40f996b40 |
|
MD5 | b15e14fb6d5ff2dd2969eadeef4f4b11 |
|
BLAKE2b-256 | 3efe0ab6a71082f625fcf1d3aab895d58376c6e7b46889825e892f7eddb89305 |