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

Public Member Functions

def __init__ (self, exprs, savelist=True)
 
def streamline (self)
 
def parseImpl (self, instring, loc, doActions=True)
 
def __str__ (self)
 
def checkRecursion (self, parseElementList)
 
- Public Member Functions inherited from ParseExpression
def append (self, other)
 
def leaveWhitespace (self)
 
def ignore (self, other)
 
def validate (self, validateTrace=None)
 
def copy (self)
 
- Public Member Functions inherited from ParserElement
def __init__ (self, savelist=False)
 
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 __iter__ (self)
 
def __getitem__ (self, key)
 
def __call__ (self, name=None)
 
def suppress (self)
 
def setWhitespaceChars (self, chars)
 
def parseWithTabs (self)
 
def setDebugActions (self, startAction, successAction, exceptionAction)
 
def setDebug (self, flag=True)
 
def __repr__ (self)
 
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, postParse=None, file=None)
 

Data Fields

 mayReturnEmpty
 
 skipWhitespace
 
 initExprGroups
 
 saveAsList
 
 opt1map
 
 optionals
 
 multioptionals
 
 multirequired
 
 required
 
 strRepr
 
- Data Fields inherited from ParseExpression
 exprs
 
 callPreparse
 
 strRepr
 
 skipWhitespace
 
 errmsg
 
- 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

Requires all given :class:`ParseExpression` s to be found, but in
any order. Expressions may be separated by whitespace.

May be constructed using the ``'&'`` operator.

Example::

    color = oneOf("RED ORANGE YELLOW GREEN BLUE PURPLE BLACK WHITE BROWN")
    shape_type = oneOf("SQUARE CIRCLE TRIANGLE STAR HEXAGON OCTAGON")
    integer = Word(nums)
    shape_attr = "shape:" + shape_type("shape")
    posn_attr = "posn:" + Group(integer("x") + ',' + integer("y"))("posn")
    color_attr = "color:" + color("color")
    size_attr = "size:" + integer("size")

    # use Each (using operator '&') to accept attributes in any order
    # (shape and posn are required, color and size are optional)
    shape_spec = shape_attr & posn_attr & Optional(color_attr) & Optional(size_attr)

    shape_spec.runTests('''
        shape: SQUARE color: BLACK posn: 100, 120
        shape: CIRCLE size: 50 color: BLUE posn: 50,80
        color:GREEN size:20 shape:TRIANGLE posn:20,40
        '''
        )

prints::

    shape: SQUARE color: BLACK posn: 100, 120
    ['shape:', 'SQUARE', 'color:', 'BLACK', 'posn:', ['100', ',', '120']]
    - color: BLACK
    - posn: ['100', ',', '120']
      - x: 100
      - y: 120
    - shape: SQUARE


    shape: CIRCLE size: 50 color: BLUE posn: 50,80
    ['shape:', 'CIRCLE', 'size:', '50', 'color:', 'BLUE', 'posn:', ['50', ',', '80']]
    - color: BLUE
    - posn: ['50', ',', '80']
      - x: 50
      - y: 80
    - shape: CIRCLE
    - size: 50


    color: GREEN size: 20 shape: TRIANGLE posn: 20,40
    ['color:', 'GREEN', 'size:', '20', 'shape:', 'TRIANGLE', 'posn:', ['20', ',', '40']]
    - color: GREEN
    - posn: ['20', ',', '40']
      - x: 20
      - y: 40
    - shape: TRIANGLE
    - size: 20

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  exprs,
  savelist = True 
)

Reimplemented from ParseExpression.

Member Function Documentation

◆ __str__()

def __str__ (   self)

Reimplemented from ParseExpression.

◆ checkRecursion()

def checkRecursion (   self,
  parseElementList 
)

Reimplemented from ParserElement.

◆ parseImpl()

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

Reimplemented from ParserElement.

◆ streamline()

def streamline (   self)

Reimplemented from ParseExpression.

Field Documentation

◆ initExprGroups

initExprGroups

◆ mayReturnEmpty

mayReturnEmpty

◆ multioptionals

multioptionals

◆ multirequired

multirequired

◆ opt1map

opt1map

◆ optionals

optionals

◆ required

required

◆ saveAsList

saveAsList

◆ skipWhitespace

skipWhitespace

◆ strRepr

strRepr

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