jarvisplot 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jarvisplot might be problematic. Click here for more details.
- jarvisplot/Figure/adapters.py +773 -0
- jarvisplot/Figure/cards/std_axes_adapter_config.json +23 -0
- jarvisplot/Figure/data_pipelines.py +87 -0
- jarvisplot/Figure/figure.py +1573 -0
- jarvisplot/Figure/helper.py +217 -0
- jarvisplot/Figure/load_data.py +252 -0
- jarvisplot/__init__.py +0 -0
- jarvisplot/cards/a4paper/1x1/ternary.json +6 -0
- jarvisplot/cards/a4paper/2x1/rect.json +106 -0
- jarvisplot/cards/a4paper/2x1/rect5x1.json +344 -0
- jarvisplot/cards/a4paper/2x1/rect_cmap.json +181 -0
- jarvisplot/cards/a4paper/2x1/ternary.json +139 -0
- jarvisplot/cards/a4paper/2x1/ternary_cmap.json +189 -0
- jarvisplot/cards/a4paper/4x1/rect.json +106 -0
- jarvisplot/cards/a4paper/4x1/rect_cmap.json +174 -0
- jarvisplot/cards/a4paper/4x1/ternary.json +139 -0
- jarvisplot/cards/a4paper/4x1/ternary_cmap.json +189 -0
- jarvisplot/cards/args.json +50 -0
- jarvisplot/cards/colors/colormaps.json +140 -0
- jarvisplot/cards/default/output.json +11 -0
- jarvisplot/cards/gambit/1x1/ternary.json +6 -0
- jarvisplot/cards/gambit/2x1/rect_cmap.json +200 -0
- jarvisplot/cards/gambit/2x1/ternary.json +139 -0
- jarvisplot/cards/gambit/2x1/ternary_cmap.json +205 -0
- jarvisplot/cards/icons/JarvisHEP.png +0 -0
- jarvisplot/cards/icons/gambit.png +0 -0
- jarvisplot/cards/icons/gambit_small.png +0 -0
- jarvisplot/cards/style_preference.json +23 -0
- jarvisplot/cli.py +64 -0
- jarvisplot/client.py +6 -0
- jarvisplot/config.py +69 -0
- jarvisplot/core.py +237 -0
- jarvisplot/data_loader.py +441 -0
- jarvisplot/inner_func.py +162 -0
- jarvisplot/utils/__init__.py +0 -0
- jarvisplot/utils/cmaps.py +258 -0
- jarvisplot/utils/interpolator.py +377 -0
- jarvisplot-1.0.0.dist-info/METADATA +93 -0
- jarvisplot-1.0.0.dist-info/RECORD +42 -0
- jarvisplot-1.0.0.dist-info/WHEEL +5 -0
- jarvisplot-1.0.0.dist-info/entry_points.txt +2 -0
- jarvisplot-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Frame": {
|
|
3
|
+
"figure": {
|
|
4
|
+
"figsize": [
|
|
5
|
+
3.3,
|
|
6
|
+
2.75
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"axes": {
|
|
10
|
+
"axlogo": {
|
|
11
|
+
"rect": [
|
|
12
|
+
0.01,
|
|
13
|
+
0.01,
|
|
14
|
+
0.06,
|
|
15
|
+
0.072
|
|
16
|
+
],
|
|
17
|
+
"frameon": false,
|
|
18
|
+
"yticks": [],
|
|
19
|
+
"xticks": [],
|
|
20
|
+
"xlim": [0, 1024],
|
|
21
|
+
"ylim": [1024, 0]
|
|
22
|
+
},
|
|
23
|
+
"axtri": {
|
|
24
|
+
"rect": [
|
|
25
|
+
0.127,
|
|
26
|
+
0.168,
|
|
27
|
+
0.745,
|
|
28
|
+
0.775
|
|
29
|
+
],
|
|
30
|
+
"xlim": [
|
|
31
|
+
0.0,
|
|
32
|
+
1.0
|
|
33
|
+
],
|
|
34
|
+
"ylim": [
|
|
35
|
+
0.0,
|
|
36
|
+
1.0
|
|
37
|
+
],
|
|
38
|
+
"clip_on": false,
|
|
39
|
+
"frameon": false,
|
|
40
|
+
"yticks": [],
|
|
41
|
+
"xticks": []
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"axtri":{
|
|
45
|
+
"frame": {
|
|
46
|
+
"linewidth": 0.8,
|
|
47
|
+
"solid_capstyle": "projecting",
|
|
48
|
+
"solid_joinstyle": "miter",
|
|
49
|
+
"clip_on": false,
|
|
50
|
+
"c": "#21171A",
|
|
51
|
+
"zorder": 100
|
|
52
|
+
},
|
|
53
|
+
"grid": {
|
|
54
|
+
"sep": 0.1,
|
|
55
|
+
"style": {
|
|
56
|
+
"color": "#C2C2C269",
|
|
57
|
+
"linewidth": 0.3,
|
|
58
|
+
"linestyle": "--"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"ticks": {
|
|
62
|
+
"majorsep": 0.1,
|
|
63
|
+
"minorsep": 0.025,
|
|
64
|
+
"majorlength": 0.02,
|
|
65
|
+
"minorlength": 0.008,
|
|
66
|
+
"majorstyle": {
|
|
67
|
+
"color": "#21171A",
|
|
68
|
+
"linestyle": "-",
|
|
69
|
+
"linewidth": 0.6,
|
|
70
|
+
"clip_on":false,
|
|
71
|
+
"zorder": 99
|
|
72
|
+
},
|
|
73
|
+
"bottomticklables": {
|
|
74
|
+
"ha": "center",
|
|
75
|
+
"va": "top",
|
|
76
|
+
"fontsize": 6,
|
|
77
|
+
"fontfamily": "Fira code"
|
|
78
|
+
},
|
|
79
|
+
"leftticklables": {
|
|
80
|
+
"ha": "center",
|
|
81
|
+
"va": "center",
|
|
82
|
+
"fontsize": 6,
|
|
83
|
+
"fontfamily": "Fira code"
|
|
84
|
+
},
|
|
85
|
+
"rightticklables": {
|
|
86
|
+
"ha": "left",
|
|
87
|
+
"va": "center",
|
|
88
|
+
"fontsize": 6,
|
|
89
|
+
"fontfamily": "Fira code"
|
|
90
|
+
},
|
|
91
|
+
"minorstyle": {
|
|
92
|
+
"color": "grey",
|
|
93
|
+
"linestyle": "-",
|
|
94
|
+
"linewidth": 0.4,
|
|
95
|
+
"clip_on":false,
|
|
96
|
+
"zorder": 98
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"labels": {
|
|
100
|
+
"leftstyle": {
|
|
101
|
+
"x": 0.16,
|
|
102
|
+
"y": 0.56,
|
|
103
|
+
"rotation": 60,
|
|
104
|
+
"fontsize": 12,
|
|
105
|
+
"fontfamily": "STIXGeneral",
|
|
106
|
+
"ha":"center",
|
|
107
|
+
"va":"center"
|
|
108
|
+
},
|
|
109
|
+
"bottomstyle": {
|
|
110
|
+
"x": 0.5,
|
|
111
|
+
"y": -0.12,
|
|
112
|
+
"fontsize": 12,
|
|
113
|
+
"fontfamily": "STIXGeneral",
|
|
114
|
+
"ha":"center",
|
|
115
|
+
"va":"center"
|
|
116
|
+
},
|
|
117
|
+
"rightstyle": {
|
|
118
|
+
"x": 0.84,
|
|
119
|
+
"y": 0.56,
|
|
120
|
+
"rotation": -60,
|
|
121
|
+
"fontsize": 12,
|
|
122
|
+
"fontfamily": "STIXGeneral",
|
|
123
|
+
"ha":"center",
|
|
124
|
+
"va":"center"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"Style": {
|
|
130
|
+
"scatter": {
|
|
131
|
+
"s": 1.0,
|
|
132
|
+
"marker": "^",
|
|
133
|
+
"linewidths": 0.02,
|
|
134
|
+
"alpha": 1.0,
|
|
135
|
+
"zorder": 30,
|
|
136
|
+
"edgecolor": "white"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Frame": {
|
|
3
|
+
"figure": {
|
|
4
|
+
"figsize": [
|
|
5
|
+
3.3,
|
|
6
|
+
2.75
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"axes": {
|
|
10
|
+
"axlogo": {
|
|
11
|
+
"rect": [
|
|
12
|
+
0.01,
|
|
13
|
+
0.05,
|
|
14
|
+
0.12,
|
|
15
|
+
0.072
|
|
16
|
+
],
|
|
17
|
+
"frameon": false,
|
|
18
|
+
"yticks": [],
|
|
19
|
+
"xticks": [],
|
|
20
|
+
"xlim": [
|
|
21
|
+
0,
|
|
22
|
+
1024
|
|
23
|
+
],
|
|
24
|
+
"ylim": [
|
|
25
|
+
512,
|
|
26
|
+
0
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"axtri": {
|
|
30
|
+
"rect": [
|
|
31
|
+
0.173,
|
|
32
|
+
0.168,
|
|
33
|
+
0.745,
|
|
34
|
+
0.775
|
|
35
|
+
],
|
|
36
|
+
"xlim": [
|
|
37
|
+
0.0,
|
|
38
|
+
1.0
|
|
39
|
+
],
|
|
40
|
+
"ylim": [
|
|
41
|
+
0.0,
|
|
42
|
+
1.0
|
|
43
|
+
],
|
|
44
|
+
"clip_on": false,
|
|
45
|
+
"frameon": false,
|
|
46
|
+
"yticks": [],
|
|
47
|
+
"xticks": [],
|
|
48
|
+
"facecolor": "#808080"
|
|
49
|
+
},
|
|
50
|
+
"axc": {
|
|
51
|
+
"rect": [
|
|
52
|
+
0.100,
|
|
53
|
+
0.400,
|
|
54
|
+
0.036,
|
|
55
|
+
0.528
|
|
56
|
+
],
|
|
57
|
+
"xticks": []
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"axtri": {
|
|
61
|
+
"frame": {
|
|
62
|
+
"linewidth": 0.8,
|
|
63
|
+
"solid_capstyle": "projecting",
|
|
64
|
+
"solid_joinstyle": "miter",
|
|
65
|
+
"clip_on": false,
|
|
66
|
+
"c": "#21171A",
|
|
67
|
+
"zorder": 0
|
|
68
|
+
},
|
|
69
|
+
"grid": {
|
|
70
|
+
"sep": 0.1,
|
|
71
|
+
"style": {
|
|
72
|
+
"color": "#C2C2C269",
|
|
73
|
+
"linewidth": 0.3,
|
|
74
|
+
"linestyle": "--"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"ticks": {
|
|
78
|
+
"majorsep": 0.1,
|
|
79
|
+
"minorsep": 0.025,
|
|
80
|
+
"majorlength": 0.02,
|
|
81
|
+
"minorlength": 0.008,
|
|
82
|
+
"majorstyle": {
|
|
83
|
+
"color": "#21171A",
|
|
84
|
+
"linestyle": "-",
|
|
85
|
+
"linewidth": 0.6,
|
|
86
|
+
"clip_on": false,
|
|
87
|
+
"zorder": 4
|
|
88
|
+
},
|
|
89
|
+
"bottomticklables": {
|
|
90
|
+
"ha": "center",
|
|
91
|
+
"va": "top",
|
|
92
|
+
"fontsize": 6,
|
|
93
|
+
"fontfamily": "Fira code"
|
|
94
|
+
},
|
|
95
|
+
"leftticklables": {
|
|
96
|
+
"ha": "center",
|
|
97
|
+
"va": "center",
|
|
98
|
+
"fontsize": 6,
|
|
99
|
+
"fontfamily": "Fira code"
|
|
100
|
+
},
|
|
101
|
+
"rightticklables": {
|
|
102
|
+
"ha": "left",
|
|
103
|
+
"va": "center",
|
|
104
|
+
"fontsize": 6,
|
|
105
|
+
"fontfamily": "Fira code"
|
|
106
|
+
},
|
|
107
|
+
"minorstyle": {
|
|
108
|
+
"color": "grey",
|
|
109
|
+
"linestyle": "-",
|
|
110
|
+
"linewidth": 0.4,
|
|
111
|
+
"clip_on": false,
|
|
112
|
+
"zorder": 3
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"labels": {
|
|
116
|
+
"leftstyle": {
|
|
117
|
+
"x": 0.1375,
|
|
118
|
+
"y": 0.575,
|
|
119
|
+
"rotation": 60,
|
|
120
|
+
"fontsize": 12,
|
|
121
|
+
"fontfamily": "STIXGeneral",
|
|
122
|
+
"ha": "center",
|
|
123
|
+
"va": "center"
|
|
124
|
+
},
|
|
125
|
+
"bottomstyle": {
|
|
126
|
+
"x": 0.5,
|
|
127
|
+
"y": -0.12,
|
|
128
|
+
"fontsize": 12,
|
|
129
|
+
"fontfamily": "STIXGeneral",
|
|
130
|
+
"ha": "center",
|
|
131
|
+
"va": "center"
|
|
132
|
+
},
|
|
133
|
+
"rightstyle": {
|
|
134
|
+
"x": 0.8625,
|
|
135
|
+
"y": 0.575,
|
|
136
|
+
"rotation": -60,
|
|
137
|
+
"fontsize": 12,
|
|
138
|
+
"fontfamily": "STIXGeneral",
|
|
139
|
+
"ha": "center",
|
|
140
|
+
"va": "center"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"axc": {
|
|
145
|
+
"label": {
|
|
146
|
+
"ylabel": "",
|
|
147
|
+
"loc": "top",
|
|
148
|
+
"fontsize": 12,
|
|
149
|
+
"fontfamily": "STIXGeneral"
|
|
150
|
+
},
|
|
151
|
+
"ticks": {
|
|
152
|
+
"ticks_position": "left",
|
|
153
|
+
"both": {
|
|
154
|
+
"labelsize": 6,
|
|
155
|
+
"direction": "in",
|
|
156
|
+
"labelfontfamily": "sans",
|
|
157
|
+
"top": false,
|
|
158
|
+
"left": true,
|
|
159
|
+
"right": false,
|
|
160
|
+
"bottom": false,
|
|
161
|
+
"which": "both"
|
|
162
|
+
},
|
|
163
|
+
"major": {
|
|
164
|
+
"which": "major",
|
|
165
|
+
"length": 4,
|
|
166
|
+
"width": 0.4,
|
|
167
|
+
"color": "black"
|
|
168
|
+
},
|
|
169
|
+
"minor": {
|
|
170
|
+
"which": "minor",
|
|
171
|
+
"length": 2,
|
|
172
|
+
"width": 0.4,
|
|
173
|
+
"color": "black"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"axlogo":{
|
|
178
|
+
"file": "&JP/jarvisplot/cards/icons/gambit_small.png",
|
|
179
|
+
"text": [
|
|
180
|
+
{
|
|
181
|
+
"x": 0.0,
|
|
182
|
+
"y": -0.5,
|
|
183
|
+
"s": "GAMBIT 2.7",
|
|
184
|
+
"ha": "left",
|
|
185
|
+
"va": "bottom",
|
|
186
|
+
"color": "black",
|
|
187
|
+
"fontfamily": "Fira code",
|
|
188
|
+
"fontsize": 5.0,
|
|
189
|
+
"fontstyle": "normal",
|
|
190
|
+
"fontweight": "normal"
|
|
191
|
+
}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"Style": {
|
|
196
|
+
"scatter": {
|
|
197
|
+
"s": 1.0,
|
|
198
|
+
"marker": "^",
|
|
199
|
+
"linewidths": 0.02,
|
|
200
|
+
"alpha": 1.0,
|
|
201
|
+
"zorder": 30,
|
|
202
|
+
"edgecolor": "white"
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"a4paper_1x1": {
|
|
3
|
+
"Ternary": "&JP/jarvisplot/cards/a4paper/1x1/ternary.json"
|
|
4
|
+
},
|
|
5
|
+
"a4paper_2x1": {
|
|
6
|
+
"Ternary": "&JP/jarvisplot/cards/a4paper/2x1/ternary.json",
|
|
7
|
+
"rect": "&JP/jarvisplot/cards/a4paper/2x1/rect.json",
|
|
8
|
+
"rect_5x1": "&JP/jarvisplot/cards/a4paper/2x1/rect5x1.json",
|
|
9
|
+
"TernaryCmap": "&JP/jarvisplot/cards/a4paper/2x1/ternary_cmap.json",
|
|
10
|
+
"rectcmap": "&JP/jarvisplot/cards/a4paper/2x1/rect_cmap.json"
|
|
11
|
+
},
|
|
12
|
+
"a4paper_4x1": {
|
|
13
|
+
"rectcmap": "&JP/jarvisplot/cards/a4paper/4x1/rect_cmap.json"
|
|
14
|
+
},
|
|
15
|
+
"gambit_1x1": {
|
|
16
|
+
"Ternary": "&JP/jarvisplot/cards/gambit/1x1/ternary.json"
|
|
17
|
+
},
|
|
18
|
+
"gambit_2x1": {
|
|
19
|
+
"Ternary": "&JP/jarvisplot/cards/gambit/2x1/ternary.json",
|
|
20
|
+
"TernaryCmap": "&JP/jarvisplot/cards/gambit/2x1/ternary_cmap.json",
|
|
21
|
+
"rectcmap": "&JP/jarvisplot/cards/gambit/2x1/rect_cmap.json"
|
|
22
|
+
}
|
|
23
|
+
}
|
jarvisplot/cli.py
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import os, sys
|
|
6
|
+
|
|
7
|
+
# --- version import fallback ---
|
|
8
|
+
try:
|
|
9
|
+
from .version import __version__ as JPLOT_VERSION
|
|
10
|
+
except Exception:
|
|
11
|
+
JPLOT_VERSION = "0.0.0"
|
|
12
|
+
|
|
13
|
+
class CLI():
|
|
14
|
+
def __init__(self):
|
|
15
|
+
self.args = argparse.ArgumentParser(description="JarvisPLOT Help Center", formatter_class=argparse.RawTextHelpFormatter)
|
|
16
|
+
self.pwd = os.path.abspath(os.path.dirname(__file__))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
with open("{}/cards/args.json".format(self.pwd), 'r') as f1:
|
|
20
|
+
args = json.load(f1)
|
|
21
|
+
# --- positionals, with nargs handling and 'file' optional by default ---
|
|
22
|
+
for pos_arg in args.get("positionals", []):
|
|
23
|
+
heltp = pos_arg['help'].replace("$n", "\n")
|
|
24
|
+
pkwargs = {"help": heltp}
|
|
25
|
+
# Allow JSON to set nargs; default: make 'file' optional so -v works without it
|
|
26
|
+
if 'nargs' in pos_arg:
|
|
27
|
+
pkwargs['nargs'] = pos_arg['nargs']
|
|
28
|
+
elif pos_arg.get('name') == 'file':
|
|
29
|
+
pkwargs['nargs'] = '?'
|
|
30
|
+
self.args.add_argument(pos_arg['name'], **pkwargs)
|
|
31
|
+
# --- options, handle version action with JarvisPLOT version ---
|
|
32
|
+
for opt in args.get("options", []):
|
|
33
|
+
action = opt.get('action', 'store')
|
|
34
|
+
kwargs = {
|
|
35
|
+
'help': opt['help'],
|
|
36
|
+
'dest': opt.get('dest')
|
|
37
|
+
}
|
|
38
|
+
if action == 'version':
|
|
39
|
+
kwargs['action'] = 'version'
|
|
40
|
+
kwargs['version'] = f"JarvisPLOT {JPLOT_VERSION}"
|
|
41
|
+
else:
|
|
42
|
+
kwargs['action'] = action
|
|
43
|
+
if 'metavar' in opt:
|
|
44
|
+
kwargs['metavar'] = opt['metavar']
|
|
45
|
+
if 'default' in opt:
|
|
46
|
+
kwargs['default'] = opt['default']
|
|
47
|
+
if "type" in opt:
|
|
48
|
+
if opt['type'] == 'int':
|
|
49
|
+
kwargs['type'] = int
|
|
50
|
+
elif opt['type'] == 'float':
|
|
51
|
+
kwargs['type'] = float
|
|
52
|
+
else:
|
|
53
|
+
kwargs['type'] = str
|
|
54
|
+
if 'short' in opt and 'long' in opt:
|
|
55
|
+
self.args.add_argument(
|
|
56
|
+
opt['short'],
|
|
57
|
+
opt['long'],
|
|
58
|
+
**kwargs
|
|
59
|
+
)
|
|
60
|
+
elif 'long' in opt:
|
|
61
|
+
self.args.add_argument(
|
|
62
|
+
opt['long'], **kwargs
|
|
63
|
+
)
|
|
64
|
+
|
jarvisplot/client.py
ADDED
jarvisplot/config.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Optional, Any, Dict, List
|
|
6
|
+
import yaml
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
class ConfigLoader:
|
|
10
|
+
"""Lightweight config holder with auto-updating path fields.
|
|
11
|
+
|
|
12
|
+
Setting `self.file` updates:
|
|
13
|
+
- `self.path` : absolute file path (str)
|
|
14
|
+
- `self.dir` : directory path (str)
|
|
15
|
+
- `self.stem` : filename without suffix (str)
|
|
16
|
+
- `self.ext` : file suffix like ".yaml" (str)
|
|
17
|
+
"""
|
|
18
|
+
def __init__(self) -> None:
|
|
19
|
+
self._file: Optional[str] = None
|
|
20
|
+
self.logger: Any = None
|
|
21
|
+
self.path: Optional[str] = None
|
|
22
|
+
self.dir: Optional[str] = None
|
|
23
|
+
self.stem: Optional[str] = None
|
|
24
|
+
self.ext: Optional[str] = None
|
|
25
|
+
self.config: Optional[Dict[str, Any]] = None
|
|
26
|
+
|
|
27
|
+
# ---- property: file ----
|
|
28
|
+
@property
|
|
29
|
+
def file(self) -> Optional[str]:
|
|
30
|
+
return self._file
|
|
31
|
+
|
|
32
|
+
@file.setter
|
|
33
|
+
def file(self, value: Optional[str]) -> None:
|
|
34
|
+
if value is None:
|
|
35
|
+
# reset all derived fields
|
|
36
|
+
self._file = None
|
|
37
|
+
self.path = None
|
|
38
|
+
self.dir = None
|
|
39
|
+
self.stem = None
|
|
40
|
+
self.ext = None
|
|
41
|
+
return
|
|
42
|
+
p = Path(value).expanduser().resolve()
|
|
43
|
+
self._file = str(p)
|
|
44
|
+
self.path = os.path.abspath(p)
|
|
45
|
+
self.dir = os.path.dirname(p)
|
|
46
|
+
self.stem = p.stem
|
|
47
|
+
self.ext = p.suffix
|
|
48
|
+
|
|
49
|
+
# ---- helpers ----
|
|
50
|
+
def load(self) -> Dict[str, Any]:
|
|
51
|
+
"""Load YAML from `self.file` into `self.config` and return it."""
|
|
52
|
+
if not self._file:
|
|
53
|
+
raise ValueError("ConfigLoader.file is not set")
|
|
54
|
+
with open(self._file, "r", encoding="utf-8") as f:
|
|
55
|
+
self.config = yaml.safe_load(f)
|
|
56
|
+
return self.config or {}
|
|
57
|
+
|
|
58
|
+
def __repr__(self) -> str: # pragma: no cover
|
|
59
|
+
return f"ConfigLoader(file={self._file!r}, dir={self.dir!r})"
|
|
60
|
+
|
|
61
|
+
def update_dataset(self, target_name, updates: dict):
|
|
62
|
+
for d in self.config["DataSet"]:
|
|
63
|
+
if d.get("name") == target_name:
|
|
64
|
+
print(d.keys())
|
|
65
|
+
d.update(updates)
|
|
66
|
+
print(d.keys())
|
|
67
|
+
return True # 成功更新
|
|
68
|
+
return False # 没找到
|
|
69
|
+
|