A Lite Package focuses on making overwrite and mending functions easier and more flexible.

Overview

Overwrite

Make Overwrite More flexible In Python

Build Status

A Lite Package focuses on making overwrite and mending functions easier and more flexible. Certain Method performs differently in Certain Condition in an event queue. Certainly used for mending or expanding finished Projects without modifying existed Codes.

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

Package Related

Package ast, inspect, functools Used in Package.

Installation

https://pypi.org/project/Overwrite/0.0.9/

Overwrite requires Python 3.6+ to run.

Simply install with one-line pip command.

pip install Overwrite

How to Use

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. Event_queue_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 overwrite events.
  4. func (function): Mending function, used for overwriting.
Overwrite = Overwrite()
Overwrite.Butler.register('Register_type', times, _license, func)
# Add overwrite entrance to function
@Overwrite.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 where the function is Called
Overwrite.claim(_license)
affected_func()

The Performance above is same as:

func()

Features

Complex Overwrite

Overwrite.Butler.register('Event_queue_type_A', 1, license_A, func_A)
Overwrite.Butler.register('Event_queue_type_A', 2, license_B, func_B)
Overwrite.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
@Overwrite.entrance(catalog='Event_queue_type_A')
def affected_func_A():
    print('A')
    return
@Overwrite.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:

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

Get Catalog Name and Available Licenses of Original Function

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

Browse the Event Queue

Print details for Event Queue:

Overwrite.Queue.print(catalog: str)

Get length of Event Queue:

Overwrite.Queue.len(catalog: str)

Get Event Queue as following type:

Overwrite.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:

Overwrite.Queue.append(catalog: str, event: list)
Overwrite.Queue.pop(catalog: str, index: int)
Overwrite.Queue.replace(catalog: str, event: list, index: int)
Overwrite.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 classes for each individual thread is a reasonable solution.

Development

Version: 2021.11.18 (0.0.9)

Author: Zack the White, Qcmcmc

Email Contact: Zack the White Qcmcmc

License

MIT

You might also like...
Make pack up python files easier.

python-easy-pack make pack up python files easier. 目前只提供了中文环境 如何使用? 将index.py复制到你的项目文件夹,或者把.py文件拷贝到这个文件夹。 打开你的cmd或者powershell 切换到程序所在目录,输入python index

This collection is to provide an easier way to interact with Juniper

Ansible Collection - cremsburg.apstra Overview The goal of this collection is to provide an easier way to interact with Juniper's Apstra solution. Whi

This tool allows you to do goole dorking much easier

This tool allows you to do goole dorking much easier

The CS Netlogo Helper is a small python script I made, to make computer science homework easier.
The CS Netlogo Helper is a small python script I made, to make computer science homework easier.

The CS Netlogo Helper is a small python script I made, to make computer science homework easier. This project is really ironic now that I think about it.

JARVIS PC Assistant is an assisting program to make your computer easier to use

JARVIS-PC-Assistant JARVIS PC Assistant is an assisting program to make your computer easier to use Welcome to the J.A.R.V.I.S. PC Assistant help file

A Powerful Tool For Making Combo List(All possible modes)
A Powerful Tool For Making Combo List(All possible modes)

ComboMaker A Powerful Tool For Making Combo List Introduction Check out all possible Combo list build modes with this tool =) How to Install Open the

Randomly distribute members by groups making sure that every sector is represented

Generate Groups Randomly distribute members by groups making sure that every sector is represented The Scenario Imagine that you have a large group of

New multi tool im making adding features currently

Emera Multi Tool New multi tool im making adding features currently Current List of Planned Features - Linkvertise Bypasser - Discord Auto Bump - Gith

"Cambio de monedas" Change-making problem with Python, dynamic programming best solutions,

Change-making-problem / Cambio de monedas Entendiendo el problema Dada una cantidad de dinero y una lista de denominaciones de monedas, encontrar el n

Owner
null
Providing a working, flexible, easier and faster installer than the one officially provided by Arch Linux

Purpose The purpose is to bring more people to Arch Linux by providing a working, flexible, easier and faster installer than the one officially provid

André Luís 0 Nov 9, 2022
Izy - Python functions and classes that make python even easier than it is

izy Python functions and classes that make it even easier! You will wonder why t

null 5 Jul 4, 2022
Aerospace utilities: flight conditions package, standard atmosphere model, and more.

Aerospace Utilities About Module that contains commonly-used aerospace utilities for problem solving. Flight Condition: input altitude to compute comm

null 1 Jan 3, 2022
addons to the turtle package that help you drew stuff more quickly

TurtlePlus addons to the turtle package that help you drew stuff more quickly --------------

null 1 Nov 18, 2021
ARA Records Ansible and makes it easier to understand and troubleshoot.

ARA Records Ansible ARA Records Ansible and makes it easier to understand and troubleshoot. It's another recursive acronym. What it does Simple to ins

Community managed Ansible repositories 1.6k Dec 25, 2022
Stopmagic gives you the power of creating amazing Stop Motion animations faster and easier than ever before.

Stopmagic gives you the power of creating amazing Stop Motion animations faster and easier than ever before. This project is maintained by Aldrin Mathew.

Aldrin's Art Factory 67 Dec 31, 2022
Blender Light Manipulation - A script that makes it easier to work with light

Blender Light Manipulation A script that makes it easier to work with light 1. Wstęp W poniższej dokumentacji przedstawiony zostanie skrypt, który swo

Tomasz 1 Oct 19, 2021
A Way to Use Python, Easier.

PyTools A Way to Use Python, Easier. How to Install Just copy this code, then make a new file in your project directory called PyTools.py, then paste

Kamran 2 Aug 15, 2022
A wrapper script to make working with ADB (Android Debug Bridge) easier

Python-ADB-Wrapper A wrapper script to make working with ADB (Android Debug Bridge) easier This project was just a simple test to see if I could wrap

18iteration 1 Nov 25, 2021