Skip to main content

An arcane-powered python hooking library for sane humans

Project description

I’m a hooker from Silvermoon City. Let me show you the Arcane way to Python

NOTE: Use me, use me haaaard…


This is my attempt to reinvent the hooking wheel. I try to keep it simple for both providers and consumers.

The whole idea is that there are events, created by either the guts of the app or an plugin itself on runtime. After that, the required plugins that actually implemnt hooks on the events should be imported. Example:

main.py

import hooker
hooker.EVENTS.append(["on_start", "with_open"])

import foo
import test
import anothertest

foo.py

@hook("on_start")
def bar():
    print("I'll be called when crawler starts!")

test.py

@hook("on_start", "foo")
def foo():
    print("I'll be called when crawler starts, but after `foo` hooks!")

anothertest.py

@hook("with_open", "test")
def foo(path, fd):
    print("This will not work! Dependencies are per-event!")
    print("`test` module should have a 'with_open' hook as well!")

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

hooker-0.2.1.tar.gz (3.2 kB view hashes)

Uploaded Source

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