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/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
  2. 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.

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

Uploaded Source

Built Distributions

File details

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

File metadata

File hashes

Hashes for Advanced-Descriptors-0.5.0.tar.gz
Algorithm Hash digest
SHA256 0c02b9be17a2e522e86dfca36fa926190400ff1f4450e1c3cf7f5b4be8297248
MD5 948f24d09b23779a0f8f15b52828cafd
BLAKE2b-256 b831efa89ed1394e32a0cb2c07abd32712c9571866e952e2ce56073ed155753d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 494ef3489793624944c69329e56723e601805642f230b3d2bd45141397040cf9
MD5 304a5ef123710c69236afb81d23ca96a
BLAKE2b-256 7e0a2cf0b86b99be5231472ab544d5d32bcd5343f162b018ae36d3b12c484d60

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 7a360d50f6ca610ea813e97c2ea6e1f55b269c6443b60ae012b0df7a6877c929
MD5 505d6fd4c8c5f3abad9969b3b56cf466
BLAKE2b-256 c6408a92cc5ef662f5c5378f9e0d398b1136e80b7c2c37ce0cce5fbe3ce7e68c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2b2915b760b3dcc555ea08fa94548629365d71be383b89f238e5c2625b1dc316
MD5 19f4e04122c55024661914875dc21b39
BLAKE2b-256 3de870c3644d6661dba0d24d0b73bf3e51faee3489f9e3adf48272d2addb7e94

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 696a9f5df49dc8d22d24a5816b4931d54fcb99768d2afd27f4186bb6189833a0
MD5 b9ec6f750d01ae7ac440c4a1660d5f65
BLAKE2b-256 36c8d8c8df12ba034ba41407c7d36ab16818dd4aacca8b04c8544473bef55d97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3f45c48a1dd90eb34e9c5949928490aafaab7e3d4ace57359a6c8901db532d00
MD5 071f6e31878766f46d5b87ac91bcd125
BLAKE2b-256 27e03ad58f13ef872393f9445ff75d0e6e081e46ddc96e95697b31758fec923a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 97fda0aa4811349b2b29a4b45e532023caa1c589acb3c9d3866b355216377833
MD5 74282c4bf7bf21b73d5901fc73037911
BLAKE2b-256 5aa101ef99932d72a057ce6d9e3839ce9a0d40d2f1be60576ec9b231227df3ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b34a8345276854624035d7a98c6dd36befefd060fc892a948088a8b696a10c47
MD5 fdd46d19a7b77bf65630a41673b64946
BLAKE2b-256 ff24cb900ef73ed68832bdac4bba77b40bda5c9a7589a170834907a02381e0f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 72b2deb09babdd05b92efdb4d5b1f26e59a45fe9fe20c87cacc9be1e0068ba6a
MD5 0714867ba5631c76997824a7630d95b1
BLAKE2b-256 0b4d0e9ff61e476ea5d0d91d92bf0cb224de88379dff556cfef3a7d60bde1744

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 db81f67bf4c4ba1d1b0ddf63263e0218ed102f470cb98fc76806fd090cd96f7b
MD5 a3f25fc4c9ec72e90986ad2c93b775be
BLAKE2b-256 3175b3f5ceefe95d068d9de16423a72b5161e035e761691aa350e8dc195e07da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-0.5.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8fdb8f91eb8f8be331b14dec38730ab0fb4a238780a06cf4d7f1c2c05a5f29ad
MD5 9a594c3a24ee1c587a4a4e4e8a2ae51c
BLAKE2b-256 c9180e63158791a9eab6340b03e4aef99aed39a3f1e74d14c40257bc138ca9ba

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