Skip to main content

Advanded descriptors for special cases.

Project description

Advanced descriptors

https://travis-ci.org/python-useful-helpers/advanced-descriptors.svg?branch=master https://coveralls.io/repos/github/python-useful-helpers/advanced-descriptors/badge.svg?branch=master Documentation Status https://img.shields.io/pypi/v/advanced-descriptors.svg https://img.shields.io/pypi/pyversions/advanced-descriptors.svg https://img.shields.io/pypi/status/advanced-descriptors.svg https://img.shields.io/github/license/python-useful-helpers/advanced-descriptors.svg

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:

  1. 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
  1. 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:

  1. Travis CI: is used for checking: PEP8, pylint, bandit, installation possibility and unit tests. Also it’s publishes coverage on coveralls.

  2. coveralls: is used for coverage display.

CD system

Travis CI: is used for package delivery on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Advanced-Descriptors-1.0.2.tar.gz (108.9 kB view details)

Uploaded Source

Built Distributions

Advanced_Descriptors-1.0.2-cp27-cp27mu-manylinux1_i686.whl (182.1 kB view details)

Uploaded CPython 2.7mu

File details

Details for the file Advanced-Descriptors-1.0.2.tar.gz.

File metadata

File hashes

Hashes for Advanced-Descriptors-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3f49847da743ef58b99eabb31f525477c6c89096d59455f65af4414d7405f860
MD5 4c0edf32e8d5f93aea56e406aa2f9a61
BLAKE2b-256 83fb077ce6bb33904cc204a3f57375a2f849e401440df0c31bb5b13065443a65

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 e368e5e6c52a5b21bb8f266d77e93ffdcec79b6e3c5baa35fcb66de0280fd993
MD5 7518df784d7836b1a3a9a8a6c46d5616
BLAKE2b-256 c4a1dbf32934291aa79b9da1f0459f3dfe5535a818df6848823a1d1fe1c3419b

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8fedf0b1032097d2508859f1e3189520875a79d068b6397f1895ace6929f9509
MD5 ee149b5814e32f165972f2ee01650d7b
BLAKE2b-256 4514f9468cb6392c23845b036b019309d32501e2f3393af55a2ace849dc727ad

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 957c9a0ace5490b808a3213731f6f36cde74f9b35dc133907d78da152c14756c
MD5 bdb070c92b265b49250ba61f7ad3ce1f
BLAKE2b-256 d800ee2d570450dc89879730c16e833b8aa342ede4d7fb23f17c5e78767c9b4a

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 fd2c1f73cf938904649417d29f063071286691f56bfdec1d0fd5a9a3b31d1674
MD5 3bc19f25fb476c228aec94e9f157f369
BLAKE2b-256 41def6793ce09e4c8fbe5ed785a3f3a9e51b40da6ae988cfdaf9762da6f75746

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ed028c1f63765d0103f83087828a8855bd27f675b4353b9db6f0ef9e521e1e5d
MD5 68bc879748066c6a3754150f7707dfa9
BLAKE2b-256 3571e1e0177fafef87b16f3ef404acad1365919b073b854ce44b4b89f3c92a86

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 5aa8dc0c0bf77b0d5c179d7021a28c3a6f08196a5329fbb6733f2280c3b696f9
MD5 dc0728b69a81bf59a4727622ac1042ff
BLAKE2b-256 23f4070045bc36ebac52f9a47a497217d1c30e37112467fe190d8b50f98163b3

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cb3b82242a63822be57d023414837f0de0bd9676f8702705d8a7fa371ad7792b
MD5 671b59133e64eb63c625e754c149c299
BLAKE2b-256 42033be0cd13d847b4ca2a0098b059465e25e2350258f5c0658f375c2a9acdec

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp27-cp27mu-manylinux1_i686.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d0cb74596105a34414ccba71b78989c1afeef0a399b766279e6e3e1c8fda613b
MD5 f75e49537b38e86e57f4e51fecf0cf62
BLAKE2b-256 138d5fcbe9da36bc3d515e48ad319b48b4225af85c8a190ccbcf1814d47522fa

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bab18de853df7c93aab704b6a833cba4b58284d5074090e68e135e9ff367af6a
MD5 888c2c8652c829854826599d494c93a5
BLAKE2b-256 a28954b2c8de30f64c93d73173e5d691085553e98064099fb0aaf1b72375468c

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.2-cp27-cp27m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.2-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 008d7c81d978f56dec01e9c700272aa9d4a20c5e4fa6f20dc3846b1e16649e94
MD5 8f2c1e7b8a30befb3b5990ca31d22d9b
BLAKE2b-256 7139e9f3ac4b81dcaeefe5f82ff3a386ccf380603a63dc09d0038294f7757223

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page