Skip to main content

Advanced 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 https://img.shields.io/badge/code%20style-black-000000.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.6.tar.gz (13.4 kB view details)

Uploaded Source

Built Distributions

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: Advanced-Descriptors-1.0.6.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.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 PyPy/5.10.1

File hashes

Hashes for Advanced-Descriptors-1.0.6.tar.gz
Algorithm Hash digest
SHA256 aa1918d45427a7da817d7b41737a3ad0c63dd0039dfffe712a214a5c27c19c54
MD5 7b31542bb8a791bcc2171b7f643ca1ad
BLAKE2b-256 d0fd779d8611a58a8d833d83c1921b03c6514e47a4a87654087bf5a5cb821807

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Advanced_Descriptors-1.0.6-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.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 PyPy/5.10.1

File hashes

Hashes for Advanced_Descriptors-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bb78b547eb8f517d6e4d30ea07a319cf9d156744f6c34cec4aab7d5a918bb16a
MD5 33e35a06e908ad6fa7a3e62642d4abef
BLAKE2b-256 c5a6d495fce94eccbf2b951764107824f376ad4b05bc35a59030c2325d395b49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cf865d8ea253d47a21f39696796c780adfa3a1bf622f0e9c2ca5b21fca7bf222
MD5 10810d8770b8bebc837871d7d6bdd10c
BLAKE2b-256 0c480f1fb506d303e7db7942688ad06725eb63e9bfbf1ac9283cab15011d69bd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Advanced_Descriptors-1.0.6-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 191.9 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for Advanced_Descriptors-1.0.6-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 167ae1a098f897a0e0b7b281a599aeaf0a0e49e41ba8d31a915c23e5c3252bb9
MD5 06ff90e1bc08bc427ca366aa2c98d316
BLAKE2b-256 13b616f6111edfdadb36f376a1d85ec336e08de7232274f206e93ee99644e687

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.6-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2e3af6086ab3b0be60c61376059d771cdffa82235573f5c41ebb50e7858e219d
MD5 7765f38949ab6dc30be193b5207ea70b
BLAKE2b-256 5af4864b58e45ab3e8e5d9b4fb251e9b3b5a5b2f536e7274dbfc2d9c46a520e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Advanced_Descriptors-1.0.6-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 189.0 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for Advanced_Descriptors-1.0.6-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 610ba912be556267739512570f5a0e4cda3cdaa31b9b663c0ef589c2954101f8
MD5 9b78e9486f6b8dd2f357aff9eee5c97f
BLAKE2b-256 894ef92b55bbd231ecac3bf869fc37c149e185bfab301d7f519f8b3628f74e77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.6-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d365cd3ee7a16775efa38a94e64feaf4136d00b649942374ca72a656e938ccc3
MD5 cca5ab50503f46a0b86ce06a30368f8f
BLAKE2b-256 64e2dab6e709fd866ae8b1ef34126b732469a81bd3b667ac64c6d30edecc78f8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Advanced_Descriptors-1.0.6-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 184.6 kB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for Advanced_Descriptors-1.0.6-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 0acdc591155eac52f2d213240d4f48d0749a24c6d816ded5cd8764a1c24f78c8
MD5 098c82f461b734da025ca0c0698758bf
BLAKE2b-256 f5122a588b95c3373cbfdde5a72433eb537dd6731e2c1bbe8323a07048af1268

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for Advanced_Descriptors-1.0.6-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7556023203a145c17e2490eafe8544dba9742686ddffce8b132c1f4388314879
MD5 6281f9b4ae3406840a05200ff7878871
BLAKE2b-256 c6d46ce11be9b6a6a270606bb299bfd3f4ff62509c5c7eeff56ca208566f06ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: Advanced_Descriptors-1.0.6-cp34-cp34m-manylinux1_i686.whl
  • Upload date:
  • Size: 187.1 kB
  • Tags: CPython 3.4m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.6

File hashes

Hashes for Advanced_Descriptors-1.0.6-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 58ba8e0d584c23ee8c90233af6cd90844ea4828615e7dbed548e8ed33de0a602
MD5 26af5bd96e742cd48c85f4b4e2b59571
BLAKE2b-256 cae5f6ada66e4e94cc4ed9654d8f3e7ed95c1dab1e76d23649c6a587389d9ea1

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