Make after-work Mending More flexible In Python

Related tags

MiscellaneousMending
Overview

Mending

Make after-work Mending More flexible In Python

Build Status

A Lite Package focuses on making project's after-post mending pythonic and flexible. Certainly used for expanding finished projects without changing exists source code.

  • No Origin Codes Changes, Injection with Licenses
  • None Invasive Embed Way, More Flexible
  • Easy to use

Package Related

Thr Official Packages ast, inspect, functools used.

Installation

Overwrite requires Python 3.6+ to run.

Simply install with one-line pip command.

pip install Mending

How to Use

Core Import

from Mending import Mend

Set a License Any type of Cipher-text is satisfactory. Set int 0 as example.

_license = 0

Defined Function Mending function, used for overwrite previous method.

def func():
    return

Register Function to Event queue.

  1. Register_type (string): Register with the same Event_queue_type will be added to the same event queue (in registration order).
  2. times (integer): The times this function calling is affected. (if affected forever, set times to -1)
  3. license (any): Used to identify whether the modification is valid and distinguish between different mending events.
  4. func (function): Mending function, used for overwriting.
Mend = Mend()
Mend.Butler.register('Register_type', times, _license, func)
# Add entrance to function
@Mend.entrance(catalog='Register_type')
def affected_func():
    return

Add the License Claim If the license is valid, the registered function affected_func will be modified and completely overwritten by func.

# Claim above the function calling
Mend.claim(_license)
affected_func()

The Performance above is same as:

func()

Features

Complex Overwrite

Mend.Butler.register('Event_queue_type_A', 1, license_A, func_A)
Mend.Butler.register('Event_queue_type_A', 2, license_B, func_B)
Mend.Butler.register('Event_queue_type_B', 1, license_B, func_C)
def func_A():
    print('1')
    return
def func_B():
    print('2')
    return
def func_C():
    print('3')
    return
@Mend.entrance(catalog='Event_queue_type_A')
def affected_func_A():
    print('A')
    return
@Mend.entrance(catalog='Event_queue_type_B')
def affected_func_B():
    print('B')
    return

Different license claiming leads to different way of overwriting. After several times calling set before, the performance of modified function will change back to origin again as a result of event queue gets empty. The program works as below:

@Mend.claim(license_B)
affected_func_A() # Output: 2
@Mend.claim(license_A)
affected_func_A() # Output: 1
@Mend.claim(license_B)
affected_func_A() # Output: 2
@Mend.claim(license_A)
affected_func_A() # Output: A
@Mend.claim(license_B)
affected_func_A() # Output: A
@Mend.claim(license_B)
affected_func_B() # Output: 3
@Mend.claim(license_B)
affected_func_B() # Output: B

Get Catalog Name and Available Licenses of Original Function

Mend.Butler.get(affected_func)
-> dict {'catalog_name': str, 'available_license': list[str]}

Browse the Event Queue

Print details for Event Queue:

Mend.Queue.print(catalog: str)

Get length of Event Queue:

Mend.Queue.len(catalog: str)

Get Event Queue as following type:

Mend.Queue.get(catalog: str)
[{'times_left': int, 'license': any, 'function_name': str}, 
 {'times_left': int, 'license': any, 'function_name': str},
 {'times_left': int, 'license': any, 'function_name': str},]

Directly manipulate the Event Queue

Class Queue redefined, making it compatible with Pythonic Style Commands as below:

Mend.Queue.append(catalog: str, event: list)
Mend.Queue.pop(catalog: str, index: int)
Mend.Queue.replace(catalog: str, event: list, index: int)
Mend.Queue.clear(catalog: str)

Threading

For multi-threaded function overrides, the event queue is cross-threaded, and the order of event completion depends on the total program time sequence, asynchrony may cause event order confusion. Instantiating Mending for each individual thread is a reasonable solution.

Development

Version: 2021.11.18 (0.0.8)

Author: Zack the White, Qcmcmc

Email Contact: Zack the White Qcmcmc

License

MIT

K2HASH Python library - NoSQL Key Value Store(KVS) library

k2hash_python Overview k2hash_python is an official python driver for k2hash. Install Firstly you must install the k2hash shared library: curl -o- htt

Yahoo! JAPAN 3 Oct 19, 2022
Explore-bikeshare-data - GitHub project as part of the Programming for Data Science with Python Nanodegree from Udacity

