|
2 | 2 | Module containing utility functions
|
3 | 3 | '''
|
4 | 4 | from importlib.resources import files
|
5 |
| -from functools import cache |
6 | 5 |
|
7 | 6 | import yaml
|
8 | 7 |
|
9 | 8 | # ---------------------------------
|
10 |
| -@cache |
11 |
| -def _get_evt_name() -> dict[str,str]: |
12 |
| - file_path = files('ap_utilities_data').joinpath('evt_name.yaml') |
13 |
| - file_path = str(file_path) |
14 |
| - with open(file_path, encoding='utf-8') as ifile: |
15 |
| - d_data = yaml.safe_load(ifile) |
16 |
| - |
17 |
| - return d_data |
18 |
| -# --------------------------------- |
19 |
| -@cache |
20 |
| -def _get_name_evt(style : str) -> dict[str,str]: |
21 |
| - if style != 'safe_1': |
22 |
| - raise NotImplementedError(f'Style {style} not supported') |
23 |
| - |
24 |
| - file_path = files('ap_utilities_data').joinpath('name_evt.yaml') |
| 9 | +def _load_data(file_name : str) -> dict: |
| 10 | + file_path = files('ap_utilities_data').joinpath(file_name) |
25 | 11 | file_path = str(file_path)
|
26 | 12 | with open(file_path, encoding='utf-8') as ifile:
|
27 | 13 | d_data = yaml.safe_load(ifile)
|
@@ -71,7 +57,7 @@ def read_decay_name(event_type : str, style : str = 'safe_1') -> str:
|
71 | 57 | + -> pl
|
72 | 58 | , -> _
|
73 | 59 | '''
|
74 |
| - d_evt_name = _get_evt_name() |
| 60 | + d_evt_name = _load_data('evt_name.yaml') |
75 | 61 |
|
76 | 62 | if event_type not in d_evt_name:
|
77 | 63 | raise ValueError(f'Event type {event_type} not found')
|
|
0 commit comments