Python pyparsing.stringEnd() Examples

The following are 6 code examples of pyparsing.stringEnd(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyparsing , or try the search function .
Example #1
Source File: console.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def __hasDeclEnd(self, line):
        if not self.declEnd: 
            import pyparsing as p
            self.declEnd = p.Literal("`") + p.stringEnd
            self.declEnd.ignore(p.pythonStyleComment)
            self.declEnd.ignore(p.quotedString)

        if self.declEnd.searchString(line.strip()):
            return True
        return False 
Example #2
Source File: pyconsole.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def __hasDeclEnd(self, line):
        if not self.declEnd: 
            import pyparsing as p
            self.declEnd = p.Literal("`") + p.stringEnd
            self.declEnd.ignore(p.pythonStyleComment)
            self.declEnd.ignore(p.quotedString)

        if self.declEnd.searchString(line.strip()):
            return True
        return False 
Example #3
Source File: console.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def __hasDeclEnd(self, line):
        if not self.declEnd: 
            import pyparsing as p
            self.declEnd = p.Literal("`") + p.stringEnd
            self.declEnd.ignore(p.pythonStyleComment)
            self.declEnd.ignore(p.quotedString)

        if self.declEnd.searchString(line.strip()):
            return True
        return False 
Example #4
Source File: alarm_expr_parser.py    From monasca-api with Apache License 2.0 5 votes vote down vote up
def sub_expr_list(self):
        # Remove all spaces before parsing. Simple, quick fix for whitespace
        # issue with dimension list not allowing whitespace after comma.
        parse_result = (expression + pyparsing.stringEnd).parseString(
            self._expr)
        sub_expr_list = parse_result[0].operands_list
        return sub_expr_list 
Example #5
Source File: strutils.py    From oslo.utils with Apache License 2.0 5 votes vote down vote up
def split_by_commas(value):
    """Split values by commas and quotes according to api-wg

    :param value: value to be split

    .. versionadded:: 3.17
    """
    word = (pp.QuotedString(quoteChar='"', escChar='\\') |
            pp.Word(pp.printables, excludeChars='",'))
    grammar = pp.stringStart + pp.delimitedList(word) + pp.stringEnd

    try:
        return list(grammar.parseString(value))
    except pp.ParseException:
        raise ValueError("Invalid value: %s" % value) 
Example #6
Source File: expression.py    From monasca-analytics with Apache License 2.0 4 votes vote down vote up
def __init__(self):
        """
        Create a parser that parse arithmetic expressions. They can
        contains variable identifiers or raw numbers. The meaning
        for the identifiers is left to the
        """
        number = p.Regex(r'\d+(\.\d*)?([eE]\d+)?')
        identifier = p.Word(p.alphas)
        terminal = identifier | number
        self._expr = p.infixNotation(terminal, [
            (p.oneOf('* /'), 2, p.opAssoc.LEFT),
            (p.oneOf('+ -'), 2, p.opAssoc.LEFT)
        ]) + p.stringEnd()