~martijnbraam/pyatem

pyatem/gtk_switcher/decorators.py -rw-r--r-- 394 bytes
ed164087Martijn Braam i18n: update translation files from source 4 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Needs to be a global for decorators
_callbacks = {}


def call_fields(name, self, data):
    if name in _callbacks:
        for f in _callbacks[name]:
            f(self, data)


def field(name):
    def wrapper(func):
        global _callbacks
        if name not in _callbacks:
            _callbacks[name] = []
        _callbacks[name].append(func)
        return func

    return wrapper