Yet another python hook system
Project description
yaphs
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75dd3d48e700f810d7c466e8159fb7673d349f7bb1dec475d722897bc0667f8a
|
|
| MD5 |
11792a262353bc7baa4cfff57376f982
|
|
| BLAKE2b-256 |
1dd0f9fe10d2258c8489bfa8d2e63194d2c5b7603e3e53e68a12d281f8f357bb
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
368ade1feb256958f6dd74847f54e3944f84d53c31bee7bb1aab3ac165f40fc0
|
|
| MD5 |
5c5cb56a2b28c75c4a2f68da0a6948af
|
|
| BLAKE2b-256 |
af00618b20d259ba81b597db8118c8df6a27b1b2e504e814cb769d7aa237a0bd
|