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.6.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a855c438e0903f628b7e5714aa7296bc1650f48c06e66bffb43d9109392e2f1e |
|
MD5 | ca1ff244cb7a263ed08a6768cc08c076 |
|
BLAKE2b-256 | e4906003dc88d4cadacd47d0bf3d7c8a4afdc1c7257cc3d2e1e7c4ae2b75f1cc |
Hashes for Advanced_Descriptors-0.6.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1c080654d316b60cd4ae39e9232f0f3cbdd5ffd70e7ff73a473fb66c65f5c76 |
|
MD5 | 7089533b2225cb0f0461306b3828eefc |
|
BLAKE2b-256 | eef0944c070d5af187ce23ca1583f7019f039cdcdddb3a2aac5896d4676e2f01 |
Hashes for Advanced_Descriptors-0.6.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d064ba98b5f24221cac3efd8d3ef20478aa414090b6660d8324ccb7d64df390 |
|
MD5 | 5fdf74bd35fd30427a3ba448ee84be39 |
|
BLAKE2b-256 | b26d1d61495ae230473a48e8e7fe8623d32669a66b81bab18921a89baecb736a |
Hashes for Advanced_Descriptors-0.6.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33b82889d8c6f866bc857e363a034373c331f156b8fda6a61a0eb93c0103d8ca |
|
MD5 | 39eed0d07e76401660e7049c4a01750a |
|
BLAKE2b-256 | cc9e7fe983e63213fbd8d45d2300f1af20abc92835bb3e17c83806a0bbbb42e5 |
Hashes for Advanced_Descriptors-0.6.0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c08aa750d553728c097515268a859ae683bbd8445386eb5364bd70345124f28b |
|
MD5 | 37895da7cb4c21d81114a2cece15b031 |
|
BLAKE2b-256 | d101fe8f48db937b589011c25741cda31d7828e8db46eaf0c88e4749b7758516 |
Hashes for Advanced_Descriptors-0.6.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f94729f01d8b9370e0ee7d39eca1e1fc3cab12daee68cf1b555e52dc125e688f |
|
MD5 | 3484efbd68d61526c2afbf6953b1b1f4 |
|
BLAKE2b-256 | 466f1f6ee8ecccd2bca3c2d46f2ee5c72c929e602179f2034f97a5144dc3ab33 |
Hashes for Advanced_Descriptors-0.6.0-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15b505ebbe8e7719587f89c4bdb7b616ba72f1d54b9a325ad486e4ed14f8b407 |
|
MD5 | 794df40cbd36a4de0dcf6d73d9bf5d94 |
|
BLAKE2b-256 | e3475a8bb052546082f14c5550fb9e95982edf7b6ffc22328bc32c18ddafa11d |
Hashes for Advanced_Descriptors-0.6.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99409dece0653f490831370d01c6270d03d160ae0b55add379d4db65a4224d3d |
|
MD5 | dae64565c489adf2cea53c901fbc3ef3 |
|
BLAKE2b-256 | f9081bbd35f3b8bfb80b0d6d8fbcca4e884b1ffaae586e0ae1e39c7a65fdb4ac |
Hashes for Advanced_Descriptors-0.6.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c54591ef2e5c72eb45f449206bc9928476143004b064704c6e35c5644083144f |
|
MD5 | 059b2a4f1492b45b6bbbefcf403afacc |
|
BLAKE2b-256 | 3fda54369d942164ec3bd62a0cf8c1e1d8681e88b7739cb250c69aab40a82a49 |
Hashes for Advanced_Descriptors-0.6.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeffeef35a0cd2454cb8bd109cfe7ca1033a9c35a55f0a2e3853f31131f259bd |
|
MD5 | a13d7bdca413649741d2b29b5a6eba97 |
|
BLAKE2b-256 | 0798a4acd6dcb0204d0dd8510796b71b85bae8898225330e616162b960fbbfe2 |
Hashes for Advanced_Descriptors-0.6.0-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dea7a3dd96f8d4bb0496ffba557e02cad8b6e631be2b24e47562e267932339ba |
|
MD5 | 4777bb66ba8b2c97b219b84c453cac91 |
|
BLAKE2b-256 | b1647a823a53adec21a5ce56c5bffa3475f7feb63b9589c1f5e2c9e7a6c86983 |