montepy.input_parser.mcnp_input module#
Classes:
|
Represents a single MCNP "Input" e.g. a single cell definition. |
|
Class to represent a default entry represented by a "jump". |
|
Object to represent an MCNP message. |
|
Object to represent a single coherent MCNP input, such as an input. |
|
A input for the read input that reads another input file |
|
Object to represent the title for an MCNP problem |
- class montepy.input_parser.mcnp_input.Input(input_lines, block_type, input_file=None, lineno=None)#
Bases:
ParsingNode
Represents a single MCNP “Input” e.g. a single cell definition.
- Parameters:
input_lines (list) – the lines read straight from the input file.
block_type (BlockType) – An enum showing which of three MCNP blocks this was inside of.
input_file (MCNP_InputFile) – the wrapper for the input file this is read from.
lineno (int) – the line number this input started at. 1-indexed.
Methods:
format_for_mcnp_input
(mcnp_version)Creates a string representation of this input that can be written to file.
tokenize
()Tokenizes this input as a stream of Tokens.
Attributes:
Prefixes for special comments like tally comments.
Enum representing which block of the MCNP input this came from.
The file this input file was read from.
The lines of the input read straight from the input file
The current lexer being used to parse this input.
The line number this input started on.
- format_for_mcnp_input(mcnp_version)#
Creates a string representation of this input that can be written to file.
- Parameters:
mcnp_version (tuple) – The tuple for the MCNP version that must be exported to.
- Returns:
a list of strings for the lines that this input will occupy.
- Return type:
list
- tokenize()#
Tokenizes this input as a stream of Tokens.
This is a generator of Tokens. This is context dependent based on
block_type()
.In a cell block
CellLexer
is used.In a surface block
SurfaceLexer
is used.In a data block
DataLexer
is used.
- Returns:
a generator of tokens.
- Return type:
Token
- SPECIAL_COMMENT_PREFIXES = ['fc', 'sc']#
Prefixes for special comments like tally comments.
- Return type:
list
- property block_type#
Enum representing which block of the MCNP input this came from.
- Return type:
- property input_file#
The file this input file was read from.
- Return type:
- property input_lines#
The lines of the input read straight from the input file
- Return type:
list
- property input_text#
- property lexer#
The current lexer being used to parse this input.
If not currently tokenizing this will be None.
- Return type:
- property line_number#
The line number this input started on.
This is 1-indexed.
- Return type:
int
- class montepy.input_parser.mcnp_input.Jump#
Bases:
object
Class to represent a default entry represented by a “jump”.
I get up and nothing gets me downYou got it tough, I’ve seen the toughest aroundAnd I know, baby, just how you feelYou gotta roll with the punches to get to what’s realOh, can’t you see me standing here?I got my back against the record machineI ain’t the worst that you’ve seenOh, can’t you see what I mean?Ah, might as well …Methods:
- lower()#
Hop.
- Return type:
str
- title()#
Skip.
- Return type:
str
- upper()#
Jump.
- Return type:
str
- class montepy.input_parser.mcnp_input.Message(input_lines, lines)#
Bases:
ParsingNode
Object to represent an MCNP message.
These are blocks at the beginning of an input that are printed in the output.
- Parameters:
input_lines (list) – the lines read straight from the input file.
lines (list) – the strings of each line in the message block
Methods:
format_for_mcnp_input
(mcnp_version)Creates a string representation of this input that can be written to file.
Attributes:
The lines of the input read straight from the input file
The lines of input for the message block.
- format_for_mcnp_input(mcnp_version)#
Creates a string representation of this input that can be written to file.
- Parameters:
mcnp_version (tuple) – The tuple for the MCNP version that must be exported to.
- Returns:
a list of strings for the lines that this input will occupy.
- Return type:
list
- property input_lines#
The lines of the input read straight from the input file
- Return type:
list
- property input_text#
- property lines#
The lines of input for the message block.
Each entry is a string of that line in the message block
- Return type:
list
- class montepy.input_parser.mcnp_input.ParsingNode(input_lines)#
Bases:
ABC
Object to represent a single coherent MCNP input, such as an input.
- Parameters:
input_lines (list) – the lines read straight from the input file.
Methods:
format_for_mcnp_input
(mcnp_version)Creates a string representation of this input that can be written to file.
Attributes:
The lines of the input read straight from the input file
- abstractmethod format_for_mcnp_input(mcnp_version)#
Creates a string representation of this input that can be written to file.
- Parameters:
mcnp_version (tuple) – The tuple for the MCNP version that must be exported to.
- Returns:
a list of strings for the lines that this input will occupy.
- Return type:
list
- property input_lines#
The lines of the input read straight from the input file
- Return type:
list
- property input_text#
- class montepy.input_parser.mcnp_input.ReadInput(input_lines, block_type, input_file=None, lineno=None)#
Bases:
Input
A input for the read input that reads another input file
- Parameters:
input_lines (list) – the lines read straight from the input file.
block_type (BlockType) – An enum showing which of three MCNP blocks this was inside of.
input_file (MCNP_InputFile) – the wrapper for the input file this is read from.
lineno (int) – the line number this input started at. 1-indexed.
Methods:
format_for_mcnp_input
(mcnp_version)Creates a string representation of this input that can be written to file.
is_read_input
(input_lines)tokenize
()Tokenizes this input as a stream of Tokens.
Attributes:
Prefixes for special comments like tally comments.
Enum representing which block of the MCNP input this came from.
The relative path to the filename specified in this read input.
The file this input file was read from.
The lines of the input read straight from the input file
The current lexer being used to parse this input.
The line number this input started on.
- static is_read_input(input_lines)#
- format_for_mcnp_input(mcnp_version)#
Creates a string representation of this input that can be written to file.
- Parameters:
mcnp_version (tuple) – The tuple for the MCNP version that must be exported to.
- Returns:
a list of strings for the lines that this input will occupy.
- Return type:
list
- tokenize()#
Tokenizes this input as a stream of Tokens.
This is a generator of Tokens. This is context dependent based on
block_type()
.In a cell block
CellLexer
is used.In a surface block
SurfaceLexer
is used.In a data block
DataLexer
is used.
- Returns:
a generator of tokens.
- Return type:
Token
- SPECIAL_COMMENT_PREFIXES = ['fc', 'sc']#
Prefixes for special comments like tally comments.
- Return type:
list
- property block_type#
Enum representing which block of the MCNP input this came from.
- Return type:
- property file_name#
The relative path to the filename specified in this read input.
- Return type:
str
- property input_file#
The file this input file was read from.
- Return type:
- property input_lines#
The lines of the input read straight from the input file
- Return type:
list
- property input_text#
- property lexer#
The current lexer being used to parse this input.
If not currently tokenizing this will be None.
- Return type:
- property line_number#
The line number this input started on.
This is 1-indexed.
- Return type:
int
- class montepy.input_parser.mcnp_input.Title(input_lines, title)#
Bases:
ParsingNode
Object to represent the title for an MCNP problem
- Parameters:
input_lines (list) – the lines read straight from the input file.
title (str) – The string for the title of the problem.
Methods:
format_for_mcnp_input
(mcnp_version)Creates a string representation of this input that can be written to file.
Attributes:
The lines of the input read straight from the input file
The string of the title set for this problem
- format_for_mcnp_input(mcnp_version)#
Creates a string representation of this input that can be written to file.
- Parameters:
mcnp_version (tuple) – The tuple for the MCNP version that must be exported to.
- Returns:
a list of strings for the lines that this input will occupy.
- Return type:
list
- property input_lines#
The lines of the input read straight from the input file
- Return type:
list
- property input_text#
- property title#
The string of the title set for this problem
- Return type:
str