montepy.input_parser.input_syntax_reader module#
- montepy.input_parser.input_syntax_reader.read_data(fh, mcnp_version, block_type=None, recursion=False)#
Reads the bulk of an MCNP file for all of the MCNP data.
This is a generator function that will yield multiple
MCNP_Input
instances.Warning
This function will move the file handle forward in state.
Warning
This function will not close the file handle.
Changed in version 0.2.0:
file_wrapper
was added to better track which file is being read.- Parameters:
fh (MCNP_InputFile) – The file handle of the input file.
mcnp_version (tuple) – The version of MCNP that the input is intended for.
block_type (BlockType) – The type of block this file is in. This is only used with partial files read using the ReadInput.
recursion (bool) – Whether or not this is being called recursively. If True this has been called from read_data. This prevents the reading queue causing infinite recursion.
- Returns:
MCNP_Input instances: Inputs that represent the data in the MCNP input.
- Return type:
MCNP_Input
- montepy.input_parser.input_syntax_reader.read_front_matters(fh, mcnp_version)#
Reads the beginning of an MCNP file for all of the unusual data there.
This is a generator function that will yield multiple
MCNP_Input
instances.Warning
This function will move the file handle forward in state.
Warning
This function will not close the file handle.
Changed in version 0.2.0:
fh
was changed to be an MCNP_InputFile to hold more information.- Parameters:
fh (MCNP_InputFile) – The file handle of the input file.
mcnp_version (tuple) – The version of MCNP that the input is intended for.
- Returns:
an instance of the Title class, and possible an instance of a Message class
- Return type:
- montepy.input_parser.input_syntax_reader.read_input_syntax(input_file, mcnp_version=(6, 2, 0), replace=True)#
Creates a generator function to return a new MCNP input for every new one that is encountered.
This is meant to just handle the MCNP input syntax, it does not semantically parse the inputs.
The version must be a three component tuple e.g., (6, 2, 0) and (5, 1, 60).
- Parameters:
input_file (MCNP_InputFile) – the path to the input file to be read
mcnp_version (tuple) – The version of MCNP that the input is intended for.
replace (bool) – replace all non-ASCII characters with a space (0x20)
- Returns:
a generator of MCNP_Object objects
- Return type:
generator