mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-27 08:12:32 +00:00
21 lines
380 B
Python
21 lines
380 B
Python
|
import functools
|
||
|
|
||
|
|
||
|
class patch:
|
||
|
|
||
|
originals = {}
|
||
|
|
||
|
def __init__(self, host, name):
|
||
|
self.host = host
|
||
|
self.name = name
|
||
|
|
||
|
def __call__(self, func):
|
||
|
original = getattr(self.host, self.name)
|
||
|
self.originals[self.name] = original
|
||
|
|
||
|
functools.update_wrapper(func, original)
|
||
|
setattr(self.host, self.name, func)
|
||
|
|
||
|
return func
|
||
|
|