montepy.input_parser.mcnp_input module#

class montepy.input_parser.mcnp_input.Card(*args, **kwargs)#

Bases: ParsingNode

Warning

Deprecated since version 0.2.0: Punch cards are dead. Use Input instead.

Raises:

DeprecatedError – punch cards are dead.

abstract 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: ParsingNode

Warning

Deprecated since version 0.2.0: This has been replaced by CommentNode.

Raises:

DeprecationWarning – Can not be created anymore.

abstract 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: ParsingNode

Represents 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.

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:

BlockType

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:

MCNP_InputFile

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().

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: object

Class to represent a default entry represented by a “jump”.

I get up and nothing gets me down
You got it tough, I’ve seen the toughest around
And I know, baby, just how you feel
You gotta roll with the punches to get to what’s real
Oh, can’t you see me standing here?
I got my back against the record machine
I ain’t the worst that you’ve seen
Oh, can’t you see what I mean?
Ah, might as well …
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

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.

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.

abstract 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: Card

Warning

Deprecated since version 0.2.0: Punch cards are dead. Use ReadInput instead.

Raises:

DeprecatedError – punch cards are dead.

abstract 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.

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:

BlockType

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:

MCNP_InputFile

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().

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: 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.

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.