File size: 690 Bytes
1f418ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


class RunnerInfo:
    ''' A dynamic dict saving temp information during running
    '''
    def __init__(self):
        self._attributes = {}

    def __setattr__(self, name, value):
        if name == '_attributes':
            super().__setattr__(name, value)
        else:
            self._attributes[name] = value

    def __getattr__(self, name):
        if name in self._attributes:
            return self._attributes[name]
        raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
    
    def __repr__(self):
        attrs = ''.join(f"\n{key}={value!r}" for key, value in self._attributes.items())
        return f"{type(self).__name__}({attrs})"