| 15 | print(exc) |
| 16 | |
| 17 | class YamlReader(): |
| 18 | |
| 19 | def __init__(self, yamlf): |
| 20 | |
| 21 | if os.path.exists(yamlf): |
| 22 | self.yamlf = yamlf |
| 23 | else: |
| 24 | raise FileExistsError("文件不存在!") |
| 25 | self._data = None # 私有属性 |
| 26 | |
| 27 | @property |
| 28 | def data(self): |
| 29 | if not self._data: |
| 30 | with open(self.yamlf, 'rb') as f: |
| 31 | self._data = list(yaml.safe_load_all(f)) |
| 32 | return self._data[0] |
| 33 | |
| 34 | class AttributeDict(dict): |
| 35 | def __init__(self, *args, **kwargs): |
nothing calls this directly
no outgoing calls
no test coverage detected