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

Uploaded Source

Built Distributions

Advanced_Descriptors-1.0.5-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: Advanced-Descriptors-1.0.5.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 PyPy/5.10.1

File hashes

Hashes for Advanced-Descriptors-1.0.5.tar.gz
Algorithm Hash digest
SHA256 a69d12287e3d42282ad683b87a38cf0b21d137caea9f1c048f084fb4284a1154
MD5 740d87d6abdc0fe0a1bef21f07f9b76d
BLAKE2b-256 218291daec816c1e8614c4005f1367fc6e9865b0011aa50a6130bee1732971c0

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: Advanced_Descriptors-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 PyPy/5.10.1

File hashes

Hashes for Advanced_Descriptors-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d0900c5631ee46084d2edfbabbf7db034c54a81376274ce2aa0e20dc45c085e0
MD5 aad8c09bfcda314983015de126d00e7f
BLAKE2b-256 c4e4941a465d7884824baef61c803c25ec5f7a19ac4aebae2cc4151c9d6ca543

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.5-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 553ea82cdc921c5b0151766700f05168ce077a1eec7f0e8f43a03dbeb65bd4a4
MD5 106d9ffe3650554d3eef13b408cc2df1
BLAKE2b-256 c685f5593bc2b16c1a612b683a5fb9599dfd2fe46280c2d1e5fdc0034eb4b1aa

See more details on using hashes here.

File details

Details for the file Advanced_Descriptors-1.0.5-cp37-cp37m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.5-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 f08057f811f5323a499f617de27a046b1cc60c469fcd970f10d2e9a0d735709d
MD5 ca487b91c1ad508fdd9573f627cd2055
BLAKE2b-256 5ff5651252b967e251e1b76b69b350c5b0694479c84b5b900d00e7957ff3d624

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ec72fe0fcaddee1caf4b65c8fb8197185888c2007a5661cb77d6c03137ec802e
MD5 075e2f233bf98185f3de33c104026fa5
BLAKE2b-256 1a0c5cb06ae8b43ee903757631e428010d8473fafb8434927f89113dbbaa07dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.5-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 914808b7a15e42c450a3b0bb5b4fe7ac6670b4ce7a42ee083df2a0f9c89aa349
MD5 0c527d20f10cba40a6cc6cf663c4fcb3
BLAKE2b-256 b841df2f50370c2424f84739fb0148dc955875b5e20543058e81ad29e638407b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.5-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5711d336d685826f58726a0b71202e52959640fe6b779e95b643c43364a45202
MD5 36930eff7c95d37f521e5b7bcc2a2ffa
BLAKE2b-256 0acee4cfc31a189b8ee043e9136e08d9e00c2108d2cfa46d0af6ad717b8bc287

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.5-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 3e1609db6c17f62489b93d37299b91ead1c4c88149ca3a5b48a470966c20cc5b
MD5 4c46d1d847b67e38c20279aeb7260bcb
BLAKE2b-256 74a6db4d70ecb98d16a1653abdc4d77da0c720dad72bab0c0dd95c8bc41b6ce2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.5-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 864eb2e8514c8765b30ef35ce874d034eedb67a72bca054806999d35720ae68a
MD5 552afb98a31523459627d128f0896ed3
BLAKE2b-256 46bc87d3b386c55125f37196aeedade5e99ac9f42fa27891c0fdf5061f96a378

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.5-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 c36fcf6d6b3baabb6f1e921849e77a0ea1e6881e5534bc19711ff2b0db25cbeb
MD5 1707539954713956d9fdc6089f2fa6fd
BLAKE2b-256 b3da25656deac9c1804a53c912a6fa3f525b32d0a313dbff0e65ac119aa9d07b

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