Skip to content

Commit 1a56ef1

Browse files
committed
utils/errors: updated codes
1 parent 42d2bd9 commit 1a56ef1

File tree

519 files changed

+2043
-2070
lines changed

Some content is hidden

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

519 files changed

+2043
-2070
lines changed

scripts/inp_code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ def ATTRS_CHECK(element, parent_name, t):
146146
for attribute in element.attributes:
147147
if attribute.restriction:
148148
if attribute.optional:
149-
o += f'{TABS(t)}if {attribute.name} is not None and not ({attribute.restriction}):\n{TABS(t+1)}raise {f"errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, {attribute.name})" if parent_name else f"errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, {attribute.name})"}\n'
149+
o += f'{TABS(t)}if {attribute.name} is not None and not ({attribute.restriction}):\n{TABS(t+1)}raise {f"errors.InpError(errors.InpCode.SEMANTICS_OPTION, {attribute.name})" if parent_name else f"errors.InpError(errors.InpCode.SEMANTICS_CARD, {attribute.name})"}\n'
150150
else:
151-
o += f'{TABS(t)}if {attribute.name} is None or not ({attribute.restriction}):\n{TABS(t+1)}raise {f"errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, {attribute.name})" if parent_name else f"errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, {attribute.name})"}\n'
151+
o += f'{TABS(t)}if {attribute.name} is None or not ({attribute.restriction}):\n{TABS(t+1)}raise {f"errors.InpError(errors.InpCode.SEMANTICS_OPTION, {attribute.name})" if parent_name else f"errors.InpError(errors.InpCode.SEMANTICS_CARD, {attribute.name})"}\n'
152152
else:
153153
if attribute.optional:
154154
continue
155155
else:
156-
o += f'{TABS(t)}if {attribute.name} is None:\n{TABS(t+1)}raise {f"errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, {attribute.name})" if parent_name else f"errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, {attribute.name})"}\n'
156+
o += f'{TABS(t)}if {attribute.name} is None:\n{TABS(t+1)}raise {f"errors.InpError(errors.InpCode.SEMANTICS_OPTION, {attribute.name})" if parent_name else f"errors.InpError(errors.InpCode.SEMANTICS_CARD, {attribute.name})"}\n'
157157

158158
return o.strip()
159159

scripts/inp_data.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(
7171
mnemonic: str,
7272
attributes: tuple[AttributeScheme],
7373
options: tuple[any] = None,
74-
error: str = 'SEMANTICS_OPTION_VALUE',
74+
error: str = 'SEMANTICS_OPTION',
7575
extra: str = '',
7676
):
7777
"""
@@ -104,7 +104,7 @@ def __init__(
104104
options=[
105105
ElementScheme(
106106
name='comment',
107-
error='SEMANTICS_CARD_VALUE',
107+
error='SEMANTICS_CARD',
108108
mnemonic='c',
109109
attributes=[
110110
AttributeScheme(
@@ -116,7 +116,7 @@ def __init__(
116116
),
117117
ElementScheme(
118118
name='cell',
119-
error='SEMANTICS_CARD_VALUE',
119+
error='SEMANTICS_CARD',
120120
mnemonic='',
121121
attributes=[
122122
AttributeScheme(
@@ -637,7 +637,7 @@ def __init__(
637637
),
638638
ElementScheme(
639639
name='surface',
640-
error='SEMANTICS_CARD_VALUE',
640+
error='SEMANTICS_CARD',
641641
mnemonic='',
642642
attributes=[
643643
AttributeScheme(
@@ -2633,7 +2633,7 @@ def draw(self):
26332633
),
26342634
ElementScheme(
26352635
name='data',
2636-
error='SEMANTICS_CARD_VALUE',
2636+
error='SEMANTICS_CARD',
26372637
mnemonic='',
26382638
attributes=[
26392639
AttributeScheme(

src/pymcnp/Inp.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,29 @@ def __init__(
6262
``Inp``.
6363
6464
Raises:
65-
InpError: SEMATNICS_INP_MESSAGE.
66-
InpError: SEMATNICS_INP_TITLE.
67-
InpError: SEMATNICS_INP_CELLS.
68-
InpError: SEMATNICS_INP_SURFACES.
69-
InpError: SEMATNICS_INP_DATA.
70-
InpError: SEMATNICS_INP_OTHER.
65+
InpError: SEMATNICS_INP.
7166
"""
7267

7368
if title is None or not len(title) < 80:
74-
raise errors.InpError(errors.InpCode.SEMANTICS_INP_TITLE, title)
69+
raise errors.InpError(errors.InpCode.SEMANTICS_INP, title)
7570

7671
if cells is None or None in cells:
77-
raise errors.InpError(errors.InpCode.SEMANTICS_INP_CELLS, cells)
72+
raise errors.InpError(errors.InpCode.SEMANTICS_INP, cells)
7873

7974
if cells_comments is None or None in cells_comments:
80-
raise errors.InpError(errors.InpCode.SEMANTICS_INP_COMMENTS, cells_comments)
75+
raise errors.InpError(errors.InpCode.SEMANTICS_INP, cells_comments)
8176

8277
if surfaces is None or None in surfaces:
83-
raise errors.InpError(errors.InpCode.SEMANTICS_INP_SURFACES, surfaces)
78+
raise errors.InpError(errors.InpCode.SEMANTICS_INP, surfaces)
8479

8580
if surfaces_comments is None or None in surfaces_comments:
86-
raise errors.InpError(errors.InpCode.SEMANTICS_INP_COMMENTS, surfaces_comments)
81+
raise errors.InpError(errors.InpCode.SEMANTICS_INP, surfaces_comments)
8782

