File: _patcher.py

package info (click to toggle)
taisei 1.4.4%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 345,704 kB
  • sloc: ansic: 136,835; cpp: 120,585; javascript: 4,343; asm: 4,083; python: 3,327; lisp: 1,043; xml: 371; sh: 367; makefile: 25
file content (20 lines) | stat: -rw-r--r-- 380 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

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