Skip to main content

Advanded descriptors for special cases.

Project description

Advanced descriptors

https://travis-ci.org/penguinolog/advanced-descriptors.svg?branch=master https://coveralls.io/repos/github/penguinolog/advanced-descriptors/badge.svg?branch=master 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/penguinolog/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. Test environments available:

pep8
py27
py34
py35
py36
pypy
pypy3
pylint
pep257

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-0.5.4.tar.gz (105.6 kB view details)

Uploaded Source

Built Distributions

File details

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

File metadata

File hashes

Hashes for Advanced-Descriptors-0.5.4.tar.gz
Algorithm Hash digest
SHA256 e87ef6ba42f5061afb45f5cdb5a13a0bea3b3cbe495385c318d146ef0e962c57
MD5 67090b9dd1ac45ad931430acdeab6cb0
BLAKE2b-256 90be2b9b638a0561414bcabd7e8edb877ca797e8e123a50b65e9f56c4d9b2b20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 100f0fc54327530019383c0ba86ad07c1ab364dabef1d5ac78d2ad99e8498791
MD5 28c87a9cd3365fc88a3573898fe23fd3
BLAKE2b-256 af04b5aa0b685aa6d0e0c676ebc94da6ea0c87db6ef97568e9517c3a74c37a42

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 16721661457529008819334c883fe139ceee4786005747c016d180aef3ad8028
MD5 64b508abdded8f1c6df870a05cce8652
BLAKE2b-256 8ccd5bc937fe9fee09e5e195a9857c741a79f33f7de489e7bd341c50f56812f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 83f5c52f58342d1bb1e0edcaea6fc8de2f77e9408bb40ae7b88174672299ebfb
MD5 feca6dfe8500997a868449beca06e74a
BLAKE2b-256 fadbf41ce9a7568f4b954393533251756aaed6ca90b7cd94e0fd2b172d094b1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8da283ccd402959da3a23135774af35d23c00edf0519ff48f3b3dd29d55546dc
MD5 921b534891973389b3dc6fab4bff2032
BLAKE2b-256 cbca90b5c3b2c12c3bb02c20e8a2a5a5e4e889d22dacedd498913c7c6847b997

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 810d64454d68881e3a5f17652033374b813f149d216e22eca6633ee713f90c52
MD5 2af515e8a60584661dff2713009a57ed
BLAKE2b-256 777159c6b10e9eab6a2cc98fe9a51666a216bb517dae3bd9a3961c5bbfb3a2cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ef0ec2ab1558b9d9a1983a2fe071fc017391d4899604498fb19ebd14b3c9f0fd
MD5 9a3c8d9bb73409cca5d4e5a59301512e
BLAKE2b-256 7d4b1620aa86911a46fd7d0ed1de428ed291f987bd97b322920cbef888912c1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3d016dcb74ef44ff075be296e6db28845db256f92ba6d81ed07cd7331b03ae2d
MD5 b942c54a63f47ddd4be52cb0b587fc8f
BLAKE2b-256 565184ff82076cb5dbb05a3f28d9c0e92386d6d4dcd0dbfe00bcd5db20da9bff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 1a0a226dcc61bbbc902c505dace0fd2bf2524bfac0a8a565c4200f68c97f7c1f
MD5 eb4d6cba9936b75926e4c152a720624e
BLAKE2b-256 10e6552f00cceee2fd3bf9f6e319ccf5b21b9c9feff13e8862565c86eab9f43d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9d793823e7da9b70f31f665749a4346b496dcee14766c6d982acbf5d70b1a9f5
MD5 bff374d552007b3d6173dbc9b42c8e16
BLAKE2b-256 4a0e8f3db59242ac69b5fb305ed401bc986656557073ad482e1e28d5d2a8e114

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.4-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8ee9605aa46f5bc5b4047b06a8b3f1cea7921a53c6af2e1a5bdd19ff9e113ad4
MD5 b4530f657284b8324417f72de809a92b
BLAKE2b-256 66fb6bf7423f297473f993215d23a55e5e2784c970bab732cb405a3d5f830461

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