8883
if data is None or None in data:
89-
raise errors.InpError(errors.InpCode.SEMANTICS_INP_DATA, data)
84+
raise errors.InpError(errors.InpCode.SEMANTICS_INP, data)
9085

9186
if data_comments is None or None in data_comments:
92-
raise errors.InpError(errors.InpCode.SEMANTICS_INP_COMMENTS, data_comments)
87+
raise errors.InpError(errors.InpCode.SEMANTICS_INP, data_comments)
9388

9489
self.message: typing.Final[types.String] = message
9590
self.title: typing.Final[types.String] = title

src/pymcnp/Meshtal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def __init__(
3333
"""
3434

3535
if header is None:
36-
raise errors.MeshtalError(errors.MeshtalCode.SEMANTICS_MESHTAL_HEADER)
36+
raise errors.MeshtalError(errors.MeshtalCode.SEMANTICS_MESHTAL)
3737

3838
if tallies is None:
39-
raise errors.MeshtalError(errors.MeshtalCode.SEMANTICS_MESHTAL_TALLIES)
39+
raise errors.MeshtalError(errors.MeshtalCode.SEMANTICS_MESHTAL)
4040

4141
self.header: typing.Final[meshtal.Header] = header
4242
self.tallies: typing.Final[

src/pymcnp/Ptrac.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ def __init__(
2828
``Ptrac``.
2929
3030
Raises:
31-
PtracError: SEMANTICS_PTRAC_HEADER.
32-
PtracError: SEMANTICS_PTRAC_HISTORY.
31+
PtracError: SEMANTICS_PTRAC.
3332
"""
3433

3534
if header is None:
36-
raise errors.PtracError(errors.PtracCode.SEMANTICS_PTRAC_HEADER)
35+
raise errors.PtracError(errors.PtracCode.SEMANTICS_PTRAC)
3736

3837
if histories is None:
39-
raise errors.PtracError(errors.PtracCode.SEMANTICS_PTRAC_HISTORY)
38+
raise errors.PtracError(errors.PtracCode.SEMANTICS_PTRAC)
4039

4140
self.header: typing.Final[ptrac.Header] = header
4241
self.histories: typing.Final[typing.Generator[ptrac.History, None, None]] = histories

src/pymcnp/inp/Cell.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Cell(Card):
1616
Represents INP cell cards.
1717
1818
Attributes:
19-
InpError: SEMANTICS_CARD_VALUE.
19+
InpError: SEMANTICS_CARD.
2020
"""
2121

2222
_ATTRS = {
@@ -50,17 +50,17 @@ def __init__(
5050
options: cell options.
5151
5252
Raises:
53-
InpError: SEMANTICS_CARD_VALUE.
53+
InpError: SEMANTICS_CARD.
5454
"""
5555

5656
if number is None or not (1 <= number <= 99_999_999):
57-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, number)
57+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, number)
5858
if material is None or not (0 <= material <= 99_999_999):
59-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, material)
59+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, material)
6060
if (density is not None and material == 0) or (density is None and material != 0):
61-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, density)
61+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, density)
6262
if geometry is None:
63-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, geometry)
63+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, geometry)
6464

6565
self.number: types.Integer = number
6666
self.material: types.Integer = material

src/pymcnp/inp/Comment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self, text: types.String):
2727
text: comment text.
2828
2929
Raises:
30-
InpError: SEMANTICS_CARD_VALUE.
30+
InpError: SEMANTICS_CARD.
3131
"""
3232

3333
self.text: typing.Final[types.String] = text

src/pymcnp/inp/Data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Data(Card):
1414
Represents INP data elements.
1515
1616
Attributes:
17-
InpError: SEMANTICS_CARD_VALUE.
17+
InpError: SEMANTICS_CARD.
1818
"""
1919

2020
_ATTRS = {'option': data.DataOption}
@@ -29,11 +29,11 @@ def __init__(self, option: data.DataOption):
2929
option: data option.
3030
3131
Raises:
32-
InpError: SEMANTICS_CARD_VALUE.
32+
InpError: SEMANTICS_CARD.
3333
"""
3434

3535
if option is None:
36-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, option)
36+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, option)
3737

3838
self.option: typing.Final[data.DataOption] = option
3939

src/pymcnp/inp/Surface.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ def __init__(
4949
``Surface``.
5050
5151
Raises:
52-
InpError: SEMANTICS_CARD_VALUE.
52+
InpError: SEMANTICS_CARD.
5353
"""
5454

5555
if number is None or not (1 <= number <= 99_999_999 if not transform else 999):
56-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, number)
56+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, number)
5757
if transform is not None and not (0 <= transform <= 999):
58-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, transform)
58+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, transform)
5959
if option is None:
60-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, option)
60+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, option)
6161
if prefix is not None and prefix not in {'*', '+'}:
62-
raise errors.InpError(errors.InpCode.SEMANTICS_CARD_VALUE, prefix)
62+
raise errors.InpError(errors.InpCode.SEMANTICS_CARD, prefix)
6363

6464
self.number: typing.Final[types.Integer] = number
6565
self.transform: typing.Final[types.Integer] = transform

src/pymcnp/inp/cell/Bflcl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ def __init__(self, number: types.Integer):
3030
number: Cell magnetic field number.
3131
3232
Raises:
33-
InpError: SEMANTICS_OPTION_VALUE.
33+
InpError: SEMANTICS_OPTION.
3434
"""
3535

3636
if number is None or not (number >= 0):
37-
raise errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, number)
37+
raise errors.InpError(errors.InpCode.SEMANTICS_OPTION, number)
3838

3939
self.value: typing.Final[types.Tuple] = types.Tuple(
4040
[

0 commit comments

Comments
 (0)