Giter Site home page Giter Site logo

khag7 / hookability Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 8 KB

makes a python application extensible -- this module adds an action and filter hook api to be used by drop-in plugins -- similar to WordPress plugin API

License: MIT License

Python 100.00%

hookability's Introduction

EXPLANATION OF SHORTHAND VARIABLES USED

# n = name of filter or action
# f = filtering function to execute
# p = priority of execution of functions
# o = original function passed when using decorator
# h = hooks dictionary (all filter/action hooks to be executed)
# a = arguments to pass to function
# k = kw arguments to pass to function
# g = filtering (as opposed to actioning)
# r = retunred statement from filtering function
# d = directory path to search for plugin files (include *.py), as a list to be separated by filestystem separator symbol

#HOW TO USE # if you are familiar with wordpress, its like their plugins api # include this module in your script using import plugins # call plugins.execute() very early in your script # to allow plugins to alter an object in your script, wrap them like this: # the_object = apply_filters('name_of_filter',the_object,data_to_pass_1,data_to_pass_2,...) # or allow plugins to execute arbitrary actions at various points in your script like this: # do_action('name_of_action',data_to_pass_1,data_to_pass_2,...) # or use decorators on your functions like @plugins.can.replace or @plugins.can.do_before or @plugins.can.filter_args # and users can add their own *.py plugin files in the plugins folder using either add_action or add_filter: # add_filter('name_of_filter',plugin_function_for_filtering) # def plugin_function_for_filtering(item_to_filter,data_to_pass_1,data_to_pass_2: # [put code and return the new value] # return new_value_for_item # [if doing 'add_action' return is ignored]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.