Skip to main content

Easily strip decorator from function or class method

Project description

strip-deco

license pypi pyversions badge Downloads


strip-deco easily strip decorator from function or class method

Installation

pip3 install strip-deco

Example of function decorator

from strip_deco import stripdeco


def deco(func):
    def _deco(*args, **kwargs):
        result = func(*args, **kwargs)
        return result
    return _deco
    
@deco
def test():
    pass
    

original_func = stripdeco(obj=test)

@deco
@deco
@deco
def test():
    pass
    
original_func = stripdeco(obj=test, depth=2)  # It will only strip two decorator

Example of Class decorator

from strip_deco import stripdeco


class Deco:
    def __call__(self, func):
        def deco(*args, **kwargs):
            return func(*args, **kwargs)
        return deco
        
@Deco()
def test():
    pass
    
    
original_func = stripdeco(obj=test)

@Deco()
@Deco()
@Deco()
def test():
    pass
original_func = stripdeco(obj=test, depth=2)  # It will only strip two decorator

Example of class method

from strip_deco import stripdeco


def deco(func):
    def _deco(*args, **kwargs):
        result = func(*args, **kwargs)
        return result
    return _deco


class Service:
    @deco
    def run(self):
        pass
        
        
original_func = stripdeco(obj=Service().run)
original_func(Service)  # Must add class through argument

Note

  • strip-deco automatically removes any kind of decorators. (class/function)
  • It supports both decorator,functools wraps and non functools wraps .
  • If you specify depth paramater, it will strip order by outside.
  • The class argument is required when executing class method.

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

strip-deco-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file strip-deco-0.0.1.tar.gz.

File metadata

  • Download URL: strip-deco-0.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for strip-deco-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ff425a82be18347bdccad895bec3b17ba4147f03088285bc059bb7a6f3c4c83b
MD5 ead675e8e64c2f3f70b65461d6941553
BLAKE2b-256 83cdf8c15ffe3f04aa4dec142596a3a4c0c20d05b37397b12e15a90ae4da7b3b

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