mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-29 02:57:20 +00:00
ec71907701
Co-authored-by: Karako <karakohear@gmail.com>
18 lines
436 B
Python
18 lines
436 B
Python
def patch(obj):
|
|
def is_patchable(item):
|
|
return getattr(item[1], 'patchable', False)
|
|
|
|
def wrapper(container):
|
|
for name, func in filter(is_patchable, container.__dict__.items()):
|
|
old = getattr(obj, name, None)
|
|
setattr(obj, f'old_{name}', old)
|
|
setattr(obj, name, func)
|
|
return container
|
|
|
|
return wrapper
|
|
|
|
|
|
def patchable(func):
|
|
func.patchable = True
|
|
return func
|