fparser.common.splitline
Defines LineSplitter and helper functions.
Original Author: Pearu Peterson <pearu@cens.ioc.ee> First version created: May 2006
Module Contents
Classes
Dummy string class. |
Functions
|
|
|
Splits the supplied line of text into parts consisting of regions that |
|
Splits a line into top-level parenthesis and not-parenthesised |
- fparser.common.splitline.string_replace_map(line, lower=False)[source]
Replaces string constants with symbol ‘_F2PY_STRING_CONSTANT_<index>_’
Replaces (expression) with symbol (F2PY_EXPR_TUPLE_<index>)
Replaces real numerical constants containing an exponent with symbol F2PY_REAL_CONSTANT_<index>_
- Parameters:
- Returns:
a new line and the replacement map.
- Return type:
2-tuple of str and
fparser.common.splitline.StringReplaceDict
- fparser.common.splitline.splitquote(line, stopchar=None, lower=False, quotechars='"\'')[source]
Splits the supplied line of text into parts consisting of regions that are not contained within quotes and those that are.
Allows for the processing of a line that follows on from a previous one where a quoted string was begun but not closed by supporting the current closing quotation character to be specified.
- Parameters:
line (str) – the line to split.
stopchar (Optional[str]) – the quote character that will terminate an existing quoted string or None otherwise.
lower (bool) – whether or not to convert the split parts of the line to lowercase.
quotechars (str) – the characters that are considered to delimit quoted strings.
- Returns:
tuple containing a list of the parts of the line split into those parts that are not quoted strings and those parts that are as well as the quote character corresponding with any quoted string that has not been closed before the end of the line.
- Return type:
- fparser.common.splitline.splitparen(line, paren_open='([', paren_close=')]')[source]
Splits a line into top-level parenthesis and not-parenthesised parts. E.g.: “a( (1+2)*3) = b(x)” becomes: [“a”, “( (1+2)*3)”, “ = b”, “(x)”] :param str line: the string to split. :param str paren_open: The characters that define an open parentheses. :param str paren_close: The characters that define a closing parentheses. :return: List of parenthesised and not-parenthesised parts :rtype: list of str The paren_open and paren_close strings must be matched in order: paren_open[x] is closed by paren_close[x].