pyPENELOPE

util – Utilities for input modules

Inheritance diagram of penelopetools.api.input.penelope.util

class penelopetools.api.input.penelope.util.Keyword(name, comment='')

Bases: object

comment
create_line(text)

Creates an input line of this keyword from the specified text. The white space between the items is automatically adjusted to fit the line size. The keyword and the total length of the line is checked not to exceed their respective maximum size.

Parameters:
  • keyword – 6-character keyword
  • text – value of the keyword
  • comment – comment associated with the line
find_multiple_lines(lines)

Finds all the lines starting with this keyword.

Parameters:lines (list) – all the lines in the input file
Returns:List of all the lines
Return type:list
find_single_line(lines)

Find the first line starting with this keyword. If no occurrence is not found and the keyword is required, the exception KeywordNotFound is raised. If the keyword is not required, the method returns None.

Parameters:lines (list) – all the lines in the input file
Returns:line
Return type:str
name
validate_values(values, parameters_count)

Validate the values. Check if the values != None and if the number of values equal the specified number of parameters. Raise ValueError if these two conditions are not met.

penelopetools.api.input.penelope.util.extract_keyword(line)

Returns the keyword of the specified line.

Parameters:line (str) – a line from the input file
Return type:str
penelopetools.api.input.penelope.util.extract_keyword_values_comment(line)

Extracts the keyword, the values and the comment of an input line. The values are returned as a list.

Parameters:line – input line
Returns:keyword, values, comment
penelopetools.api.input.penelope.util.extract_values(line)

Returns the values inside the specified line.

Parameters:line (str) – a line from the input file
Return type:list
penelopetools.api.input.penelope.util.find_group_lines(lines, expected_keywords)

Extract the values from occurrence spanning more than one line. The function searches for the first expectedKeyword of list of expected_keywords and finds every occurrence. Each occurrence is then processed to identify the other expected_keywords.

It returns a list containing every occurrence and their respective values stored in a tuple.

Parameters:
  • lines (list) – all the lines in the input file
  • expected_keywords (list of Keyword) – list of the option’s keywords
Return type:

list

penelopetools.api.input.penelope.util.to_string(value, unit='')