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

My attempt at this years Advent of Code!

Advent-of-code-2021 My attempt at this years Advent of Code! day 1: ** day 2: ** day 3: ** day 4: ** day 5: ** day 6: ** day 7: ** day 8: * day 9: day

1 Jul 06, 2022
A GUI love Calculator which saves all the User Data in text file(sql based script will be uploaded soon). Interative GUI. Even For Admin Panel

Love-Calculator A GUI love Calculator which saves all the User Data in text file(sql based script will be uploaded soon). Interative GUI, even For Adm

Adithya Krishnan 1 Mar 22, 2022
Sigma coding youtube - This is a collection of all the code that can be found on my YouTube channel Sigma Coding.

Sigma Coding Tutorials & Resources YouTube • Facebook Support Sigma Coding Patreon • GitHub Sponsor • Shop Amazon Table of Contents Overview Topics Re

Alex Reed 927 Jan 08, 2023
The LiberaPay archive module for the SeanPM life archive project.

By: Top README.md Read this article in a different language Sorted by: A-Z Sorting options unavailable ( af Afrikaans Afrikaans | sq Shqiptare Albania

Sean P. Myrick V19.1.7.2 1 Aug 26, 2022
A notebook explaining the principle of adversarial attacks and their defences

TL;DR: A notebook explaining the principle of adversarial attacks and their defences Abstract: Deep neural networks models have been wildly successful

1 Jan 22, 2022
Delayed iteration for polling and retries.

Does Python need yet another retry / poll library? It needs at least one that isn't coupled to decorators and functions. Decorators prevent the caller

A. Coady 22 Dec 29, 2022
script buat mengcrack

setan script buat mengcrack cara install $ pkg install upgrade && pkg update $ pkg install python $ pkg install git $ pip install requests $ pip insta

1 Nov 03, 2021
This is a Fava extension to display a grouped portfolio view in Fava for a set of Beancount accounts.

Fava Portfolio Summary This is a Fava extension to display a grouped portfolio view in Fava for a set of Beancount accounts. It can also calculate MWR

18 Dec 26, 2022
The Blinker Herald includes helpers to easily emit signals using the excellent blinker library.

Blinker Herald The Blinker Herald includes helpers to easily emit signals using the excelent blinker library. Decorate a function or method with @blin

SatelliteQE 7 Nov 03, 2022
This is a library which aiming to save all my code about cpp. It will help me to code conveniently.

This is a library which aiming to save all my code about cpp. It will help me to code conveniently.

Paul Leo 21 Dec 06, 2021
Convert ldapdomaindump to Bloodhound

ldd2bh Usage usage: ldd2bh.py [-h] [-i INPUT_FOLDER] [-o OUTPUT_FOLDER] [-a] [-u] [-c] [-g] [-d] Convert ldapdomaindump to Bloodhoun

64 Oct 30, 2022
Simple kivy project to help new kivy users build android apps with python.

Kivy Calculator A Simple Calculator made with kivy framework.Works on all platforms from Windows/linux to android. Description Simple kivy project to

Oussama Ben Sassi 6 Oct 06, 2022
A simple, fantasy and fast note taking program.

notes A simple, fantasy and fast note taking program Installation This program supposed to run in linux and may have some bugs on windows or any other

Ali Hosseinverdi 1 Apr 06, 2022
Simple and easy to use python API for the COVID registration booking system of the math department @ unipd (torre archimede)

Simple and easy to use python API for the COVID registration booking system of the math department @ unipd (torre archimede). This API creates an interface with the official browser, with more useful

Guglielmo Camporese 4 Dec 24, 2021
200 LeetCode problems

LeetCode I classify 200 leetcode problems into some categories and upload my code to who concern WEEK 1 # Title Difficulty Array 15 3Sum Medium 1324 P

Hoang Cao Bao 108 Dec 08, 2022
Demo repository for Saltconf21 talk - Testing strategies for Salt states

Saltconf21 testing strategies Demonstration repository for my Saltconf21 talk "Strategies for testing Salt states" Talk recording Slides and demos Get

Barney Sowood 3 Mar 31, 2022
This python module allows to extract data from the RAW-file-format produces by devices from Thermo Fisher Scientific.

fisher_py This Python module allows access to Thermo Orbitrap raw mass spectrometer files. Using this library makes it possible to automate the analys

8 Oct 14, 2022
4Geeks Academy Full-Stack Developer program final project.

Final Project Chavi, Clara y Pablo 4Geeks Academy Full-Stack Developer program final project. Authors Javier Manteca - Coding - chavisam Clara Rojano

1 Feb 05, 2022
Geodesic Dome Math

dome Geodesic Dome Math Python dome tool dome.py calculates an icosahedron or 2v geodesic dome and creates 3d printable hubs as OpenSCAD sources. usag

Brian Olson 2 Feb 09, 2022
take home quiz

guess the correlation data inspection a pretty normal distribution train/val/test split splitting amount .dataset: 150000 instances ├─8

HR Wu 1 Nov 04, 2021