Skip to content

Commit 656a7c6

Browse files
committed
files/inp: fixed inp for tests
1 parent 21d92e0 commit 656a7c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1217
-910
lines changed

scripts/build_cell_options.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def build_CellOption(cell_option: _data.CellOptionScheme):
1515
o += 'import re\n'
1616
o += 'from typing import Final\n'
1717
o += '\n'
18-
o += 'from ..cell import CellOption, CellKeyword\n'
19-
o += 'from ....utils import types, errors, _parser\n'
18+
o += 'from ..cell_option import CellOption, CellKeyword\n'
19+
o += 'from ...utils import types, errors, _parser\n'
2020
o += '\n'
2121
o += f'class {cell_option.name}(CellOption):\n'
2222
o += ' """\n'
@@ -137,7 +137,7 @@ def build_CellOption(cell_option: _data.CellOptionScheme):
137137

138138
else:
139139
# value: ?
140-
o += f' {cell_option.attributes[0].name} = {attribute.type}.from_mcnp(tokens.popl())\n'
140+
o += f' {cell_option.attributes[0].name} = {cell_option.attributes[0].type}.from_mcnp(tokens.popl())\n'
141141

142142
o += '\n'
143143

@@ -156,10 +156,10 @@ def build_CellOption(cell_option: _data.CellOptionScheme):
156156
)
157157
with filename.open('w') as file:
158158
file.write(
159-
f'"""\n Contains the ``{cell_option.name}`` subclass of ``CellOption``."""\n\n'
159+
f'"""\n Contains the ``{cell_option.name}`` subclass of ``CellOption``.\n"""\n\n'
160160
+ build_CellOption(cell_option)
161161
)
162-
init_imports.append(f'from .{cell_option.name} import {cell_option.name}')
162+
init_imports.append(f'from .{cell_option.name.lower()} import {cell_option.name}')
163163
init_all.append(f'"{cell_option.name}",')
164164

165165
init_path = pathlib.Path(__file__).parent / pathlib.Path(

scripts/build_data.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def build_Data(data: _data.DataScheme):
325325
o += 'from ..data import DataEntry\n' if data.entries else ''
326326
o += 'from ..data import DataOption\n' if data.options else ''
327327
o += 'from ..data import DataKeyword\n' if data.options else ''
328-
o += 'from ....utils import types, errors, _parser\n'
328+
o += 'from ...utils import types, errors, _parser\n'
329329
o += '\n'
330330

331331
# DATA.ENTRY
@@ -473,6 +473,9 @@ def build_Data(data: _data.DataScheme):
473473
o += '\n'
474474

475475
for attribute in data.attributes:
476+
if attribute.name == 'suffix' or attribute.name == 'designator':
477+
continue
478+
476479
if attribute.type.endswith('Option]'):
477480
# tuple[..Option]
478481

@@ -571,6 +574,9 @@ def build_Data(data: _data.DataScheme):
571574
o += ' return _parser.Postprocessor.add_continuation_lines(f"{self.mnemonic.to_mcnp()}'
572575

573576
for attribute in data.attributes:
577+
if attribute.name == 'designator' or attribute.name == 'suffix':
578+
continue
579+
574580
if attribute.type.startswith('tuple'):
575581
o += f' {{" ".join(entry.to_mcnp() for entry in self.{attribute.name})}}'
576582
elif attribute.type.startswith('dict'):
@@ -593,7 +599,7 @@ def build_Data(data: _data.DataScheme):
593599
)
594600
with filename.open('w') as file:
595601
file.write(build_Data(data))
596-
init_imports.append(f'from .{data.name} import {data.name}')
602+
init_imports.append(f'from .{data.name.lower()} import {data.name}')
597603
init_all.append(f'"{data.name}",')
598604

599605
init_path = pathlib.Path(__file__).parent / pathlib.Path(

scripts/build_surfaces.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def build_Surface(surface: _data.SurfaceScheme):
1515
o += 'from typing import Final\n'
1616
o += '\n'
1717
o += 'from ..surface import Surface, SurfaceMnemonic\n'
18-
o += 'from ....utils import types, errors, _parser\n'
18+
o += 'from ...utils import types, errors, _parser\n'
1919
o += '\n'
2020
o += f'class {surface.name}(Surface):\n'
2121
o += ' """\n'
@@ -106,7 +106,9 @@ def build_Surface(surface: _data.SurfaceScheme):
106106
o += f' ``{surface.name}`` object.\n'
107107
o += '\n'
108108
o += ' Raises:\n'
109-
o += ' McnpError: EXPECTED_TOKEN, UNEXPECTED_TOKEN.\n'
109+
o += ' McnpError: EXPECTED_TOKEN.\n'
110+
o += ' McnpError: UNEXPECTED_TOKEN.\n'
111+
o += ' McnpError: UNRECOGNIZED_KEYWORD.\n'
110112
o += ' """\n'
111113
o += '\n'
112114
o += ' source = _parser.Preprocessor.process_inp(source)\n'
@@ -136,7 +138,8 @@ def build_Surface(surface: _data.SurfaceScheme):
136138
o += ' except Exception:\n'
137139
o += ' transform = None\n'
138140
o += '\n'
139-
o += ' mnemonic = SurfaceMnemonic.from_mcnp(tokens.popl())\n'
141+
o += f' if tokens.popl() != "{surface.mnemonic}":\n'
142+
o += ' raise errors.McnpError(errors.McnpCode.UNRECOGNIZED_KEYWORD, info=source)\n'
140143
o += '\n'
141144

142145
t = []
@@ -145,7 +148,7 @@ def build_Surface(surface: _data.SurfaceScheme):
145148
t.append(attribute.name)
146149

147150
o += '\n'
148-
o += f' return {surface.name}(number, transform, mnemonic, {", ".join(t)}, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting)\n'
151+
o += f' return {surface.name}(number, transform, {", ".join(t)}, is_whiteboundary=is_whiteboundary, is_reflecting=is_reflecting)\n'
149152
o += '\n'
150153

151154
return o
@@ -160,7 +163,7 @@ def build_Surface(surface: _data.SurfaceScheme):
160163
)
161164
with filename.open('w') as file:
162165
file.write(
163-
f'"""\n Contains the ``{surface.name}`` subclass of ``Surface``."""\n\n'
166+
f'"""\n Contains the ``{surface.name}`` subclass of ``Surface``.\n"""\n\n'
164167
+ build_Surface(surface)
165168
)
166169
init_imports.append(f'from .{surface.name.lower()} import {surface.name}')

0 commit comments

Comments
 (0)