FoamFormatter¶
- class dictIO.formatter.FoamFormatter¶
Bases:
NativeFormatter
Formatter to serialize a dict into a string in OpenFOAM dictionary format.
- __init__() None ¶
Define default configuration for FoamFormatter.
Methods
__init__
()Define default configuration for FoamFormatter.
add_double_quotes
(arg)Add double quotes to a string.
add_single_quotes
(arg)Add single quotes to a string.
format_bool
(arg)Format a boolean.
format_dict
(arg[, tab_len, level, sep, ...])Format a dict or list object.
format_empty_string
(arg)Format an empty string.
Format an expression.
format_float
(arg)Format a floating point number.
format_int
(arg)Format an integer.
format_key
(arg)Format a key.
Format a multi word string.
format_none
()Format None.
format_reference_string
(arg)Format a reference.
format_single_word_string
(arg)Format a single word string.
format_string
(arg)Format a string.
Format a string that contains a nested string.
format_value
(arg)Format a single value.
format_values
(arg)Format multiple values.
get_formatter
([target_file])Return a Formatter instance matching the type of the target file to be formatted (factory method).
insert_block_comments
(s_dict, s)Insert back all block comments.
insert_includes
(s_dict, s)Insert back all include directives.
insert_line_comments
(s_dict, s)Insert back all line directives.
make_default_block_comment
([block_comment])Create the default block comment (header) for files in OpenFOAM dictionary format.
remove_trailing_spaces
(s)Remove trailing spaces from all lines.
to_string
(arg)Create a string representation of the passed in dict in OpenFOAM dictionary format.
- format_empty_string(arg: str) str ¶
Format an empty string.
- Parameters:
arg (str) – the empty string to be formatted
- Returns:
the formatted empty string
- Return type:
str
- format_expression_string(arg: str) str ¶
Format an expression.
- Parameters:
arg (str) – the expression to be formatted
- Returns:
the formatted expression
- Return type:
str
- format_multi_word_string(arg: str) str ¶
Format a multi word string.
- Parameters:
arg (str) – the multi word string to be formatted
- Returns:
the formatted multi word string
- Return type:
str
- format_string_with_nested_string(arg: str) str ¶
Format a string that contains a nested string.
- Parameters:
arg (str) – the string with a nested string to be formatted
- Returns:
the formatted string with a nested string
- Return type:
str
- make_default_block_comment(block_comment: str = '') str ¶
Create the default block comment (header) for files in OpenFOAM dictionary format.
- to_string(arg: MutableMapping[K, V]) str ¶
Create a string representation of the passed in dict in OpenFOAM dictionary format.
- Parameters:
arg (MutableMapping[K, V]) – dict to be formatted
- Returns:
string representation of the dict in OpenFOAM dictionary format
- Return type:
str