montepy.input_parser.mcnp_input module#

Classes:

Input(input_lines, block_type[, input_file, ...])

Represents a single MCNP "Input" e.g. a single cell definition.

Jump()

Class to represent a default entry represented by a "jump".

Message(input_lines, lines)

Object to represent an MCNP message.

ParsingNode(input_lines)

Object to represent a single coherent MCNP input, such as an input.

ReadInput(input_lines, block_type[, ...])

A input for the read input that reads another input file

Title(input_lines, title)

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:

SPECIAL_COMMENT_PREFIXES

Prefixes for special comments like tally comments.

block_type

Enum representing which block of the MCNP input this came from.

input_file

The file this input file was read from.

input_lines

The lines of the input read straight from the input file

input_text

lexer

The current lexer being used to parse this input.

line_number

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

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:

BlockType

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.

Return type:

MCNP_Lexer

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 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 …

Methods:

lower()

Hop.

title()

Skip.

upper()

Jump.

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:

input_lines

The lines of the input read straight from the input file

input_text

lines

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:

input_lines

The lines of the input read straight from the input file

input_text

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:

SPECIAL_COMMENT_PREFIXES

Prefixes for special comments like tally comments.

block_type

Enum representing which block of the MCNP input this came from.

file_name

The relative path to the filename specified in this read input.

input_file

The file this input file was read from.

input_lines

The lines of the input read straight from the input file

input_text

lexer

The current lexer being used to parse this input.

line_number

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

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:

BlockType

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:

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.

Return type:

MCNP_Lexer

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:

input_lines

The lines of the input read straight from the input file

input_text

title

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