File: _patcher.py

package info (click to toggle)
python-zipfile-zstd 0.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,300 kB
  • sloc: python: 187; makefile: 2
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