Skip to main content

Yet another python hook system

Project description

yaphs

pipeline status coverage report

Yet another python hook system for python 2.7/3.x

Usage

Basic usage

Import yaphs

from yaphs import Hook

Register foo as a hook-compatible function

@Hook
def foo(*args):
    print(args)

Register bar as a hook to be executed before calling foo

@foo.before(*args):
def bar(*args):
    print('before foo, args: ' + str(args))

When you call foo, bar is called before

foo(1, 2)

Expected output:

before foo, args: (1, 2)
(1, 2)

Class usage (python 3.x only)

You can use yaphs hooks inside classes:

class MyClass:
    @Hook
    def foo(self, *args)

When you register hooks, you just have to know that the first argument will be the object

c = MyClass()

@c.foo.after:
def bar(o, *args):
    print('after foo')
    print('object: ' + str(o))
    print('args: ' + str(args))

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yaphs-1.0.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yaphs-1.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file yaphs-1.0.tar.gz.

File metadata

  • Download URL: yaphs-1.0.tar.gz
  • Upload date:
  • Size: 1.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for yaphs-1.0.tar.gz
Algorithm Hash digest
SHA256 75dd3d48e700f810d7c466e8159fb7673d349f7bb1dec475d722897bc0667f8a
MD5 11792a262353bc7baa4cfff57376f982
BLAKE2b-256 1dd0f9fe10d2258c8489bfa8d2e63194d2c5b7603e3e53e68a12d281f8f357bb

See more details on using hashes here.

File details

Details for the file yaphs-1.0-py3-none-any.whl.

File metadata

  • Download URL: yaphs-1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for yaphs-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 368ade1feb256958f6dd74847f54e3944f84d53c31bee7bb1aab3ac165f40fc0
MD5 5c5cb56a2b28c75c4a2f68da0a6948af
BLAKE2b-256 af00618b20d259ba81b597db8118c8df6a27b1b2e504e814cb769d7aa237a0bd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page