endf-parserpy 0.6.0__tar.gz → 0.7.0__tar.gz
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.
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/PKG-INFO +1 -1
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/debugging_utils.py +56 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_mapping_core.py +5 -6
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_mapping_utils.py +34 -33
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_parser.py +28 -5
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_utils.py +10 -2
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/logging_utils.py +9 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/meta_control_utils.py +0 -1
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/pyproject.toml +1 -1
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/LICENSE.MIT +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/README.md +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/__init__.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/accessories.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/custom_exceptions.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_lark.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_mappings.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipe_utils.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/__init__.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf0_mt0.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf10.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf12.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf13.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf14.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf15.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt451.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt452.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt455.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt456.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt458.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt460.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf23.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf26.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf27.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf28.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf2_mt151.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf3.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf32.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf33.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf34.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf35.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf4.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf40.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf5.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf6.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf7.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf8.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf8_mt454.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf8_mt457.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf8_mt459.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf9.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/ext_endf_parser.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/fortran_utils.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/math_utils.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/tree_utils.py +0 -0
- {endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/user_tools.py +0 -0
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#
|
|
10
10
|
############################################################
|
|
11
11
|
|
|
12
|
+
from collections.abc import MutableMapping
|
|
12
13
|
from .math_utils import math_allclose
|
|
13
14
|
|
|
14
15
|
|
|
@@ -105,3 +106,58 @@ def compare_objects(obj1, obj2, curpath='', atol=1e-8, rtol=1e-6,
|
|
|
105
106
|
|
|
106
107
|
# return True if equivalent
|
|
107
108
|
return (not found_diff)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class TrackingDict(MutableMapping):
|
|
112
|
+
|
|
113
|
+
def __init__(self, dict_like):
|
|
114
|
+
self._basedict = dict_like
|
|
115
|
+
self._trackingdicts = {}
|
|
116
|
+
self._accessed = set()
|
|
117
|
+
|
|
118
|
+
def __getitem__(self, key):
|
|
119
|
+
if isinstance(key, int):
|
|
120
|
+
self._accessed.add(key)
|
|
121
|
+
retval = self._basedict.__getitem__(key)
|
|
122
|
+
if isinstance(retval, MutableMapping) and not str(key).startswith('__'):
|
|
123
|
+
if key not in self._trackingdicts:
|
|
124
|
+
self._trackingdicts[key] = TrackingDict(retval)
|
|
125
|
+
retval = self._trackingdicts[key]
|
|
126
|
+
return retval
|
|
127
|
+
|
|
128
|
+
def __setitem__(self, key, value):
|
|
129
|
+
if key in self._accessed:
|
|
130
|
+
self._accessed.remove(key)
|
|
131
|
+
if key in self._trackingdicts:
|
|
132
|
+
self._trackingdicts.__delitem__(key)
|
|
133
|
+
return self._basedict.__setitem__(key, value)
|
|
134
|
+
|
|
135
|
+
def __delitem__(self, key):
|
|
136
|
+
if key in self._accessed:
|
|
137
|
+
self._accessed.__delitem__(key)
|
|
138
|
+
if key in self._trackingdicts:
|
|
139
|
+
self._trackingdicts.__delitem__(key)
|
|
140
|
+
return self._basedict.__delitem__(key)
|
|
141
|
+
|
|
142
|
+
def __iter__(self):
|
|
143
|
+
return self._basedict.__iter__()
|
|
144
|
+
|
|
145
|
+
def __len__(self):
|
|
146
|
+
return self._basedict.__len__()
|
|
147
|
+
|
|
148
|
+
def verify_complete_retrieval(self, path=''):
|
|
149
|
+
if len(self._accessed) > 0:
|
|
150
|
+
for k in self._basedict:
|
|
151
|
+
if isinstance(k, int) and k not in self._accessed:
|
|
152
|
+
indexpath = path + '/' + str(k)
|
|
153
|
+
raise IndexError(
|
|
154
|
+
f'The content of {indexpath} was not accessed'
|
|
155
|
+
)
|
|
156
|
+
for k in self._basedict:
|
|
157
|
+
curval = self.__getitem__(k)
|
|
158
|
+
if isinstance(curval, TrackingDict):
|
|
159
|
+
indexpath = path + '/' + str(k)
|
|
160
|
+
curval.verify_complete_retrieval(indexpath)
|
|
161
|
+
|
|
162
|
+
def unwrap(self):
|
|
163
|
+
return self._basedict
|
|
@@ -17,6 +17,7 @@ from .custom_exceptions import (
|
|
|
17
17
|
)
|
|
18
18
|
from .endf_mapping_utils import (
|
|
19
19
|
get_varname, get_indexquants, eval_expr,
|
|
20
|
+
eval_expr_without_unknown_var,
|
|
20
21
|
varvalue_expr_conversion, get_indexvalue
|
|
21
22
|
)
|
|
22
23
|
from .tree_utils import (is_token, get_name, search_name)
|
|
@@ -158,12 +159,10 @@ def map_datadic_to_recorddic(basekeys, record_dic, expr_list,
|
|
|
158
159
|
datadic, loop_vars, parse_opts):
|
|
159
160
|
zipit = zip(basekeys, expr_list)
|
|
160
161
|
for sourcekey, curexpr in zipit:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
IndexError('some variable missing in dictionary')
|
|
166
|
-
record_dic[sourcekey] = expr_vv[0]
|
|
162
|
+
val = eval_expr_without_unknown_var(
|
|
163
|
+
curexpr, datadic, loop_vars, look_up=False, cast_int=False
|
|
164
|
+
)
|
|
165
|
+
record_dic[sourcekey] = val
|
|
167
166
|
return record_dic
|
|
168
167
|
|
|
169
168
|
|
|
@@ -51,14 +51,14 @@ def substitute_abbreviation(val, datadic, loop_vars, look_up):
|
|
|
51
51
|
|
|
52
52
|
def get_varval(expr, datadic, loop_vars, look_up=True, eval_abbrev=True):
|
|
53
53
|
name = get_name(expr, nofail=True)
|
|
54
|
-
if name in ('VARNAME', 'extvarname'):
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
else:
|
|
58
|
-
raise TypeError(f'node must be either of type VARNAME or extvarname ' +
|
|
59
|
-
'but is {name} OR it must be at least a string with ' +
|
|
54
|
+
if name not in ('VARNAME', 'extvarname'):
|
|
55
|
+
raise TypeError('node must be either of type VARNAME or extvarname ' +
|
|
56
|
+
f'but is {name} OR it must be at least a string with ' +
|
|
60
57
|
'the variable name')
|
|
61
58
|
|
|
59
|
+
varname = get_varname(expr)
|
|
60
|
+
idxquants = get_indexquants(expr)
|
|
61
|
+
|
|
62
62
|
if loop_vars is not None:
|
|
63
63
|
if varname in datadic and varname in loop_vars:
|
|
64
64
|
raise LoopVariableError(
|
|
@@ -82,20 +82,14 @@ def get_varval(expr, datadic, loop_vars, look_up=True, eval_abbrev=True):
|
|
|
82
82
|
return datadic[varname]
|
|
83
83
|
else:
|
|
84
84
|
curdic = datadic[varname]
|
|
85
|
-
for
|
|
85
|
+
for idxquant in idxquants:
|
|
86
86
|
idx = get_indexvalue(idxquant, loop_vars)
|
|
87
|
-
if
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
idx = get_indexvalue(idxquants[-1], loop_vars)
|
|
94
|
-
try:
|
|
95
|
-
val = curdic[idx]
|
|
96
|
-
except Exception:
|
|
97
|
-
raise UnavailableIndexError(
|
|
98
|
-
f'index {idx} does not exist in array {varname}')
|
|
87
|
+
if idx in curdic:
|
|
88
|
+
curdic = curdic[idx]
|
|
89
|
+
else:
|
|
90
|
+
raise UnavailableIndexError(
|
|
91
|
+
f'index {idx} does not exist in array {varname}')
|
|
92
|
+
val = curdic
|
|
99
93
|
if eval_abbrev:
|
|
100
94
|
return substitute_abbreviation(val, orig_datadic, loop_vars, look_up)
|
|
101
95
|
else:
|
|
@@ -179,14 +173,11 @@ def varvalue_expr_conversion(vv, val, rwmode, cast_int=True):
|
|
|
179
173
|
|
|
180
174
|
def eval_expr_without_unknown_var(expr, datadic=None, loop_vars=None,
|
|
181
175
|
look_up=True, cast_int=True):
|
|
182
|
-
ret = eval_expr(expr, datadic, loop_vars, look_up, cast_int)
|
|
183
|
-
if ret[1] != 0:
|
|
184
|
-
unknown_varname = get_varname(ret[2])
|
|
185
|
-
raise VariableNotFoundError(
|
|
186
|
-
f'Unknown variable in expression ({unknown_varname})')
|
|
176
|
+
ret = eval_expr(expr, datadic, loop_vars, look_up, cast_int, False)
|
|
187
177
|
return ret[0]
|
|
188
178
|
|
|
189
|
-
def eval_expr(expr, datadic=None, loop_vars=None, look_up=True,
|
|
179
|
+
def eval_expr(expr, datadic=None, loop_vars=None, look_up=True,
|
|
180
|
+
cast_int=True, accept_missing=True):
|
|
190
181
|
name = get_name(expr, nofail=True)
|
|
191
182
|
# reminder: VARNAME is is a string of letters and number, e.g., foo1
|
|
192
183
|
# extvarname can contain an index specification, e.g., foo1[i]
|
|
@@ -200,13 +191,18 @@ def eval_expr(expr, datadic=None, loop_vars=None, look_up=True, cast_int=True):
|
|
|
200
191
|
val = get_varval(expr, datadic, loop_vars, look_up, False)
|
|
201
192
|
if is_tree(val) and get_name(val) == 'expr':
|
|
202
193
|
return eval_expr(
|
|
203
|
-
val, datadic, loop_vars, look_up,
|
|
194
|
+
val, datadic, loop_vars, look_up,
|
|
195
|
+
cast_int, accept_missing
|
|
204
196
|
)
|
|
205
197
|
else:
|
|
206
198
|
return (val, 0, None)
|
|
207
|
-
except VariableNotFoundError:
|
|
199
|
+
except VariableNotFoundError as exc:
|
|
200
|
+
if not accept_missing:
|
|
201
|
+
raise exc
|
|
208
202
|
return (0, 1, expr)
|
|
209
|
-
except UnavailableIndexError:
|
|
203
|
+
except UnavailableIndexError as exc:
|
|
204
|
+
if not accept_missing:
|
|
205
|
+
raise exc
|
|
210
206
|
return (0, 1, expr)
|
|
211
207
|
elif name == 'NUMBER' or name == 'DESIRED_NUMBER':
|
|
212
208
|
vstr = expr.value
|
|
@@ -220,13 +216,16 @@ def eval_expr(expr, datadic=None, loop_vars=None, look_up=True, cast_int=True):
|
|
|
220
216
|
v = float(vstr)
|
|
221
217
|
return (v, 0, None)
|
|
222
218
|
elif name == 'minusexpr':
|
|
223
|
-
v = eval_expr(expr.children[0], datadic, loop_vars, look_up,
|
|
219
|
+
v = eval_expr(expr.children[0], datadic, loop_vars, look_up,
|
|
220
|
+
cast_int, accept_missing)
|
|
224
221
|
return (math_neg(v[0]), -v[1], v[2])
|
|
225
222
|
elif name in ('addition', 'subtraction',
|
|
226
223
|
'multiplication', 'modulo', 'division'):
|
|
227
|
-
v1 = eval_expr(expr.children[0], datadic, loop_vars, look_up,
|
|
224
|
+
v1 = eval_expr(expr.children[0], datadic, loop_vars, look_up,
|
|
225
|
+
cast_int, accept_missing)
|
|
228
226
|
# children[1] contains the operator symbol *,/,+,-
|
|
229
|
-
v2 = eval_expr(expr.children[2], datadic, loop_vars, look_up,
|
|
227
|
+
v2 = eval_expr(expr.children[2], datadic, loop_vars, look_up,
|
|
228
|
+
cast_int, accept_missing)
|
|
230
229
|
if name == 'multiplication':
|
|
231
230
|
if v1[1] != 0 and v2[1] != 0:
|
|
232
231
|
raise SeveralUnboundVariablesError(
|
|
@@ -276,7 +275,8 @@ def eval_expr(expr, datadic=None, loop_vars=None, look_up=True, cast_int=True):
|
|
|
276
275
|
vexpr)
|
|
277
276
|
elif name == 'inconsistent_varspec':
|
|
278
277
|
ch = get_child(expr, 'extvarname')
|
|
279
|
-
return eval_expr(ch, datadic, loop_vars, look_up,
|
|
278
|
+
return eval_expr(ch, datadic, loop_vars, look_up,
|
|
279
|
+
cast_int, accept_missing)
|
|
280
280
|
else:
|
|
281
281
|
# we remove enclosing brackets if present
|
|
282
282
|
ch_first = expr.children[0]
|
|
@@ -288,5 +288,6 @@ def eval_expr(expr, datadic=None, loop_vars=None, look_up=True, cast_int=True):
|
|
|
288
288
|
trimmed_children = expr.children
|
|
289
289
|
assert len(trimmed_children) == 1
|
|
290
290
|
return eval_expr(
|
|
291
|
-
trimmed_children[0], datadic, loop_vars, look_up,
|
|
291
|
+
trimmed_children[0], datadic, loop_vars, look_up,
|
|
292
|
+
cast_int, accept_missing
|
|
292
293
|
)
|
|
@@ -36,6 +36,7 @@ from .endf_recipe_utils import (
|
|
|
36
36
|
get_responsible_recipe_parsetree,
|
|
37
37
|
)
|
|
38
38
|
from .endf_recipes import endf_recipe_dictionary
|
|
39
|
+
from .debugging_utils import TrackingDict
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
class BasicEndfParser():
|
|
@@ -45,6 +46,7 @@ class BasicEndfParser():
|
|
|
45
46
|
blank_as_zero=True, abuse_signpos=False,
|
|
46
47
|
skip_intzero=False, prefer_noexp=False,
|
|
47
48
|
accept_spaces=True, keep_E=False, width=11,
|
|
49
|
+
check_arrays=True, strict_datatypes=False,
|
|
48
50
|
cache_dir=None, print_cache_info=True, recipes=None):
|
|
49
51
|
# obtain the parsing tree for the language
|
|
50
52
|
# in which ENDF reading recipes are formulated
|
|
@@ -94,7 +96,9 @@ class BasicEndfParser():
|
|
|
94
96
|
'skip_intzero': skip_intzero,
|
|
95
97
|
'prefer_noexp': prefer_noexp,
|
|
96
98
|
'keep_E': keep_E,
|
|
97
|
-
'width': width
|
|
99
|
+
'width': width,
|
|
100
|
+
'check_arrays': check_arrays,
|
|
101
|
+
'strict_datatypes': strict_datatypes
|
|
98
102
|
}
|
|
99
103
|
self.read_opts = {
|
|
100
104
|
'accept_spaces': accept_spaces,
|
|
@@ -148,6 +152,7 @@ class BasicEndfParser():
|
|
|
148
152
|
map_head_dic(tree, cont_dic, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
149
153
|
self.datadic.update(get_ctrl(cont_dic))
|
|
150
154
|
else:
|
|
155
|
+
self.logbuffer.save_reduced_record_log(tree)
|
|
151
156
|
head_dic = map_head_dic(tree, {}, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
152
157
|
head_dic.update(get_ctrl(self.datadic))
|
|
153
158
|
newlines = write_head(head_dic, with_ctrl=True, **self.write_opts)
|
|
@@ -165,6 +170,7 @@ class BasicEndfParser():
|
|
|
165
170
|
write_info('Content of the CONT record: ' + str(cont_dic))
|
|
166
171
|
map_cont_dic(tree, cont_dic, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
167
172
|
else:
|
|
173
|
+
self.logbuffer.save_reduced_record_log(tree)
|
|
168
174
|
cont_dic = map_cont_dic(tree, {}, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
169
175
|
cont_dic.update(get_ctrl(self.datadic))
|
|
170
176
|
newlines = write_cont(cont_dic, with_ctrl=True, **self.write_opts)
|
|
@@ -180,6 +186,7 @@ class BasicEndfParser():
|
|
|
180
186
|
dir_dic.update(self.logbuffer.get_last_entry(key_prefix='__'))
|
|
181
187
|
map_dir_dic(tree, dir_dic, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
182
188
|
else:
|
|
189
|
+
self.logbuffer.save_reduced_record_log(tree)
|
|
183
190
|
dir_dic = map_dir_dic(tree, {}, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
184
191
|
dir_dic.update(get_ctrl(self.datadic))
|
|
185
192
|
newlines = write_dir(dir_dic, with_ctrl=True, **self.write_opts)
|
|
@@ -196,6 +203,7 @@ class BasicEndfParser():
|
|
|
196
203
|
intg_dic.update(self.logbuffer.get_last_entry(key_prefix='__'))
|
|
197
204
|
map_intg_dic(tree, intg_dic, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
198
205
|
else:
|
|
206
|
+
self.logbuffer.save_reduced_record_log(tree)
|
|
199
207
|
intg_dic = map_intg_dic(tree, {}, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
200
208
|
intg_dic.update(get_ctrl(self.datadic))
|
|
201
209
|
ndigit = eval_expr_without_unknown_var(get_child(tree, 'ndigit_expr'), self.datadic, self.loop_vars)
|
|
@@ -213,6 +221,7 @@ class BasicEndfParser():
|
|
|
213
221
|
tab1_dic.update(self.logbuffer.get_last_entry(key_prefix='__'))
|
|
214
222
|
map_tab1_dic(tree, tab1_dic, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
215
223
|
else:
|
|
224
|
+
self.logbuffer.save_reduced_record_log(tree)
|
|
216
225
|
tab1_dic = map_tab1_dic(tree, {}, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
217
226
|
tab1_dic.update(get_ctrl(self.datadic))
|
|
218
227
|
newlines = write_tab1(tab1_dic, with_ctrl=True, **self.write_opts)
|
|
@@ -229,6 +238,7 @@ class BasicEndfParser():
|
|
|
229
238
|
tab2_dic.update(self.logbuffer.get_last_entry(key_prefix='__'))
|
|
230
239
|
map_tab2_dic(tree, tab2_dic, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
231
240
|
else:
|
|
241
|
+
self.logbuffer.save_reduced_record_log(tree)
|
|
232
242
|
tab2_dic = map_tab2_dic(tree, {}, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
233
243
|
tab2_dic.update(get_ctrl(self.datadic))
|
|
234
244
|
newlines = write_tab2(tab2_dic, with_ctrl=True, **self.write_opts)
|
|
@@ -245,6 +255,7 @@ class BasicEndfParser():
|
|
|
245
255
|
list_dic.update(self.logbuffer.get_last_entry(key_prefix='__'))
|
|
246
256
|
map_list_dic(tree, list_dic, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
247
257
|
else:
|
|
258
|
+
self.logbuffer.save_reduced_record_log(tree)
|
|
248
259
|
list_dic = map_list_dic(tree, {}, self.datadic, self.loop_vars, self.rwmode, parse_opts=self.parse_opts)
|
|
249
260
|
list_dic.update(get_ctrl(self.datadic))
|
|
250
261
|
newlines = write_list(list_dic, with_ctrl=True, **self.write_opts)
|
|
@@ -257,6 +268,7 @@ class BasicEndfParser():
|
|
|
257
268
|
read_send(self.lines, self.ofs,
|
|
258
269
|
blank_as_zero=self.parse_opts['blank_as_zero'], **self.read_opts)
|
|
259
270
|
else:
|
|
271
|
+
self.logbuffer.save_reduced_record_log(tree)
|
|
260
272
|
newlines = write_send(self.datadic, with_ctrl=True,
|
|
261
273
|
zero_as_blank=self.zero_as_blank,
|
|
262
274
|
**self.write_opts)
|
|
@@ -383,7 +395,7 @@ class BasicEndfParser():
|
|
|
383
395
|
except ParserException as exc:
|
|
384
396
|
if not nofail:
|
|
385
397
|
logstr = self.logbuffer.display_record_logs()
|
|
386
|
-
raise
|
|
398
|
+
raise type(exc)(
|
|
387
399
|
'\nHere is the parser record log until failure:\n\n' +
|
|
388
400
|
logstr + 'Error message: ' + str(exc))
|
|
389
401
|
return mfmt_dic
|
|
@@ -391,6 +403,9 @@ class BasicEndfParser():
|
|
|
391
403
|
def write(self, endf_dic, exclude=None, include=None, zero_as_blank=False):
|
|
392
404
|
self.zero_as_blank = zero_as_blank
|
|
393
405
|
self.reset_parser_state(rwmode='write', datadic={})
|
|
406
|
+
should_check_arrays = self.write_opts['check_arrays']
|
|
407
|
+
if should_check_arrays:
|
|
408
|
+
endf_dic = TrackingDict(endf_dic)
|
|
394
409
|
tree_dic = self.tree_dic
|
|
395
410
|
lines = []
|
|
396
411
|
for mf in sorted(endf_dic):
|
|
@@ -404,9 +419,15 @@ class BasicEndfParser():
|
|
|
404
419
|
if cur_tree is not None and is_parsed:
|
|
405
420
|
datadic = endf_dic[mf][mt]
|
|
406
421
|
self.reset_parser_state(rwmode='write', datadic=datadic)
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
422
|
+
try:
|
|
423
|
+
initialize_abbreviations(self.datadic)
|
|
424
|
+
self.run_instruction(cur_tree)
|
|
425
|
+
finalize_abbreviations(self.datadic)
|
|
426
|
+
except Exception as exc:
|
|
427
|
+
logstr = self.logbuffer.display_reduced_record_logs()
|
|
428
|
+
raise type(exc)(
|
|
429
|
+
'\nHere is the parser record log until failure:\n\n' +
|
|
430
|
+
logstr + 'Error message: ' + str(exc))
|
|
410
431
|
# add the NS number to the lines except last one
|
|
411
432
|
# because the SEND (=section end) record already
|
|
412
433
|
# contains it
|
|
@@ -459,6 +480,8 @@ class BasicEndfParser():
|
|
|
459
480
|
lines.extend(write_tend(with_ctrl=True, with_ns=True,
|
|
460
481
|
zero_as_blank=zero_as_blank, **self.write_opts))
|
|
461
482
|
del self.zero_as_blank
|
|
483
|
+
if should_check_arrays:
|
|
484
|
+
endf_dic.verify_complete_retrieval()
|
|
462
485
|
return lines
|
|
463
486
|
|
|
464
487
|
def parsefile(self, filename, exclude=None, include=None, nofail=False):
|
|
@@ -151,8 +151,16 @@ def write_cont(dic, with_ctrl=True, **write_opts):
|
|
|
151
151
|
width = write_opts.get('width', 11)
|
|
152
152
|
for varname in ('L1', 'L2', 'N1', 'N2'):
|
|
153
153
|
if not isinstance(dic[varname], int):
|
|
154
|
-
|
|
155
|
-
|
|
154
|
+
strict_datatypes = write_opts.get('strict_datatypes', True)
|
|
155
|
+
intval = int(dic[varname])
|
|
156
|
+
floatval = float(dic[varname])
|
|
157
|
+
if intval != floatval or strict_datatypes:
|
|
158
|
+
raise InvalidIntegerError(
|
|
159
|
+
f'variable in slot `{varname}` is not of type integer '
|
|
160
|
+
f'(value = {floatval})'
|
|
161
|
+
)
|
|
162
|
+
else:
|
|
163
|
+
dic[varname] = intval
|
|
156
164
|
C1 = float2fortstr(dic['C1'], **write_opts)
|
|
157
165
|
C2 = float2fortstr(dic['C2'], **write_opts)
|
|
158
166
|
L1 = str(dic['L1']).rjust(width)
|
|
@@ -98,6 +98,15 @@ class RingBuffer():
|
|
|
98
98
|
outstr += 'Line: "{}"\n\n'.format(curentry['line'])
|
|
99
99
|
return outstr
|
|
100
100
|
|
|
101
|
+
def save_reduced_record_log(self, record_tree, onlyfirst=False):
|
|
102
|
+
self.save_record_log(0, '', record_tree, onlyfirst)
|
|
103
|
+
|
|
104
|
+
def display_reduced_record_logs(self):
|
|
105
|
+
outstr = ''
|
|
106
|
+
for curentry in self.get_queue():
|
|
107
|
+
outstr += 'Template: {}\n'.format(curentry['record_spec'])
|
|
108
|
+
return outstr
|
|
109
|
+
|
|
101
110
|
def get_last_entry(self, key_prefix=''):
|
|
102
111
|
last_entry = self.buffer[self.tail]
|
|
103
112
|
return {f'{key_prefix}{k}': v for k, v in last_entry.items()}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf0_mt0.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt451.py
RENAMED
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt452.py
RENAMED
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt455.py
RENAMED
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt456.py
RENAMED
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt458.py
RENAMED
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf1_mt460.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf2_mt151.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf8_mt454.py
RENAMED
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf8_mt457.py
RENAMED
|
File without changes
|
{endf_parserpy-0.6.0 → endf_parserpy-0.7.0}/endf_parserpy/endf_recipes/endf_recipe_mf8_mt459.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|