Date created February 10, 2022 Project Title Explore US Bikeshare Data Descripti

Thárcyla 1 Feb 14, 2022
Add your recently blog and douban states in your GitHub Profile

Add your recently blog and douban states in your GitHub Profile

Bingjie Yan 4 Dec 12, 2022
Zeus - Advanced Punishments with Embeds.

Zeus Advanced Punishments with Embeds. Make sure to put the Discord Bot Token in the " TOKEN = '' " Language Python Features Ban Kick Mute Unmute Warn

2 Jan 05, 2022
A micro-service that can be extended to help in monitoring systems

A micro-service that can be extended to help in monitoring systems. Be extensible to be incorporated in any of the systems to facilitate timely interventions.

Peter Kagwe 1 Feb 06, 2022
LTGen provides classic algorithms used in Language Theory.

LTGen LTGen stands for Language Theory GENerator and provides tools to implement language theory. Command Line LTGen is a collection of tools to imple

Hugues Cassé 1 Jan 07, 2022
Shopping-card - Shopping Card Project With Python

Shopping Card Project this application was built to handle problems with saving

moein98 1 May 06, 2022
Python project that aims to discover CDP neighbors and map their Layer-2 topology within a shareable medium like Visio or Draw.io.

Python project that aims to discover CDP neighbors and map their Layer-2 topology within a shareable medium like Visio or Draw.io.

3 Feb 11, 2022
This is a Python program I wrote to simulate the solar system with 79 lines of code.

Solar System With Python This is a Python program I wrote to simulate the solar system with 79 lines of code. Required modules tkinter, math, time Why

Mehmet Aydoğmuş 1 Oct 26, 2021
FindUncommonShares.py is a Python equivalent of PowerView's Invoke-ShareFinder.ps1 allowing to quickly find uncommon shares in vast Windows Domains.

FindUncommonShares The script FindUncommonShares.py is a Python equivalent of PowerView's Invoke-ShareFinder.ps1 allowing to quickly find uncommon sha

Podalirius 184 Jan 03, 2023
serological measurements from multiplexed ELISA assays

pysero pysero enables serological measurements with multiplexed and standard ELISA assays. The project automates estimation of antibody titers from da

Chan Zuckerberg Biohub 5 Aug 06, 2022
Simple logger for Urbit pier size, with systemd timer template

urbit-piermon Simple logger for Urbit pier size, with systemd timer template. Syntax piermon.py -i [PATH TO PIER] -o [PATH TO OUTPUT CSV] systemd serv

1 Nov 07, 2021
dynamically create __slots__ objects with less code

slots_factory Factory functions and decorators for creating slot objects Slots are a python construct that allows users to create an object that doesn

Michael Green 2 Sep 07, 2021
Package to provide translation methods for pyramid, and means to reload translations without stopping the application

Package to provide translation methods for pyramid, and means to reload translations without stopping the application

Grzegorz Śliwiński 4 Nov 20, 2022
Hartree-Fock Workshop for the Han-sur-Lesse Winterschool of 2021

Hartree-Fock course for the Han-sur-Lesse Winterschool of 2021 Requirements For going through these exercises, please install the Anaconda suite. Next

Ivo Filot 2 Nov 16, 2022
Python data loader for Solar Orbiter's (SolO) Energetic Particle Detector (EPD).

Data loader (and downloader) for Solar Orbiter/EPD energetic charged particle sensors EPT, HET, and STEP. Supports level 2 and low latency data provided by ESA's Solar Orbiter Archive.

Jan Gieseler 9 Dec 16, 2022
A Python library to simulate a Zoom H6 recorder remote control

H6 A Python library to emulate a Zoom H6 recorder remote control Introduction This library allows you to control your Zoom H6 recorder from your compu

Matias Godoy 68 Nov 02, 2022
Test reproducibility of leiden/umap on different systems

Demonstrate that UMAP and Leiden analysis is not reproducible between different cpu architectures.

Gregor Sturm 2 Oct 16, 2021
Saturne best tools pour baiser tout le système de discord

Installation | Important | Discord 🌟 Comme Saturne est gratuit, les dons sont vraiment appréciables et maintiennent le développement! Caractéristique

GalackQSM 8 Oct 02, 2022
Random Programming Language Project

Crastle Random Programming Language Project Freedom of expression Are you a fan of curly brace languages? Then use curly braces! Not a fan of curly br

DevNugget 2 Dec 23, 2021