OpenQuizz
Une application de gestion des contenus pédagogiques
QuotedString Class Reference
Inheritance diagram for QuotedString:
Collaboration diagram for QuotedString:

Public Member Functions

def __init__ (self, quoteChar, escChar=None, escQuote=None, multiline=False, unquoteResults=True, endQuoteChar=None, convertWhitespaceEscapes=True)
 
def parseImpl (self, instring, loc, doActions=True)
 
def __str__ (self)
 
- Public Member Functions inherited from Token
def __init__ (self)
 
- Public Member Functions inherited from ParserElement
def __init__ (self, savelist=False)
 
def copy (self)
 
def setName (self, name)
 
def setResultsName (self, name, listAllMatches=False)
 
def setBreak (self, breakFlag=True)
 
def setParseAction (self, *fns, **kwargs)
 
def addParseAction (self, *fns, **kwargs)
 
def addCondition (self, *fns, **kwargs)
 
def setFailAction (self, fn)
 
def preParse (self, instring, loc)
 
def postParse (self, instring, loc, tokenlist)
 
def tryParse (self, instring, loc)
 
def canParseNext (self, instring, loc)
 
def parseString (self, instring, parseAll=False)
 
def scanString (self, instring, maxMatches=_MAX_INT, overlap=False)
 
def transformString (self, instring)
 
def searchString (self, instring, maxMatches=_MAX_INT)
 
def split (self, instring, maxsplit=_MAX_INT, includeSeparators=False)
 
def __add__ (self, other)
 
def __radd__ (self, other)
 
def __sub__ (self, other)
 
def __rsub__ (self, other)
 
def __mul__ (self, other)
 
def __rmul__ (self, other)
 
def __or__ (self, other)
 
def __ror__ (self, other)
 
def __xor__ (self, other)
 
def __rxor__ (self, other)
 
def __and__ (self, other)
 
def __rand__ (self, other)
 
def __invert__ (self)
 
def __call__ (self, name=None)
 
def suppress (self)
 
def leaveWhitespace (self)
 
def setWhitespaceChars (self, chars)
 
def parseWithTabs (self)
 
def ignore (self, other)
 
def setDebugActions (self, startAction, successAction, exceptionAction)
 
def setDebug (self, flag=True)
 
def __repr__ (self)
 
def streamline (self)
 
def checkRecursion (self, parseElementList)
 
def validate (self, validateTrace=[])
 
def parseFile (self, file_or_filename, parseAll=False)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 
def __hash__ (self)
 
def __req__ (self, other)
 
def __rne__ (self, other)
 
def matches (self, testString, parseAll=True)
 
def runTests (self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False)
 

Data Fields

 quoteChar
 
 quoteCharLen
 
 firstQuoteChar
 
 endQuoteChar
 
 endQuoteCharLen
 
 escChar
 
 escQuote
 
 unquoteResults
 
 convertWhitespaceEscapes
 
 flags
 
 pattern
 
 escCharReplacePattern
 
 re
 
 reString
 
 name
 
 errmsg
 
 mayIndexError
 
 mayReturnEmpty
 
 strRepr
 
- Data Fields inherited from ParserElement
 parseAction
 
 failAction
 
 strRepr
 
 resultsName
 
 saveAsList
 
 skipWhitespace
 
 whiteChars
 
 copyDefaultWhiteChars
 
 mayReturnEmpty
 
 keepTabs
 
 ignoreExprs
 
 debug
 
 streamlined
 
 mayIndexError
 
 errmsg
 
 modalResults
 
 debugActions
 
 re
 
 callPreparse
 
 callDuringTry
 
 name
 

Additional Inherited Members

- Static Public Member Functions inherited from ParserElement
def setDefaultWhitespaceChars (chars)
 
def inlineLiteralsUsing (cls)
 
def resetCache ()
 
def enablePackrat (cache_size_limit=128)
 
- Static Public Attributes inherited from ParserElement
 DEFAULT_WHITE_CHARS
 
 verbose_stacktrace
 
 packrat_cache
 
 packrat_cache_lock
 
 packrat_cache_stats
 

Detailed Description

Token for matching strings that are delimited by quoting characters.

Defined with the following parameters:
    - quoteChar - string of one or more characters defining the quote delimiting string
    - escChar - character to escape quotes, typically backslash (default=C{None})
    - escQuote - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=C{None})
    - multiline - boolean indicating whether quotes can span multiple lines (default=C{False})
    - unquoteResults - boolean indicating whether the matched text should be unquoted (default=C{True})
    - endQuoteChar - string of one or more characters defining the end of the quote delimited string (default=C{None} => same as quoteChar)
    - convertWhitespaceEscapes - convert escaped whitespace (C{'\t'}, C{'\n'}, etc.) to actual whitespace (default=C{True})

Example::
    qs = QuotedString('"')
    print(qs.searchString('lsjdf "This is the quote" sldjf'))
    complex_qs = QuotedString('{{', endQuoteChar='}}')
    print(complex_qs.searchString('lsjdf {{This is the "quote"}} sldjf'))
    sql_qs = QuotedString('"', escQuote='""')
    print(sql_qs.searchString('lsjdf "This is the quote with ""embedded"" quotes" sldjf'))
prints::
    [['This is the quote']]
    [['This is the "quote"']]
    [['This is the quote with "embedded" quotes']]

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  quoteChar,
  escChar = None,
  escQuote = None,
  multiline = False,
  unquoteResults = True,
  endQuoteChar = None,
  convertWhitespaceEscapes = True 
)

Member Function Documentation

◆ __str__()

def __str__ (   self)

Reimplemented from ParserElement.

◆ parseImpl()

def parseImpl (   self,
  instring,
  loc,
  doActions = True 
)

Reimplemented from ParserElement.

Field Documentation

◆ convertWhitespaceEscapes

convertWhitespaceEscapes

◆ endQuoteChar

endQuoteChar

◆ endQuoteCharLen

endQuoteCharLen

◆ errmsg

errmsg

◆ escChar

escChar

◆ escCharReplacePattern

escCharReplacePattern

◆ escQuote

escQuote

◆ firstQuoteChar

firstQuoteChar

◆ flags

flags

◆ mayIndexError

mayIndexError

◆ mayReturnEmpty

mayReturnEmpty

◆ name

name

◆ pattern

pattern

◆ quoteChar

quoteChar

◆ quoteCharLen

quoteCharLen

◆ re

re

◆ reString

reString

◆ strRepr

strRepr

◆ unquoteResults

unquoteResults

The documentation for this class was generated from the following file: