Advanced 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.
LogOnAccess - property with logging on successful get/set/delete or failure.
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
LogOnAccess
This special case of property is useful in cases, where a lot of properties should be logged by similar way without writing a lot of code.
Basic API is conform with property, but in addition it is possible to customize logger, log levels and log conditions.
Usage examples:
Simple usage. All by default. logger is re-used from instance if available with names logger or log else used internal advanced_descriptors.log_on_access logger:
import logging class Target(object): def init(self, val='ok') self.val = val self.logger = logging.get_logger(self.__class__.__name__) # Single for class, follow subclassing def __repr__(self): return "{cls}(val={self.val})".format(cls=self.__class__.__name__, self=self) @advanced_descriptors.LogOnAccess def ok(self): return self.val @ok.setter def ok(self, val): self.val = val @ok.deleter def ok(self): self.val = ""
Use with global logger for class:
class Target(object): def init(self, val='ok') self.val = val def __repr__(self): return "{cls}(val={self.val})".format(cls=self.__class__.__name__, self=self) @advanced_descriptors.LogOnAccess def ok(self): return self.val @ok.setter def ok(self, val): self.val = val @ok.deleter def ok(self): self.val = "" ok.logger = 'test_logger' ok.log_level = logging.INFO ok.exc_level = logging.ERROR ok.log_object_repr = True # As by default ok.log_success = True # As by default ok.log_failure = True # As by default ok.log_traceback = True # As by default ok.override_name = None # As by default: use original name
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.
Azure CI: is used for functional tests on Windows.
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-3.0.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0e1b76ebe22dedaa341c12b43c309bf0e808d2ce0ee7de382934b3e511b49d6 |
|
MD5 | 4868c6d22cfc9d926c17f2a40f4f64dc |
|
BLAKE2b-256 | bbe50ec213fcaf89bdb82dc30a614a05df6120f85e8ec01d7ccb7e5d3108e816 |
Hashes for advanced_descriptors-3.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cbb31df1b38b30ccb745cd8babf605ac9402040cbc635bb1f6c2565ebb67a51 |
|
MD5 | beba8a4fcfe21a350348e01ae31d5cac |
|
BLAKE2b-256 | adca10dd584dfc783dd9f8b65448a560266a83b001fa3777b780c933ef791084 |
Hashes for advanced_descriptors-3.0.9-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7db102faf12e5e8072ce3f6251ce5a5012a887ad23d44f699208017010b51c5 |
|
MD5 | 8016f1843d2c0599c536607afc144a49 |
|
BLAKE2b-256 | 2bd617f0cf39acdaf44735466ad52f988870edd9545e25c8f01f027a6dcdc5ee |
Hashes for advanced_descriptors-3.0.9-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eefc8f8ebac79bb2aa88e45ee84783a070de0bcb021929e51cb15ac635b8650c |
|
MD5 | ad2388858682d3ed906d775eb491e116 |
|
BLAKE2b-256 | 62ae9b4b6e2fa01edc91419c4fc4a21f314ae15fddba1f626268145e116af330 |
Hashes for advanced_descriptors-3.0.9-cp39-cp39-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5442a62b05b6787debe36af21a111a28c2c9dd2c28f5e46008c5ce49e90f5cfd |
|
MD5 | 374a8a4a5a4c37ac652f8688f9a2fe32 |
|
BLAKE2b-256 | 4f8a8ce871ed7d1f2cc531225d779e2909815053ebb827f821ceee524a1271e6 |
Hashes for advanced_descriptors-3.0.9-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 518ea7452316e65efd319fab809d0ac28af3571007d561f35c6b64f740838fda |
|
MD5 | 8d75b22399223431cdf3d246315866cc |
|
BLAKE2b-256 | 57a38a72fec88d5d4d2d1d67835ac78db5b77cd405381a32251030494cb98e84 |
Hashes for advanced_descriptors-3.0.9-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7927799261962076a16e03807f5055dd8b240adb77ede2edb5bd3687d7b96ad8 |
|
MD5 | 98389a4f8ae41d9ac4f4755c752a2bf5 |
|
BLAKE2b-256 | 905180f60cbdf119603211acb28e74467b63142a7ec6968aa27356d3ae78385d |
Hashes for advanced_descriptors-3.0.9-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88ecc3da0861264fa3685c21aafe4da6466d1268f8a99f78a1ab2619d34bb7de |
|
MD5 | cc07ce7d17343c10d0a2a1720b4fcaec |
|
BLAKE2b-256 | 32157a46c3784ebb588d00934831d4e3da3dee0d2d5e5e00f4659ad83335dff8 |
Hashes for advanced_descriptors-3.0.9-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ab12a3259146cc9d45e525833d803714b81bef7c7fc84c3950d2bdda0fc0e2b |
|
MD5 | a48cb88c12504e1695e88c97dba98583 |
|
BLAKE2b-256 | bc83041194a07e7303b7e06e1baa3a1a3a15a44b545198f582fd77dcd5884c0d |
Hashes for advanced_descriptors-3.0.9-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | add1c11567cf86f757577b05d4019eebb54cb825e4d7eb6db5fca73b964c9cf7 |
|
MD5 | 81d23bbc28365c4648f8e86584fe9b72 |
|
BLAKE2b-256 | d9aa240ebb31da0baff5d2012df8436a18a542aa530e5d17037decfe2a9cc1b7 |
Hashes for advanced_descriptors-3.0.9-cp38-cp38-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a73d5b168e79e1c8cd1068daaddb89e62fd55c119dcf74c93e914611032c6bc |
|
MD5 | e1a24737e45181efd715c9737cbdf77c |
|
BLAKE2b-256 | e963711f66d7694adecef3f5e4d11e7a2a13718f58dd89f6246e3241372c7c2c |
Hashes for advanced_descriptors-3.0.9-cp38-cp38-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb2cda9c56d649dbbc48c1f34ae56bdc29463d068d3c0255a3f39462b1ac4f11 |
|
MD5 | c2e2df268584e826e2ded6a83135bcc0 |
|
BLAKE2b-256 | 7c648550b2277ecbc58d4257bc82d8c789188e39d14f0165be6ee7b8f906bbcf |
Hashes for advanced_descriptors-3.0.9-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdbc1576e547167d9567590ab860e254933284554e919a3d19d6354f35a724ec |
|
MD5 | 889bcd859ef940a7ca5bd400cf8807cf |
|
BLAKE2b-256 | 56d63e1acd5190aac4053d276370ecda6f60776150ff35f66962d1e79a1a6227 |
Hashes for advanced_descriptors-3.0.9-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54c6b461a562a0288419db2e0d90b9747dfd155a9754e25f1372b874e5abe791 |
|
MD5 | cd2ae758467f9e7192a239cc68ba3fff |
|
BLAKE2b-256 | 8deedf328dd86966b159812061a4463fedcef53fba2f958535cfd921790a1e9f |
Hashes for advanced_descriptors-3.0.9-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfb6d302d55a93339dc874b0a6fd9bd60de51d8c2c51cd63225524e252b68bac |
|
MD5 | 51f663ba664ab4984ecb2c8843fdc5b1 |
|
BLAKE2b-256 | ee15ce4f14d13c959e38cf0f96377e6ee568d982ea0cc4a320f8d0b6381852c2 |
Hashes for advanced_descriptors-3.0.9-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e455e1fd0b66ac36fe2fc0d2c1a8a8001be0f8826c69b30679bb1459edf9223 |
|
MD5 | 4b8fdc564c6bd548ad48efafc766dd95 |
|
BLAKE2b-256 | 66b7c62f9a71e5cd27c3431df9f88e5d349ece4af4b4988eed1be1ec8c847a3e |
Hashes for advanced_descriptors-3.0.9-cp37-cp37m-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcb7b191578f3a00b063853c3b563215b6a9a137dacc65554a3765443d3b87e8 |
|
MD5 | f454a61d88fa379acbd6f8769f9e2e7d |
|
BLAKE2b-256 | acffa017781138285eeb154a5944b3df979122c100846d562302c6b4d7d011c6 |
Hashes for advanced_descriptors-3.0.9-cp37-cp37m-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb9863e68d8e532167977999b93e64e07a7407d2f2d8dd8d3fe06bc427a6321b |
|
MD5 | d88999e150c563821ce500296d0c2b54 |
|
BLAKE2b-256 | dc831daee52414101668975c31b4b1536fb1359841a18f703c0ceab54211cae8 |
Hashes for advanced_descriptors-3.0.9-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 051fae2be2edc3c6d54c39d25695dfe736a9d6fa0dd1f72cdf6d5cb5ea8bb363 |
|
MD5 | e9aedf0bf0ebc0ba637147815cb9a346 |
|
BLAKE2b-256 | 42559114a71269fa82806c7662e8d587a6da098ef7bb815231ef5f914be92435 |
Hashes for advanced_descriptors-3.0.9-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 938259b7363d9a88b198b9042937512c353e2de789ffac50e154ad1ade6d25a7 |
|
MD5 | 90852af11b6270d5685f58abcc497de6 |
|
BLAKE2b-256 | 889b77a8cec1e21cce4dda245f8bbd5062902ff5a6d743a8e5b6021c692ac993 |
Hashes for advanced_descriptors-3.0.9-cp36-cp36m-manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccb65aba35796b4472b5ef4e928cb6243b5732844b0b630d8d26a9414ef3e021 |
|
MD5 | 0e90ddacd622164088d4e2e52397a6fa |
|
BLAKE2b-256 | fd0e62eeb692242727d33d259f6cf78be6c792073bae7535b80b64e839dafcdf |
Hashes for advanced_descriptors-3.0.9-cp36-cp36m-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d41ab58bb008095d520ca78f41b82c9ec94b7b8baa536713bd2438332edd0812 |
|
MD5 | 9910a7815d653b03c512212f259c8f76 |
|
BLAKE2b-256 | 43954c37f9773ba21a3cdb18b26f98453bfce77edefd4c74d052b1b17c533624 |
Hashes for advanced_descriptors-3.0.9-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b19f7afce9cffcea0fc9b6b48536c36ea95af3552c562de556d04adc52ea8626 |
|
MD5 | 6a64abd1a360299c98613b6cd1e3d256 |
|
BLAKE2b-256 | 5f41fdaeee4e8a3f0524b69ead29e6e5419ae3540831c70e42ca70448f02ae22 |
Hashes for advanced_descriptors-3.0.9-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 902e308feb1d0719c97f49cc103bc2725043f91a36c42bf616208d21850c2417 |
|
MD5 | e7529ab921c450321484d9ecc25f862a |
|
BLAKE2b-256 | 9232facb3882fc0a57fd767d0c0617fcc8cfce9cafced12b79e080edeacfb505 |