RawData

class ase2sprkkr.common.grammar_types.data.RawData(prefix=None, postfix=None, format='', after_format=None, default_value=None, condition=None, after_convert=None, description='', *, lines=None, indented=False, line_length=None, ends_with=None, ends_with_str=None, include_ends_with=False)[source]

Match anything up to the end of the file or to the given delimiter

Class hierarchy

Inheritance diagram of ase2sprkkr.common.grammar_types.data.RawData

Constructor

Parameters:
  • prefix (str | None)

  • postfix (str | None)

  • format (str)

  • after_format (str | None)

  • default_value (Any)

  • condition (Callable[[Any], bool | str] | None)

  • after_convert (Callable[[Any], Any] | None)

  • ends_with (str | Pattern)

__init__(prefix=None, postfix=None, format='', after_format=None, default_value=None, condition=None, after_convert=None, description='', *, lines=None, indented=False, line_length=None, ends_with=None, ends_with_str=None, include_ends_with=False)[source]
lines

Number of lines to read. Can be given as string - then the value of the given option determines the number of lines.

indented

If there are <n> spaces before data, pass n to this arg.

If the file has the following structure: .. code-block:: text

….rest of the splitted line….. ….rest of the splitted line.

……. The second line…………….

….. the rest of the ………… ………… second line …

Pass a tuple with two integers into this argument. The first number of tuple is the max. number of characters on a line, longer lines will be splitted. The second number is the number of spaces placed on the begining of the new lines created by splitting the old.

line_length

Wrap the lines longer than a given number

ends_with

The data ends with a given string.

ends_with_str

If ends_with is regex, print this on end of the data

include_ends_with

Include the ending delimiter to the data.

**kwargs

Any other arguments are passed to the GrammarType constructor

Parameters:
  • prefix (str | None)

  • postfix (str | None)

  • format (str)

  • after_format (str | None)

  • default_value (Any)

  • condition (Callable[[Any], bool | str] | None)

  • after_convert (Callable[[Any], Any] | None)

  • ends_with (str | Pattern)

_n_lines_grammar(lines)[source]

return a grammar for n lines of text

_grammar(param_name=False)[source]
_string(val)[source]

Convert the value to the ouput.

The string() apply format and do some additional transformation (add prefix, postfix etc.), so the actual way how to convert the value for the output should be here.

added_to_container(container)[source]
convert(val)[source]

Convert a value from user to the “cannonical form”