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 |
Functions:
|
- class montepy.input_parser.mcnp_input.Card(*args, **kwargs)#
Bases:
ParsingNodeWarning
Deprecated since version 0.2.0: Punch cards are dead. Use
Inputinstead.- Raises:
DeprecatedError – punch cards are dead.
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.Comment(*args, **kwargs)#
Bases:
ParsingNodeWarning
Deprecated since version 0.2.0: This has been replaced by
CommentNode.- Raises:
DeprecationWarning – Can not be created anymore.
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.Input(input_lines, block_type, input_file=None, lineno=None)#
Bases:
ParsingNodeRepresents a single MCNP “Input” e.g. a single cell definition.
Added in version 0.2.0: This was added as part of the parser rework, and rename. This was a replacement for
Card.- 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.
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.
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.
- 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:
- 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_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. :rtype:MCNP_Lexer
- property line_number#
The line number this input started on.
This is 1-indexed.
- Return type:
int
- 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
CellLexeris used.In a surface block
SurfaceLexeris used.In a data block
DataLexeris used.
- Returns:
a generator of tokens.
- Return type:
Token
- property words#
Warning
Deprecated since version 0.2.0.
This has been deprecated, and removed.
- Raises:
DeprecationWarning – use the parser and tokenize workflow instead.
- class montepy.input_parser.mcnp_input.Jump#
Bases:
objectClass 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:
ParsingNodeObject 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:
ABCObject to represent a single coherent MCNP input, such as an input.
Added in version 0.2.0: This was added as part of the parser rework.
- 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.ReadCard(*args, **kwargs)#
Bases:
CardWarning
Deprecated since version 0.2.0: Punch cards are dead. Use
ReadInputinstead.- Raises:
DeprecatedError – punch cards are dead.
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:
InputA 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.
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.
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.
- 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
- 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_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#
- static is_read_input(input_lines)#
- property lexer#
The current lexer being used to parse this input.
If not currently tokenizing this will be None. :rtype:MCNP_Lexer
- property line_number#
The line number this input started on.
This is 1-indexed.
- Return type:
int
- 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
CellLexeris used.In a surface block
SurfaceLexeris used.In a data block
DataLexeris used.
- Returns:
a generator of tokens.
- Return type:
Token
- property words#
Warning
Deprecated since version 0.2.0.
This has been deprecated, and removed.
- Raises:
DeprecationWarning – use the parser and tokenize workflow instead.
- class montepy.input_parser.mcnp_input.Title(input_lines, title)#
Bases:
ParsingNodeObject 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
- montepy.input_parser.mcnp_input.parse_card_shortcuts(*args, **kwargs)#
Warning
Deprecated since version 0.2.0: This is no longer necessary and should not be called.
- Raises:
DeprecationWarning – This is not needed anymore.