Skip to content

Commit

Permalink
Actually propogated option through full stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Jan 17, 2024
1 parent 225fe0e commit dbf5133
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion montepy/input_parser/input_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ def read_input(input_file, mcnp_version=DEFAULT_VERSION, encoding="ascii"):
"""
problem = mcnp_problem.MCNP_Problem(input_file)
problem.mcnp_version = mcnp_version
problem.parse_input()
problem.parse_input(encoding=encoding)
return problem
11 changes: 10 additions & 1 deletion montepy/input_parser/input_syntax_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
reading_queue = []


def read_input_syntax(input_file, mcnp_version=DEFAULT_VERSION):
def read_input_syntax(input_file, mcnp_version=DEFAULT_VERSION, encoding="ascii"):
"""
Creates a generator function to return a new MCNP input for
every new one that is encountered.
Expand All @@ -25,11 +25,20 @@ def read_input_syntax(input_file, mcnp_version=DEFAULT_VERSION):
The version must be a three component tuple e.g., (6, 2, 0) and (5, 1, 60).
.. Note::
For different encoding schemes see the available list
`here <https://docs.python.org/3.9/library/codecs.html#standard-encodings>`_.
CP1252 is commonly referred to as "extended-ASCII".
You may have success with this encoding for working with special characters.
:param input_file: the path to the input file to be read
:type input_file: MCNP_InputFile
:param mcnp_version: The version of MCNP that the input is intended for.
:type mcnp_version: tuple
:param encoding: The encoding scheme to use.
:type encoding: str
:returns: a generator of MCNP_Object objects
:rtype: generator
"""
Expand Down
11 changes: 10 additions & 1 deletion montepy/mcnp_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,19 @@ def transforms(self):
"""
return self._transforms

def parse_input(self, check_input=False):
def parse_input(self, check_input=False, encoding="ascii"):
"""
Semantically parses the MCNP file provided to the constructor.
.. Note::
For different encoding schemes see the available list
`here <https://docs.python.org/3.9/library/codecs.html#standard-encodings>`_.
CP1252 is commonly referred to as "extended-ASCII".
You may have success with this encoding for working with special characters.
:param encoding: The encoding scheme to use.
:type encoding: str
:param check_input: If true, will try to find all errors with input and collect them as warnings to log.
:type check_input: bool
"""
Expand Down

0 comments on commit dbf5133

Please sign in to comment.