def delimitedList( expr, delim="<STR_LIT:U+002C>", combine=False ):

dlName = _ustr(expr)+"<STR_LIT>"+_ustr(delim)+"<STR_LIT:U+0020>"+_ustr(expr)+"<STR_LIT>"<EOL>if combine:<EOL><INDENT>return Combine( expr + ZeroOrMore( delim + expr ) ).setName(dlName)<EOL><DEDENT>else:<EOL><INDENT>return ( expr + ZeroOrMore( Suppress( delim ) + expr ) ).setName(dlName)<EOL><DEDENT>

Helper to define a delimited list of expressions - the delimiter defaults to ','.
       By default, the list elements and delimiters can have intervening whitespace, and
       comments, but this can be overridden by passing 'combine=True' in the constructor.
       If combine is set to True, the matching tokens are returned as a single token
       string, with the delimiters included; otherwise, the matching tokens are returned
       as a list of tokens, with the delimiters suppressed.


arrayExpr = Forward()<EOL>def countFieldParseAction(s,l,t):<EOL><INDENT>n = int(t[<NUM_LIT:0>])<EOL>arrayExpr << (n and Group(And([expr]*n)) or Group(empty))<EOL>return []<EOL><DEDENT>return ( Word(nums).setName("<STR_LIT>").setParseAction(countFieldParseAction, callDuringTry=True) + arrayExpr )<EOL>

Helper to define a counted list of expressions.
       This helper defines a pattern of the form::
           integer expr expr expr...
       where the leading integer tells how many expr expressions follow.
       The matched tokens returns the array of expr tokens as a list - the leading count token is suppressed.


rep = Forward()<EOL>def copyTokenToRepeater(s,l,t):<EOL><INDENT>if t:<EOL><INDENT>if len(t) == <NUM_LIT:1>:<EOL><INDENT>rep << t[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>tflat = _flatten(t.asList())<EOL>rep << And( [ Literal(tt) for tt in tflat ] )<EOL><DEDENT><DEDENT>else:<EOL><INDENT>rep << Empty()<EOL><DEDENT><DEDENT>expr.addParseAction(copyTokenToRepeater, callDuringTry=True)<EOL>return rep<EOL>

Helper to define an expression that is indirectly defined from
       the tokens matched in a previous expression, that is, it looks
       for a 'repeat' of a previous expression.  For example::
           first = Word(nums)
           second = matchPreviousLiteral(first)
           matchExpr = first + ":" + second
       will match "1:1", but not "1:2".  Because this matches a
       previous literal, will also match the leading "1:1" in "1:10".
       If this is not desired, use matchPreviousExpr.
       Do *not* use with packrat parsing enabled.


rep = Forward()<EOL>e2 = expr.copy()<EOL>rep << e2<EOL>def copyTokenToRepeater(s,l,t):<EOL><INDENT>matchTokens = _flatten(t.asList())<EOL>def mustMatchTheseTokens(s,l,t):<EOL><INDENT>theseTokens = _flatten(t.asList())<EOL>if  theseTokens != matchTokens:<EOL><INDENT>raise ParseException("<STR_LIT>",<NUM_LIT:0>,"<STR_LIT>")<EOL><DEDENT><DEDENT>rep.setParseAction( mustMatchTheseTokens, callDuringTry=True )<EOL><DEDENT>expr.addParseAction(copyTokenToRepeater, callDuringTry=True)<EOL>return rep<EOL>

Helper to define an expression that is indirectly defined from
       the tokens matched in a previous expression, that is, it looks
       for a 'repeat' of a previous expression.  For example::
           first = Word(nums)
           second = matchPreviousExpr(first)
           matchExpr = first + ":" + second
       will match "1:1", but not "1:2".  Because this matches by
       expressions, will *not* match the leading "1:1" in "1:10";
       the expressions are evaluated first, and then compared, so
       "1" is compared with "10".
       Do *not* use with packrat parsing enabled.


def oneOf( strs, caseless=False, useRegex=True ):

if caseless:<EOL><INDENT>isequal = ( lambda a,b: a.upper() == b.upper() )<EOL>masks = ( lambda a,b: b.upper().startswith(a.upper()) )<EOL>parseElementClass = CaselessLiteral<EOL><DEDENT>else:<EOL><INDENT>isequal = ( lambda a,b: a == b )<EOL>masks = ( lambda a,b: b.startswith(a) )<EOL>parseElementClass = Literal<EOL><DEDENT>if isinstance(strs,(list,tuple)):<EOL><INDENT>symbols = strs[:]<EOL><DEDENT>elif isinstance(strs,str):<EOL><INDENT>symbols = strs.split()<EOL><DEDENT>else:<EOL><INDENT>warnings.warn("<STR_LIT>",<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL><DEDENT>i = <NUM_LIT:0><EOL>while i < len(symbols)-<NUM_LIT:1>:<EOL><INDENT>cur = symbols[i]<EOL>for j,other in enumerate(symbols[i+<NUM_LIT:1>:]):<EOL><INDENT>if ( isequal(other, cur) ):<EOL><INDENT>del symbols[i+j+<NUM_LIT:1>]<EOL>break<EOL><DEDENT>elif ( masks(cur, other) ):<EOL><INDENT>del symbols[i+j+<NUM_LIT:1>]<EOL>symbols.insert(i,other)<EOL>cur = other<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>i += <NUM_LIT:1><EOL><DEDENT><DEDENT>if not caseless and useRegex:<EOL><INDENT>try:<EOL><INDENT>if len(symbols)==len("<STR_LIT>".join(symbols)):<EOL><INDENT>return Regex( "<STR_LIT>" % "<STR_LIT>".join( [ _escapeRegexRangeChars(sym) for sym in symbols] ) )<EOL><DEDENT>else:<EOL><INDENT>return Regex( "<STR_LIT:|>".join( [ re.escape(sym) for sym in symbols] ) )<EOL><DEDENT><DEDENT>except:<EOL><INDENT>warnings.warn("<STR_LIT>",<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL><DEDENT><DEDENT>return MatchFirst( [ parseElementClass(sym) for sym in symbols ] )<EOL>

Helper to quickly define a set of alternative Literals, and makes sure to do
       longest-first testing when there is a conflict, regardless of the input order,
       but returns a MatchFirst for best performance.

       Parameters:
        - strs - a string of space-delimited literals, or a list of string literals
        - caseless - (default=False) - treat all literals as caseless
        - useRegex - (default=True) - as an optimization, will generate a Regex
          object; otherwise, will generate a MatchFirst object (if caseless=True, or
          if creating a Regex raises an exception)


return Dict( ZeroOrMore( Group ( key + value ) ) )<EOL>

Helper to easily and clearly define a dictionary by specifying the respective patterns
       for the key and value.  Takes care of defining the Dict, ZeroOrMore, and Group tokens
       in the proper order.  The key pattern can include delimiting markers or punctuation,
       as long as they are suppressed, thereby leaving the significant key text.  The value
       pattern can include named results, so that the Dict results can include named token
       fields.


try:<EOL><INDENT>return "<STR_LIT>".join([_expanded(part) for part in _reBracketExpr.parseString(s).body])<EOL><DEDENT>except:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>

r"""Helper to easily define string ranges for use in Word construction.  Borrows
       syntax from regexp '[]' string range definitions::
          srange("[0-9]")   -> "0123456789"
          srange("[a-z]")   -> "abcdefghijklmnopqrstuvwxyz"
          srange("[a-z$_]") -> "abcdefghijklmnopqrstuvwxyz$_"
       The input string must be enclosed in []'s, and the returned string is the expanded
       character set joined into a single string.
       The values enclosed in the []'s may be::
          a single character
          an escaped character with a leading backslash (such as \- or \])
          an escaped hex character with a leading '\0x' (\0x21, which is a '!' character)
          an escaped octal character with a leading '\0' (\041, which is a '!' character)
          a range of any of the above, separated by a dash ('a-z', etc.)
          any combination of the above ('aeiouy', 'a-zA-Z0-9_$', etc.)


def verifyCol(strg,locn,toks):<EOL><INDENT>if col(locn,strg) != n:<EOL><INDENT>raise ParseException(strg,locn,"<STR_LIT>" % n)<EOL><DEDENT><DEDENT>return verifyCol<EOL>

Helper method for defining parse actions that require matching at a specific
       column in the input text.


def _replFunc(*args):<EOL><INDENT>return [replStr]<EOL><DEDENT>return _replFunc<EOL>

Helper method for common parse actions that simply return a literal value.  Especially
       useful when used with transformString().


return t[<NUM_LIT:0>][<NUM_LIT:1>:-<NUM_LIT:1>]<EOL>

Helper parse action for removing quotation marks from parsed quoted strings.
       To use, add this parse action to quoted string using::
         quotedString.setParseAction( removeQuotes )


return [ tt.upper() for tt in map(_ustr,t) ]<EOL>

Helper parse action to convert tokens to upper case.


return [ tt.lower() for tt in map(_ustr,t) ]<EOL>

Helper parse action to convert tokens to lower case.


try:<EOL><INDENT>endloc = getTokensEndLoc()<EOL><DEDENT>except ParseException:<EOL><INDENT>raise ParseFatalException("<STR_LIT>")<EOL><DEDENT>del t[:]<EOL>t += ParseResults(s[startLoc:endloc])<EOL>return t<EOL>

Helper parse action to preserve original parsed text,
       overriding any nested parse actions.


import inspect<EOL>fstack = inspect.stack()<EOL>try:<EOL><INDENT>for f in fstack[<NUM_LIT:2>:]:<EOL><INDENT>if f[<NUM_LIT:3>] == "<STR_LIT>":<EOL><INDENT>endloc = f[<NUM_LIT:0>].f_locals["<STR_LIT>"]<EOL>return endloc<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ParseFatalException("<STR_LIT>")<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>del fstack<EOL><DEDENT>

Method to be called from within a parse action to determine the end
       location of the parsed tokens.


if isinstance(tagStr,str):<EOL><INDENT>resname = tagStr<EOL>tagStr = Keyword(tagStr, caseless=not xml)<EOL><DEDENT>else:<EOL><INDENT>resname = tagStr.name<EOL><DEDENT>tagAttrName = Word(alphas,alphanums+"<STR_LIT>")<EOL>if (xml):<EOL><INDENT>tagAttrValue = dblQuotedString.copy().setParseAction( removeQuotes )<EOL>openTag = Suppress("<STR_LIT:<>") + tagStr +Dict(ZeroOrMore(Group( tagAttrName + Suppress("<STR_LIT:=>") + tagAttrValue ))) +Optional("<STR_LIT:/>",default=[False]).setResultsName("<STR_LIT>").setParseAction(lambda s,l,t:t[<NUM_LIT:0>]=='<STR_LIT:/>') + Suppress("<STR_LIT:>>")<EOL><DEDENT>else:<EOL><INDENT>printablesLessRAbrack = "<STR_LIT>".join( [ c for c in printables if c not in "<STR_LIT:>>" ] )<EOL>tagAttrValue = quotedString.copy().setParseAction( removeQuotes ) | Word(printablesLessRAbrack)<EOL>openTag = Suppress("<STR_LIT:<>") + tagStr +Dict(ZeroOrMore(Group( tagAttrName.setParseAction(downcaseTokens) +Optional( Suppress("<STR_LIT:=>") + tagAttrValue ) ))) +Optional("<STR_LIT:/>",default=[False]).setResultsName("<STR_LIT>").setParseAction(lambda s,l,t:t[<NUM_LIT:0>]=='<STR_LIT:/>') + Suppress("<STR_LIT:>>")<EOL><DEDENT>closeTag = Combine(_L("<STR_LIT>") + tagStr + "<STR_LIT:>>")<EOL>openTag = openTag.setResultsName("<STR_LIT:start>"+"<STR_LIT>".join(resname.replace("<STR_LIT::>","<STR_LIT:U+0020>").title().split())).setName("<STR_LIT>" % tagStr)<EOL>closeTag = closeTag.setResultsName("<STR_LIT:end>"+"<STR_LIT>".join(resname.replace("<STR_LIT::>","<STR_LIT:U+0020>").title().split())).setName("<STR_LIT>" % tagStr)<EOL>return openTag, closeTag<EOL>

Internal helper to construct opening and closing tag expressions, given a tag name


return _makeTags( tagStr, False )<EOL>

Helper to construct opening and closing tag expressions for HTML, given a tag name


return _makeTags( tagStr, True )<EOL>

Helper to construct opening and closing tag expressions for XML, given a tag name


if args:<EOL><INDENT>attrs = args[:]<EOL><DEDENT>else:<EOL><INDENT>attrs = list(attrDict.items())<EOL><DEDENT>attrs = [(k,v) for k,v in attrs]<EOL>def pa(s,l,tokens):<EOL><INDENT>for attrName,attrValue in attrs:<EOL><INDENT>if attrName not in tokens:<EOL><INDENT>raise ParseException(s,l,"<STR_LIT>" + attrName)<EOL><DEDENT>if attrValue != withAttribute.ANY_VALUE and tokens[attrName] != attrValue:<EOL><INDENT>raise ParseException(s,l,"<STR_LIT>" %<EOL>(attrName, tokens[attrName], attrValue))<EOL><DEDENT><DEDENT><DEDENT>return pa<EOL>

Helper to create a validating parse action to be used with start tags created
       with makeXMLTags or makeHTMLTags. Use withAttribute to qualify a starting tag
       with a required attribute value, to avoid false matches on common tags such as
       <TD> or <DIV>.

       Call withAttribute with a series of attribute names and values. Specify the list
       of filter attributes names and values as:
        - keyword arguments, as in (class="Customer",align="right"), or
        - a list of name-value tuples, as in ( ("ns1:class", "Customer"), ("ns2:align","right") )
       For attribute names with a namespace prefix, you must use the second form.  Attribute
       names are matched insensitive to upper/lower case.

       To verify that the attribute exists, but without specifying a value, pass
       withAttribute.ANY_VALUE as the value.


def operatorPrecedence( baseExpr, opList ):

ret = Forward()<EOL>lastExpr = baseExpr | ( Suppress('<STR_LIT:(>') + ret + Suppress('<STR_LIT:)>') )<EOL>for i,operDef in enumerate(opList):<EOL><INDENT>opExpr,arity,rightLeftAssoc,pa = (operDef + (None,))[:<NUM_LIT:4>]<EOL>if arity == <NUM_LIT:3>:<EOL><INDENT>if opExpr is None or len(opExpr) != <NUM_LIT:2>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>opExpr1, opExpr2 = opExpr<EOL><DEDENT>thisExpr = Forward()<EOL>if rightLeftAssoc == opAssoc.LEFT:<EOL><INDENT>if arity == <NUM_LIT:1>:<EOL><INDENT>matchExpr = FollowedBy(lastExpr + opExpr) + Group( lastExpr + OneOrMore( opExpr ) )<EOL><DEDENT>elif arity == <NUM_LIT:2>:<EOL><INDENT>if opExpr is not None:<EOL><INDENT>matchExpr = FollowedBy(lastExpr + opExpr + lastExpr) + Group( lastExpr + OneOrMore( opExpr + lastExpr ) )<EOL><DEDENT>else:<EOL><INDENT>matchExpr = FollowedBy(lastExpr+lastExpr) + Group( lastExpr + OneOrMore(lastExpr) )<EOL><DEDENT><DEDENT>elif arity == <NUM_LIT:3>:<EOL><INDENT>matchExpr = FollowedBy(lastExpr + opExpr1 + lastExpr + opExpr2 + lastExpr) +Group( lastExpr + opExpr1 + lastExpr + opExpr2 + lastExpr )<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>elif rightLeftAssoc == opAssoc.RIGHT:<EOL><INDENT>if arity == <NUM_LIT:1>:<EOL><INDENT>if not isinstance(opExpr, Optional):<EOL><INDENT>opExpr = Optional(opExpr)<EOL><DEDENT>matchExpr = FollowedBy(opExpr.expr + thisExpr) + Group( opExpr + thisExpr )<EOL><DEDENT>elif arity == <NUM_LIT:2>:<EOL><INDENT>if opExpr is not None:<EOL><INDENT>matchExpr = FollowedBy(lastExpr + opExpr + thisExpr) + Group( lastExpr + OneOrMore( opExpr + thisExpr ) )<EOL><DEDENT>else:<EOL><INDENT>matchExpr = FollowedBy(lastExpr + thisExpr) + Group( lastExpr + OneOrMore( thisExpr ) )<EOL><DEDENT><DEDENT>elif arity == <NUM_LIT:3>:<EOL><INDENT>matchExpr = FollowedBy(lastExpr + opExpr1 + thisExpr + opExpr2 + thisExpr) +Group( lastExpr + opExpr1 + thisExpr + opExpr2 + thisExpr )<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if pa:<EOL><INDENT>matchExpr.setParseAction( pa )<EOL><DEDENT>thisExpr << ( matchExpr | lastExpr )<EOL>lastExpr = thisExpr<EOL><DEDENT>ret << lastExpr<EOL>return ret<EOL>

Helper method for constructing grammars of expressions made up of
       operators working in a precedence hierarchy.  Operators may be unary or
       binary, left- or right-associative.  Parse actions can also be attached
       to operator expressions.

       Parameters:
        - baseExpr - expression representing the most basic element for the nested
        - opList - list of tuples, one for each operator precedence level in the
          expression grammar; each tuple is of the form
          (opExpr, numTerms, rightLeftAssoc, parseAction), where:
           - opExpr is the pyparsing expression for the operator;
              may also be a string, which will be converted to a Literal;
              if numTerms is 3, opExpr is a tuple of two expressions, for the
              two operators separating the 3 terms
           - numTerms is the number of terms for this operator (must
              be 1, 2, or 3)
           - rightLeftAssoc is the indicator whether the operator is
              right or left associative, using the pyparsing-defined
              constants opAssoc.RIGHT and opAssoc.LEFT.
           - parseAction is the parse action to be associated with
              expressions matching this operator expression (the
              parse action tuple member may be omitted)


def nestedExpr(opener="<STR_LIT:(>", closer="<STR_LIT:)>", content=None, ignoreExpr=quotedString):

if opener == closer:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if content is None:<EOL><INDENT>if isinstance(opener,str) and isinstance(closer,str):<EOL><INDENT>if ignoreExpr is not None:<EOL><INDENT>content = (Combine(OneOrMore(~ignoreExpr +<EOL>CharsNotIn(opener+closer+ParserElement.DEFAULT_WHITE_CHARS,exact=<NUM_LIT:1>))<EOL>).setParseAction(lambda t:t[<NUM_LIT:0>].strip()))<EOL><DEDENT>else:<EOL><INDENT>content = (empty+CharsNotIn(opener+closer+ParserElement.DEFAULT_WHITE_CHARS).setParseAction(lambda t:t[<NUM_LIT:0>].strip()))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT><DEDENT>ret = Forward()<EOL>if ignoreExpr is not None:<EOL><INDENT>ret << Group( Suppress(opener) + ZeroOrMore( ignoreExpr | ret | content ) + Suppress(closer) )<EOL><DEDENT>else:<EOL><INDENT>ret << Group( Suppress(opener) + ZeroOrMore( ret | content )  + Suppress(closer) )<EOL><DEDENT>return ret<EOL>

Helper method for defining nested lists enclosed in opening and closing
       delimiters ("(" and ")" are the default).

       Parameters:
        - opener - opening character for a nested list (default="("); can also be a pyparsing expression
        - closer - closing character for a nested list (default=")"); can also be a pyparsing expression
        - content - expression for items within the nested lists (default=None)
        - ignoreExpr - expression for ignoring opening and closing delimiters (default=quotedString)

       If an expression is not provided for the content argument, the nested
       expression will capture all whitespace-delimited content between delimiters
       as a list of separate values.

       Use the ignoreExpr argument to define expressions that may contain
       opening or closing characters that should not be treated as opening
       or closing characters for nesting, such as quotedString or a comment
       expression.  Specify multiple expressions using an Or or MatchFirst.
       The default is quotedString, but if no expressions are to be ignored,
       then pass None for this argument.


def indentedBlock(blockStatementExpr, indentStack, indent=True):

def checkPeerIndent(s,l,t):<EOL><INDENT>if l >= len(s): return<EOL>curCol = col(l,s)<EOL>if curCol != indentStack[-<NUM_LIT:1>]:<EOL><INDENT>if curCol > indentStack[-<NUM_LIT:1>]:<EOL><INDENT>raise ParseFatalException(s,l,"<STR_LIT>")<EOL><DEDENT>raise ParseException(s,l,"<STR_LIT>")<EOL><DEDENT><DEDENT>def checkSubIndent(s,l,t):<EOL><INDENT>curCol = col(l,s)<EOL>if curCol > indentStack[-<NUM_LIT:1>]:<EOL><INDENT>indentStack.append( curCol )<EOL><DEDENT>else:<EOL><INDENT>raise ParseException(s,l,"<STR_LIT>")<EOL><DEDENT><DEDENT>def checkUnindent(s,l,t):<EOL><INDENT>if l >= len(s): return<EOL>curCol = col(l,s)<EOL>if not(indentStack and curCol < indentStack[-<NUM_LIT:1>] and curCol <= indentStack[-<NUM_LIT:2>]):<EOL><INDENT>raise ParseException(s,l,"<STR_LIT>")<EOL><DEDENT>indentStack.pop()<EOL><DEDENT>NL = OneOrMore(LineEnd().setWhitespaceChars("<STR_LIT>").suppress())<EOL>INDENT = Empty() + Empty().setParseAction(checkSubIndent)<EOL>PEER   = Empty().setParseAction(checkPeerIndent)<EOL>UNDENT = Empty().setParseAction(checkUnindent)<EOL>if indent:<EOL><INDENT>smExpr = Group( Optional(NL) +<EOL>FollowedBy(blockStatementExpr) +<EOL>INDENT + (OneOrMore( PEER + Group(blockStatementExpr) + Optional(NL) )) + UNDENT)<EOL><DEDENT>else:<EOL><INDENT>smExpr = Group( Optional(NL) +<EOL>(OneOrMore( PEER + Group(blockStatementExpr) + Optional(NL) )) )<EOL><DEDENT>blockStatementExpr.ignore("<STR_LIT:\\>" + LineEnd())<EOL>return smExpr<EOL>

Helper method for defining space-delimited indentation blocks, such as
       those used to define block statements in Python source code.

       Parameters:
        - blockStatementExpr - expression defining syntax of statement that
            is repeated within the indented block
        - indentStack - list created by caller to manage indentation stack
            (multiple statementWithIndentedBlock expressions within a single grammar
            should share a common indentStack)
        - indent - boolean indicating whether block must be indented beyond the
            the current level; set to False for block of left-most statements
            (default=True)

       A valid block must contain at least one blockStatement.


if( aname == "<STR_LIT>" ):<EOL><INDENT>return lineno( self.loc, self.pstr )<EOL><DEDENT>elif( aname in ("<STR_LIT>", "<STR_LIT>") ):<EOL><INDENT>return col( self.loc, self.pstr )<EOL><DEDENT>elif( aname == "<STR_LIT>" ):<EOL><INDENT>return line( self.loc, self.pstr )<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError(aname)<EOL><DEDENT>

supported attributes by name are:
            - lineno - returns the line number of the exception text
            - col - returns the column number of the exception text
            - line - returns the line containing the exception text


def markInputline( self, markerString = "<STR_LIT>" ):

line_str = self.line<EOL>line_column = self.column - <NUM_LIT:1><EOL>if markerString:<EOL><INDENT>line_str = "<STR_LIT>".join( [line_str[:line_column],<EOL>markerString, line_str[line_column:]])<EOL><DEDENT>return line_str.strip()<EOL>

Extracts the exception line from the input string, and marks
           the location of the exception with a special symbol.


return list(self.__tokdict.keys())<EOL>


ret = self[index]<EOL>del self[index]<EOL>return ret<EOL>

Removes and returns item at specified index (default=last).
           Will work with either numeric indices or dict-key indicies.


if key in self:<EOL><INDENT>return self[key]<EOL><DEDENT>else:<EOL><INDENT>return defaultValue<EOL><DEDENT>

Returns named result matching the given key, or if there is no
           such name, then returns the given defaultValue or None if no
           defaultValue is specified.


return [(k,self[k]) for k in self.__tokdict]<EOL>

Returns all named result keys and values as a list of tuples.


return [ v[-<NUM_LIT:1>][<NUM_LIT:0>] for v in list(self.__tokdict.values()) ]<EOL>


out = []<EOL>for res in self.__toklist:<EOL><INDENT>if isinstance(res,ParseResults):<EOL><INDENT>out.append( res.asList() )<EOL><DEDENT>else:<EOL><INDENT>out.append( res )<EOL><DEDENT><DEDENT>return out<EOL>

Returns the parse results as a nested list of matching tokens, all converted to strings.


return dict( list(self.items()) )<EOL>

Returns the named parse results as dictionary.


ret = ParseResults( self.__toklist )<EOL>ret.__tokdict = self.__tokdict.copy()<EOL>ret.__parent = self.__parent<EOL>ret.__accumNames.update( self.__accumNames )<EOL>ret.__name = self.__name<EOL>return ret<EOL>

Returns a new copy of a ParseResults object.


def asXML( self, doctag=None, namedItemsOnly=False, indent="<STR_LIT>", formatted=True ):

nl = "<STR_LIT:\n>"<EOL>out = []<EOL>namedItems = dict( [ (v[<NUM_LIT:1>],k) for (k,vlist) in list(self.__tokdict.items())<EOL>for v in vlist ] )<EOL>nextLevelIndent = indent + "<STR_LIT:U+0020>"<EOL>if not formatted:<EOL><INDENT>indent = "<STR_LIT>"<EOL>nextLevelIndent = "<STR_LIT>"<EOL>nl = "<STR_LIT>"<EOL><DEDENT>selfTag = None<EOL>if doctag is not None:<EOL><INDENT>selfTag = doctag<EOL><DEDENT>else:<EOL><INDENT>if self.__name:<EOL><INDENT>selfTag = self.__name<EOL><DEDENT><DEDENT>if not selfTag:<EOL><INDENT>if namedItemsOnly:<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>selfTag = "<STR_LIT>"<EOL><DEDENT><DEDENT>out += [ nl, indent, "<STR_LIT:<>", selfTag, "<STR_LIT:>>" ]<EOL>worklist = self.__toklist<EOL>for i,res in enumerate(worklist):<EOL><INDENT>if isinstance(res,ParseResults):<EOL><INDENT>if i in namedItems:<EOL><INDENT>out += [ res.asXML(namedItems[i],<EOL>namedItemsOnly and doctag is None,<EOL>nextLevelIndent,<EOL>formatted)]<EOL><DEDENT>else:<EOL><INDENT>out += [ res.asXML(None,<EOL>namedItemsOnly and doctag is None,<EOL>nextLevelIndent,<EOL>formatted)]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>resTag = None<EOL>if i in namedItems:<EOL><INDENT>resTag = namedItems[i]<EOL><DEDENT>if not resTag:<EOL><INDENT>if namedItemsOnly:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>resTag = "<STR_LIT>"<EOL><DEDENT><DEDENT>xmlBodyText = xml.sax.saxutils.escape(_ustr(res))<EOL>out += [ nl, nextLevelIndent, "<STR_LIT:<>", resTag, "<STR_LIT:>>",<EOL>xmlBodyText,<EOL>"<STR_LIT>", resTag, "<STR_LIT:>>" ]<EOL><DEDENT><DEDENT>out += [ nl, indent, "<STR_LIT>", selfTag, "<STR_LIT:>>" ]<EOL>return "<STR_LIT>".join(out)<EOL>

Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.


if self.__name:<EOL><INDENT>return self.__name<EOL><DEDENT>elif self.__parent:<EOL><INDENT>par = self.__parent()<EOL>if par:<EOL><INDENT>return par.__lookup(self)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>elif (len(self) == <NUM_LIT:1> and<EOL>len(self.__tokdict) == <NUM_LIT:1> and<EOL>list(self.__tokdict.values())[<NUM_LIT:0>][<NUM_LIT:0>][<NUM_LIT:1>] in (<NUM_LIT:0>,-<NUM_LIT:1>)):<EOL><INDENT>return list(self.__tokdict.keys())[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Returns the results name for this token expression.


out = []<EOL>out.append( indent+_ustr(self.asList()) )<EOL>keys = list(self.items())<EOL>keys.sort()<EOL>for k,v in keys:<EOL><INDENT>if out:<EOL><INDENT>out.append('<STR_LIT:\n>')<EOL><DEDENT>out.append( "<STR_LIT>" % (indent,('<STR_LIT:U+0020>'*depth), k) )<EOL>if isinstance(v,ParseResults):<EOL><INDENT>if list(v.keys()):<EOL><INDENT>out.append( v.dump(indent,depth+<NUM_LIT:1>) )<EOL><DEDENT>else:<EOL><INDENT>out.append(_ustr(v))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>out.append(_ustr(v))<EOL><DEDENT><DEDENT>return "<STR_LIT>".join(out)<EOL>

Diagnostic method for listing out the contents of a ParseResults.
           Accepts an optional indent argument so that this string can be embedded
           in a nested display of other data.


ParserElement.DEFAULT_WHITE_CHARS = chars<EOL>


cpy = copy.copy( self )<EOL>cpy.parseAction = self.parseAction[:]<EOL>cpy.ignoreExprs = self.ignoreExprs[:]<EOL>if self.copyDefaultWhiteChars:<EOL><INDENT>cpy.whiteChars = ParserElement.DEFAULT_WHITE_CHARS<EOL><DEDENT>return cpy<EOL>

Make a copy of this ParserElement.  Useful for defining different parse actions
           for the same parsing pattern, using copies of the original parse element.


self.name = name<EOL>self.errmsg = "<STR_LIT>" + self.name<EOL>if hasattr(self,"<STR_LIT>"):<EOL><INDENT>self.exception.msg = self.errmsg<EOL><DEDENT>return self<EOL>

Define name for this expression, for use in debugging.


def setResultsName( self, name, listAllMatches=False ):

newself = self.copy()<EOL>newself.resultsName = name<EOL>newself.modalResults = not listAllMatches<EOL>return newself<EOL>

Define name for referencing matching tokens as a nested attribute
           of the returned parse results.
           NOTE: this returns a *copy* of the original ParserElement object;
           this is so that the client can define a basic element, such as an
           integer, and reference it in multiple places with different names.


if breakFlag:<EOL><INDENT>_parseMethod = self._parse<EOL>def breaker(instring, loc, doActions=True, callPreParse=True):<EOL><INDENT>import pdb<EOL>pdb.set_trace()<EOL>_parseMethod( instring, loc, doActions, callPreParse )<EOL><DEDENT>breaker._originalParseMethod = _parseMethod<EOL>self._parse = breaker<EOL><DEDENT>else:<EOL><INDENT>if hasattr(self._parse,"<STR_LIT>"):<EOL><INDENT>self._parse = self._parse._originalParseMethod<EOL><DEDENT><DEDENT>return self<EOL>

Method to invoke the Python pdb debugger when this element is
           about to be parsed. Set breakFlag to True to enable, False to
           disable.


STAR_ARGS = <NUM_LIT:4><EOL>try:<EOL><INDENT>restore = None<EOL>if isinstance(f,type):<EOL><INDENT>restore = f<EOL>f = f.__init__<EOL><DEDENT>if not _PY3K:<EOL><INDENT>codeObj = f.__code__<EOL><DEDENT>else:<EOL><INDENT>codeObj = f.code<EOL><DEDENT>if codeObj.co_flags & STAR_ARGS:<EOL><INDENT>return f<EOL><DEDENT>numargs = codeObj.co_argcount<EOL>if not _PY3K:<EOL><INDENT>if hasattr(f,"<STR_LIT>"):<EOL><INDENT>numargs -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>if hasattr(f,"<STR_LIT>"):<EOL><INDENT>numargs -= <NUM_LIT:1><EOL><DEDENT><DEDENT>if restore:<EOL><INDENT>f = restore<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>try:<EOL><INDENT>if not _PY3K:<EOL><INDENT>call_im_func_code = f.__call__.__func__.__code__<EOL><DEDENT>else:<EOL><INDENT>call_im_func_code = f.__code__<EOL><DEDENT>if call_im_func_code.co_flags & STAR_ARGS:<EOL><INDENT>return f<EOL><DEDENT>numargs = call_im_func_code.co_argcount<EOL>if not _PY3K:<EOL><INDENT>if hasattr(f.__call__,"<STR_LIT>"):<EOL><INDENT>numargs -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>if hasattr(f.__call__,"<STR_LIT>"):<EOL><INDENT>numargs -= <NUM_LIT:0><EOL><DEDENT><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>if not _PY3K:<EOL><INDENT>call_func_code = f.__call__.__code__<EOL><DEDENT>else:<EOL><INDENT>call_func_code = f.__call__.__code__<EOL><DEDENT>if call_func_code.co_flags & STAR_ARGS:<EOL><INDENT>return f<EOL><DEDENT>numargs = call_func_code.co_argcount<EOL>if not _PY3K:<EOL><INDENT>if hasattr(f.__call__,"<STR_LIT>"):<EOL><INDENT>numargs -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>if hasattr(f.__call__,"<STR_LIT>"):<EOL><INDENT>numargs -= <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT><DEDENT>if numargs == <NUM_LIT:3>:<EOL><INDENT>return f<EOL><DEDENT>else:<EOL><INDENT>if numargs > <NUM_LIT:3>:<EOL><INDENT>def tmp(s,l,t):<EOL><INDENT>return f(f.__call__.__self__, s,l,t)<EOL><DEDENT><DEDENT>if numargs == <NUM_LIT:2>:<EOL><INDENT>def tmp(s,l,t):<EOL><INDENT>return f(l,t)<EOL><DEDENT><DEDENT>elif numargs == <NUM_LIT:1>:<EOL><INDENT>def tmp(s,l,t):<EOL><INDENT>return f(t)<EOL><DEDENT><DEDENT>else: <EOL><INDENT>def tmp(s,l,t):<EOL><INDENT>return f()<EOL><DEDENT><DEDENT>try:<EOL><INDENT>tmp.__name__ = f.__name__<EOL><DEDENT>except (AttributeError,TypeError):<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>tmp.__doc__ = f.__doc__<EOL><DEDENT>except (AttributeError,TypeError):<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>tmp.__dict__.update(f.__dict__)<EOL><DEDENT>except (AttributeError,TypeError):<EOL><INDENT>pass<EOL><DEDENT>return tmp<EOL><DEDENT>

Internal method used to decorate parse actions that take fewer than 3 arguments,
           so that all parse actions can be called as f(s,l,t).


def setParseAction( self, *fns, **kwargs ):

self.parseAction = list(map(self._normalizeParseActionArgs, list(fns)))<EOL>self.callDuringTry = ("<STR_LIT>" in kwargs and kwargs["<STR_LIT>"])<EOL>return self<EOL>

Define action to perform when successfully matching parse element definition.
           Parse action fn is a callable method with 0-3 arguments, called as fn(s,loc,toks),
           fn(loc,toks), fn(toks), or just fn(), where:
            - s   = the original string being parsed (see note below)
            - loc = the location of the matching substring
            - toks = a list of the matched tokens, packaged as a ParseResults object
           If the functions in fns modify the tokens, they can return them as the return
           value from fn, and the modified list of tokens will replace the original.
           Otherwise, fn does not need to return any value.

           Note: the default parsing behavior is to expand tabs in the input string
           before starting the parsing process.  See L{I{parseString}<parseString>} for more information
           on parsing strings containing <TAB>s, and suggested methods to maintain a
           consistent view of the parsed string, the parse location, and line and column
           positions within the parsed string.


def addParseAction( self, *fns, **kwargs ):

self.parseAction += list(map(self._normalizeParseActionArgs, list(fns)))<EOL>self.callDuringTry = self.callDuringTry or ("<STR_LIT>" in kwargs and kwargs["<STR_LIT>"])<EOL>return self<EOL>

Add parse action to expression's list of parse actions. See L{I{setParseAction}<setParseAction>}.


self.failAction = fn<EOL>return self<EOL>

Define action to perform if parsing fails at this expression.
           Fail acton fn is a callable function that takes the arguments
           fn(s,loc,expr,err) where:
            - s = string being parsed
            - loc = location where expression match was attempted and failed
            - expr = the parse expression that failed
            - err = the exception thrown
           The function returns no value.  It may throw ParseFatalException
           if it is desired to stop parsing immediately.


if not ParserElement._packratEnabled:<EOL><INDENT>ParserElement._packratEnabled = True<EOL>ParserElement._parse = ParserElement._parseCache<EOL><DEDENT>

Enables "packrat" parsing, which adds memoizing to the parsing logic.
           Repeated parse attempts at the same string location (which happens
           often in many complex grammars) can immediately return a cached value,
           instead of re-executing parsing/validating code.  Memoizing is done of
           both valid results and parsing exceptions.

           This speedup may break existing programs that use parse actions that
           have side-effects.  For this reason, packrat parsing is disabled when
           you first import pyparsing.  To activate the packrat feature, your
           program must call the class method ParserElement.enablePackrat().  If
           your program uses psyco to "compile as you go", you must call
           enablePackrat before calling psyco.full().  If you do not do this,
           Python will crash.  For best results, call enablePackrat() immediately
           after importing pyparsing.


def parseString( self, instring, parseAll=False ):

ParserElement.resetCache()<EOL>if not self.streamlined:<EOL><INDENT>self.streamline()<EOL><DEDENT>for e in self.ignoreExprs:<EOL><INDENT>e.streamline()<EOL><DEDENT>if not self.keepTabs:<EOL><INDENT>instring = instring.expandtabs()<EOL><DEDENT>loc, tokens = self._parse( instring, <NUM_LIT:0> )<EOL>if parseAll:<EOL><INDENT>StringEnd()._parse( instring, loc )<EOL><DEDENT>return tokens<EOL>

Execute the parse expression with the given string.
           This is the main interface to the client code, once the complete
           expression has been built.

           If you want the grammar to require that the entire input string be
           successfully parsed, then set parseAll to True (equivalent to ending
           the grammar with StringEnd()).

           Note: parseString implicitly calls expandtabs() on the input string,
           in order to report proper column numbers in parse actions.
           If the input string contains tabs and
           the grammar uses parse actions that use the loc argument to index into the
           string being parsed, you can ensure you have a consistent view of the input
           string by:
            - calling parseWithTabs on your grammar before calling parseString
              (see L{I{parseWithTabs}<parseWithTabs>})
            - define your parse action using the full (s,loc,toks) signature, and
              reference the input string using the parse action's s argument
            - explictly expand the tabs in your input string before calling
              parseString


def scanString( self, instring, maxMatches=_MAX_INT ):

if not self.streamlined:<EOL><INDENT>self.streamline()<EOL><DEDENT>for e in self.ignoreExprs:<EOL><INDENT>e.streamline()<EOL><DEDENT>if not self.keepTabs:<EOL><INDENT>instring = _ustr(instring).expandtabs()<EOL><DEDENT>instrlen = len(instring)<EOL>loc = <NUM_LIT:0><EOL>preparseFn = self.preParse<EOL>parseFn = self._parse<EOL>ParserElement.resetCache()<EOL>matches = <NUM_LIT:0><EOL>while loc <= instrlen and matches < maxMatches:<EOL><INDENT>try:<EOL><INDENT>preloc = preparseFn( instring, loc )<EOL>nextLoc,tokens = parseFn( instring, preloc, callPreParse=False )<EOL><DEDENT>except ParseException:<EOL><INDENT>loc = preloc+<NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>matches += <NUM_LIT:1><EOL>yield tokens, preloc, nextLoc<EOL>loc = nextLoc<EOL><DEDENT><DEDENT>

Scan the input string for expression matches.  Each match will return the
           matching tokens, start location, and end location.  May be called with optional
           maxMatches argument, to clip scanning after 'n' matches are found.

           Note that the start and end locations are reported relative to the string
           being parsed.  See L{I{parseString}<parseString>} for more information on parsing
           strings with embedded tabs.


out = []<EOL>lastE = <NUM_LIT:0><EOL>self.keepTabs = True<EOL>for t,s,e in self.scanString( instring ):<EOL><INDENT>out.append( instring[lastE:s] )<EOL>if t:<EOL><INDENT>if isinstance(t,ParseResults):<EOL><INDENT>out += t.asList()<EOL><DEDENT>elif isinstance(t,list):<EOL><INDENT>out += t<EOL><DEDENT>else:<EOL><INDENT>out.append(t)<EOL><DEDENT><DEDENT>lastE = e<EOL><DEDENT>out.append(instring[lastE:])<EOL>return "<STR_LIT>".join(map(_ustr,out))<EOL>

Extension to scanString, to modify matching text with modified tokens that may
           be returned from a parse action.  To use transformString, define a grammar and
           attach a parse action to it that modifies the returned token list.
           Invoking transformString() on a target string will then scan for matches,
           and replace the matched text patterns according to the logic in the parse
           action.  transformString() returns the resulting transformed string.


def searchString( self, instring, maxMatches=_MAX_INT ):

return ParseResults([ t for t,s,e in self.scanString( instring, maxMatches ) ])<EOL>

Another extension to scanString, simplifying the access to the tokens found
           to match the given parse expression.  May be called with optional
           maxMatches argument, to clip searching after 'n' matches are found.


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return And( [ self, other ] )<EOL>

Implementation of + operator - returns And


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return other + self<EOL>

Implementation of + operator when left operand is not a ParserElement


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return And( [ self, And._ErrorStop(), other ] )<EOL>

Implementation of - operator, returns And with error stop


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return other - self<EOL>

Implementation of - operator when left operand is not a ParserElement


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return MatchFirst( [ self, other ] )<EOL>

Implementation of | operator - returns MatchFirst


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return other | self<EOL>

Implementation of | operator when left operand is not a ParserElement


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return Or( [ self, other ] )<EOL>

Implementation of ^ operator - returns Or


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return other ^ self<EOL>

Implementation of ^ operator when left operand is not a ParserElement


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return Each( [ self, other ] )<EOL>

Implementation of & operator - returns Each


if isinstance( other, str ):<EOL><INDENT>other = Literal( other )<EOL><DEDENT>if not isinstance( other, ParserElement ):<EOL><INDENT>warnings.warn("<STR_LIT>" % type(other),<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>return None<EOL><DEDENT>return other & self<EOL>

Implementation of & operator when left operand is not a ParserElement


return NotAny( self )<EOL>

Implementation of ~ operator - returns NotAny


return self.setResultsName(name)<EOL>

Shortcut for setResultsName, with listAllMatches=default::
             userdata = Word(alphas).setResultsName("name") + Word(nums+"-").setResultsName("socsecno")
           could be written as::
             userdata = Word(alphas)("name") + Word(nums+"-")("socsecno")


return Suppress( self )<EOL>

Suppresses the output of this ParserElement; useful to keep punctuation from
           cluttering up returned output.


self.skipWhitespace = False<EOL>return self<EOL>

Disables the skipping of whitespace before matching the characters in the
           ParserElement's defined pattern.  This is normally only used internally by
           the pyparsing module, but may be needed in some whitespace-sensitive grammars.


self.skipWhitespace = True<EOL>self.whiteChars = chars<EOL>self.copyDefaultWhiteChars = False<EOL>return self<EOL>


self.keepTabs = True<EOL>return self<EOL>

Overrides default behavior to expand <TAB>s to spaces before parsing the input string.
           Must be called before parseString when the input grammar contains elements that
           match <TAB> characters.


if isinstance( other, Suppress ):<EOL><INDENT>if other not in self.ignoreExprs:<EOL><INDENT>self.ignoreExprs.append( other )<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.ignoreExprs.append( Suppress( other ) )<EOL><DEDENT>return self<EOL>

Define expression to be ignored (e.g., comments) while doing pattern
           matching; may be called repeatedly, to define multiple comment or other
           ignorable patterns.


def setDebugActions( self, startAction, successAction, exceptionAction ):

self.debugActions = (startAction or _defaultStartDebugAction,<EOL>successAction or _defaultSuccessDebugAction,<EOL>exceptionAction or _defaultExceptionDebugAction)<EOL>self.debug = True<EOL>return self<EOL>

Enable display of debugging messages while doing pattern matching.


if flag:<EOL><INDENT>self.setDebugActions( _defaultStartDebugAction, _defaultSuccessDebugAction, _defaultExceptionDebugAction )<EOL><DEDENT>else:<EOL><INDENT>self.debug = False<EOL><DEDENT>return self<EOL>

Enable display of debugging messages while doing pattern matching.
           Set flag to True to enable, False to disable.


self.checkRecursion( [] )<EOL>

Check defined expressions for valid structure, check for infinite recursive definitions.


def parseFile( self, file_or_filename ):

try:<EOL><INDENT>file_contents = file_or_filename.read()<EOL><DEDENT>except AttributeError:<EOL><INDENT>f = open(file_or_filename, "<STR_LIT:rb>")<EOL>file_contents = f.read()<EOL>f.close()<EOL><DEDENT>return self.parseString(file_contents)<EOL>

Execute the parse expression on the given file or filename.
           If a filename is specified (instead of a file object),
           the entire file is opened, read, and closed before parsing.


Keyword.DEFAULT_KEYWORD_CHARS = chars<EOL>


def __init__( self, pattern, flags=<NUM_LIT:0>):

super(Regex,self).__init__()<EOL>if len(pattern) == <NUM_LIT:0>:<EOL><INDENT>warnings.warn("<STR_LIT>",<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL><DEDENT>self.pattern = pattern<EOL>self.flags = flags<EOL>try:<EOL><INDENT>self.re = re.compile(self.pattern, self.flags)<EOL>self.reString = self.pattern<EOL><DEDENT>except sre_constants.error:<EOL><INDENT>warnings.warn("<STR_LIT>" % pattern,<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>raise<EOL><DEDENT>self.name = _ustr(self)<EOL>self.errmsg = "<STR_LIT>" + self.name<EOL>self.mayIndexError = False<EOL>self.mayReturnEmpty = True<EOL>

The parameters pattern and flags are passed to the re.compile() function as-is. See the Python re module for an explanation of the acceptable patterns and flags.


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

super(QuotedString,self).__init__()<EOL>quoteChar = quoteChar.strip()<EOL>if len(quoteChar) == <NUM_LIT:0>:<EOL><INDENT>warnings.warn("<STR_LIT>",SyntaxWarning,stacklevel=<NUM_LIT:2>)<EOL>raise SyntaxError()<EOL><DEDENT>if endQuoteChar is None:<EOL><INDENT>endQuoteChar = quoteChar<EOL><DEDENT>else:<EOL><INDENT>endQuoteChar = endQuoteChar.strip()<EOL>if len(endQuoteChar) == <NUM_LIT:0>:<EOL><INDENT>warnings.warn("<STR_LIT>",SyntaxWarning,stacklevel=<NUM_LIT:2>)<EOL>raise SyntaxError()<EOL><DEDENT><DEDENT>self.quoteChar = quoteChar<EOL>self.quoteCharLen = len(quoteChar)<EOL>self.firstQuoteChar = quoteChar[<NUM_LIT:0>]<EOL>self.endQuoteChar = endQuoteChar<EOL>self.endQuoteCharLen = len(endQuoteChar)<EOL>self.escChar = escChar<EOL>self.escQuote = escQuote<EOL>self.unquoteResults = unquoteResults<EOL>if multiline:<EOL><INDENT>self.flags = re.MULTILINE | re.DOTALL<EOL>self.pattern = r'<STR_LIT>' %( re.escape(self.quoteChar),<EOL>_escapeRegexRangeChars(self.endQuoteChar[<NUM_LIT:0>]),<EOL>(escChar is not None and _escapeRegexRangeChars(escChar) or '<STR_LIT>') )<EOL><DEDENT>else:<EOL><INDENT>self.flags = <NUM_LIT:0><EOL>self.pattern = r'<STR_LIT>' %( re.escape(self.quoteChar),<EOL>_escapeRegexRangeChars(self.endQuoteChar[<NUM_LIT:0>]),<EOL>(escChar is not None and _escapeRegexRangeChars(escChar) or '<STR_LIT>') )<EOL><DEDENT>if len(self.endQuoteChar) > <NUM_LIT:1>:<EOL><INDENT>self.pattern += (<EOL>'<STR_LIT>' + '<STR_LIT>'.join(["<STR_LIT>" % (re.escape(self.endQuoteChar[:i]),<EOL>_escapeRegexRangeChars(self.endQuoteChar[i]))<EOL>for i in range(len(self.endQuoteChar)-<NUM_LIT:1>,<NUM_LIT:0>,-<NUM_LIT:1>)]) + '<STR_LIT:)>'<EOL>)<EOL><DEDENT>if escQuote:<EOL><INDENT>self.pattern += (r'<STR_LIT>' % re.escape(escQuote))<EOL><DEDENT>if escChar:<EOL><INDENT>self.pattern += (r'<STR_LIT>' % re.escape(escChar))<EOL>self.escCharReplacePattern = re.escape(self.escChar)+"<STR_LIT>"<EOL><DEDENT>self.pattern += (r'<STR_LIT>' % re.escape(self.endQuoteChar))<EOL>try:<EOL><INDENT>self.re = re.compile(self.pattern, self.flags)<EOL>self.reString = self.pattern<EOL><DEDENT>except sre_constants.error:<EOL><INDENT>warnings.warn("<STR_LIT>" % self.pattern,<EOL>SyntaxWarning, stacklevel=<NUM_LIT:2>)<EOL>raise<EOL><DEDENT>self.name = _ustr(self)<EOL>self.errmsg = "<STR_LIT>" + self.name<EOL>self.mayIndexError = False<EOL>self.mayReturnEmpty = True<EOL>

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=None)
 - escQuote - special quote sequence to escape an embedded quote string (such as SQL's "" to escape an embedded ") (default=None)
 - multiline - boolean indicating whether quotes can span multiple lines (default=False)
 - unquoteResults - boolean indicating whether the matched text should be unquoted (default=True)
 - endQuoteChar - string of one or more characters defining the end of the quote delimited string (default=None => same as quoteChar)


self.skipWhitespace = False<EOL>self.exprs = [ e.copy() for e in self.exprs ]<EOL>for e in self.exprs:<EOL><INDENT>e.leaveWhitespace()<EOL><DEDENT>return self<EOL>

Extends leaveWhitespace defined in base class, and also invokes leaveWhitespace on
           all contained expressions.


def __patch__init__(self,<EOL>edgecolor=None,<EOL>facecolor=None,<EOL>linewidth=None,<EOL>linestyle=None,<EOL>antialiased = None,<EOL>hatch = None,<EOL>fill=True,<EOL>**kwargs<EOL>):

artist.Artist.__init__(self)<EOL>if linewidth is None: linewidth = mpl.rcParams['<STR_LIT>']<EOL>if linestyle is None: linestyle = "<STR_LIT>"<EOL>if antialiased is None: antialiased = mpl.rcParams['<STR_LIT>']<EOL>self.set_edgecolor(edgecolor)<EOL>self.set_facecolor(facecolor)<EOL>self.set_linewidth(linewidth)<EOL>self.set_linestyle(linestyle)<EOL>self.set_antialiased(antialiased)<EOL>self.set_hatch(hatch)<EOL>self.fill = fill<EOL>self._combined_transform = transforms.IdentityTransform()<EOL>if len(kwargs): artist.setp(self, **kwargs)<EOL>

The following kwarg properties are supported

%(Patch)s


def bbox_artist(artist, renderer, props=None, fill=True):

if props is None: props = {}<EOL>props = props.copy() <EOL>pad = props.pop('<STR_LIT>', <NUM_LIT:4>)<EOL>pad = renderer.points_to_pixels(pad)<EOL>bbox = artist.get_window_extent(renderer)<EOL>l,b,w,h = bbox.bounds<EOL>l-=pad/<NUM_LIT><EOL>b-=pad/<NUM_LIT><EOL>w+=pad<EOL>h+=pad<EOL>r = Rectangle(xy=(l,b),<EOL>width=w,<EOL>height=h,<EOL>fill=fill,<EOL>)<EOL>r.set_transform(transforms.IdentityTransform())<EOL>r.set_clip_on( False )<EOL>r.update(props)<EOL>r.draw(renderer)<EOL>

This is a debug function to draw a rectangle around the bounding
box returned by
:meth:`~matplotlib.artist.Artist.get_window_extent` of an artist,
to test whether the artist is returning the correct bbox.

*props* is a dict of rectangle props with the additional property
'pad' that sets the padding around the bbox in points.


def draw_bbox(bbox, renderer, color='<STR_LIT:k>', trans=None):

l,b,w,h = bbox.get_bounds()<EOL>r = Rectangle(xy=(l,b),<EOL>width=w,<EOL>height=h,<EOL>edgecolor=color,<EOL>fill=False,<EOL>)<EOL>if trans is not None: r.set_transform(trans)<EOL>r.set_clip_on( False )<EOL>r.draw(renderer)<EOL>

This is a debug function to draw a rectangle around the bounding
box returned by
:meth:`~matplotlib.artist.Artist.get_window_extent` of an artist,
to test whether the artist is returning the correct bbox.


if leadingspace:<EOL><INDENT>pad = '<STR_LIT:U+0020>'*leadingspace<EOL><DEDENT>else:<EOL><INDENT>pad  = '<STR_LIT>'<EOL><DEDENT>columns = [[] for cell in _table[<NUM_LIT:0>]]<EOL>for row in _table:<EOL><INDENT>for column, cell in zip(columns, row):<EOL><INDENT>column.append(cell)<EOL><DEDENT><DEDENT>col_len = [max([len(cell) for cell in column]) for column in columns]<EOL>lines = []<EOL>table_formatstr = pad + '<STR_LIT:U+0020>'.join([('<STR_LIT:=>' * cl) for cl in col_len])<EOL>lines.append('<STR_LIT>')<EOL>lines.append(table_formatstr)<EOL>lines.append(pad + '<STR_LIT:U+0020>'.join([cell.ljust(cl) for cell, cl in zip(_table[<NUM_LIT:0>], col_len)]))<EOL>lines.append(table_formatstr)<EOL>lines.extend([(pad + '<STR_LIT:U+0020>'.join([cell.ljust(cl) for cell, cl in zip(row, col_len)]))<EOL>for row in _table[<NUM_LIT:1>:]])<EOL>lines.append(table_formatstr)<EOL>lines.append('<STR_LIT>')<EOL>return "<STR_LIT:\n>".join(lines)<EOL>

Given the list of list of strings, return a string of REST table format.


if leadingspace:<EOL><INDENT>pad = '<STR_LIT:U+0020>'*leadingspace<EOL><DEDENT>else:<EOL><INDENT>pad  = '<STR_LIT>'<EOL><DEDENT>names, attrss, clss = [], [], []<EOL>import inspect<EOL>_table = [["<STR_LIT>", "<STR_LIT:Name>", "<STR_LIT>"]]<EOL>for name, cls in sorted(_styles.items()):<EOL><INDENT>args, varargs, varkw, defaults =  inspect.getargspec(cls.__init__)<EOL>if defaults:<EOL><INDENT>args = [(argname, argdefault)for argname, argdefault in zip(args[<NUM_LIT:1>:], defaults)]<EOL><DEDENT>else:<EOL><INDENT>args = None<EOL><DEDENT>if args is None:<EOL><INDENT>argstr = '<STR_LIT:None>'<EOL><DEDENT>else:<EOL><INDENT>argstr =  "<STR_LIT:U+002C>".join([("<STR_LIT>" % (an, av)) for an, av in args])<EOL><DEDENT>_table.append([cls.__name__, "<STR_LIT>"%name, argstr])<EOL><DEDENT>return _pprint_table(_table)<EOL>

A helper function for the _Style class.  Given the dictionary of
(stylename : styleclass), return a formatted string listing all the
styles. Used to update the documentation.


trans = self.get_transform()<EOL>path = self.get_path()<EOL>polygons = path.to_polygons(trans)<EOL>if len(polygons):<EOL><INDENT>return polygons[<NUM_LIT:0>]<EOL><DEDENT>return []<EOL>

Return a copy of the vertices used in this patch

If the patch contains Bézier curves, the curves will be
interpolated by line segments.  To access the curves as
curves, use :meth:`get_path`.


<EOL>if callable(self._contains): return self._contains(self,mouseevent)<EOL>inside = self.get_path().contains_point(<EOL>(mouseevent.x, mouseevent.y), self.get_transform())<EOL>return inside, {}<EOL>

Test whether the mouse event occurred in the patch.

        Returns T/F, {}


Updates this :class:`Patch` from the properties of *other*.


return self.get_path().get_extents(self.get_transform())<EOL>

Return a :class:`~matplotlib.transforms.Bbox` object defining
the axis-aligned extents of the :class:`Patch`.


return self.get_patch_transform() + artist.Artist.get_transform(self)<EOL>

Return the :class:`~matplotlib.transforms.Transform` applied
to the :class:`Patch`.


return self._antialiased<EOL>

Returns True if the :class:`Patch` is to be drawn with antialiasing.


return self._edgecolor<EOL>

Return the edge color of the :class:`Patch`.


return self._facecolor<EOL>

Return the face color of the :class:`Patch`.


return self._linewidth<EOL>


return self._linestyle<EOL>

Return the linestyle.  Will be one of ['solid' | 'dashed' |
'dashdot' | 'dotted']


if aa is None: aa = mpl.rcParams['<STR_LIT>']<EOL>self._antialiased = aa<EOL>

Set whether to use antialiased rendering

ACCEPTS: [True | False]  or None for default


return self.set_antialiased(aa)<EOL>


if color is None: color = mpl.rcParams['<STR_LIT>']<EOL>self._edgecolor = color<EOL>

Set the patch edge color

ACCEPTS: mpl color spec, or None for default, or 'none' for no color


return self.set_edgecolor(color)<EOL>


if color is None: color = mpl.rcParams['<STR_LIT>']<EOL>self._facecolor = color<EOL>

Set the patch face color

ACCEPTS: mpl color spec, or None for default, or 'none' for no color


return self.set_facecolor(color)<EOL>


if w is None: w = mpl.rcParams['<STR_LIT>']<EOL>self._linewidth = w<EOL>

Set the patch linewidth in points

ACCEPTS: float or None for default


return self.set_linewidth(lw)<EOL>


if ls is None: ls = "<STR_LIT>"<EOL>self._linestyle = ls<EOL>

Set the patch linestyle

ACCEPTS: ['solid' | 'dashed' | 'dashdot' | 'dotted']


return self.set_linestyle(ls)<EOL>


self.fill = b<EOL>

Set whether to fill the patch

ACCEPTS: [True | False]


return self.fill<EOL>


self._hatch = h<EOL>

Set the hatching pattern

hatch can be one of::

  /   - diagonal hatching
  \   - back diagonal
  |   - vertical
  -   - horizontal
  #   - crossed
  x   - crossed diagonal

Letters can be combined, in which case all the specified
hatchings are done.  If same letter repeats, it increases the
density of hatching in that direction.

CURRENT LIMITATIONS:

1. Hatching is supported in the PostScript backend only.

2. Hatching is done with solid black lines of width 0.

ACCEPTS: [ '/' | '\\' | '|' | '-' | '#' | 'x' ]


return self._hatch<EOL>


if not self.get_visible(): return<EOL>gc = renderer.new_gc()<EOL>if cbook.is_string_like(self._edgecolor) and self._edgecolor.lower()=='<STR_LIT:none>':<EOL><INDENT>gc.set_linewidth(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>gc.set_foreground(self._edgecolor)<EOL>gc.set_linewidth(self._linewidth)<EOL>gc.set_linestyle(self._linestyle)<EOL><DEDENT>gc.set_antialiased(self._antialiased)<EOL>self._set_gc_clip(gc)<EOL>gc.set_capstyle('<STR_LIT>')<EOL>gc.set_url(self._url)<EOL>gc.set_snap(self._snap)<EOL>if (not self.fill or self._facecolor is None or<EOL>(cbook.is_string_like(self._facecolor) and self._facecolor.lower()=='<STR_LIT:none>')):<EOL><INDENT>rgbFace = None<EOL>gc.set_alpha(<NUM_LIT:1.0>)<EOL><DEDENT>else:<EOL><INDENT>r, g, b, a = colors.colorConverter.to_rgba(self._facecolor, self._alpha)<EOL>rgbFace = (r, g, b)<EOL>gc.set_alpha(a)<EOL><DEDENT>if self._hatch:<EOL><INDENT>gc.set_hatch(self._hatch )<EOL><DEDENT>path = self.get_path()<EOL>transform = self.get_transform()<EOL>tpath = transform.transform_path_non_affine(path)<EOL>affine = transform.get_affine()<EOL>renderer.draw_path(gc, tpath, affine, rgbFace)<EOL>

Draw the :class:`Patch` to the given *renderer*.


raise NotImplementedError('<STR_LIT>')<EOL>


def __init__(self, patch, ox, oy, props=None, **kwargs):

Patch.__init__(self)<EOL>self.patch = patch<EOL>self.props = props<EOL>self._ox, self._oy = ox, oy<EOL>self._update_transform()<EOL>self._update()<EOL>

Create a shadow of the given *patch* offset by *ox*, *oy*.
*props*, if not *None*, is a patch property update dictionary.
If *None*, the shadow will have have the same color as the face,
but darkened.

kwargs are
%(Patch)s


def __init__(self, xy, width, height, **kwargs):

Patch.__init__(self, **kwargs)<EOL>self._x = xy[<NUM_LIT:0>]<EOL>self._y = xy[<NUM_LIT:1>]<EOL>self._width = width<EOL>self._height = height<EOL>self._rect_transform = transforms.IdentityTransform()<EOL>

*fill* is a boolean indicating whether to fill the rectangle

Valid kwargs are:
%(Patch)s


return Path.unit_rectangle()<EOL>


x = self.convert_xunits(self._x)<EOL>y = self.convert_yunits(self._y)<EOL>width = self.convert_xunits(self._width)<EOL>height = self.convert_yunits(self._height)<EOL>bbox = transforms.Bbox.from_bounds(x, y, width, height)<EOL>self._rect_transform = transforms.BboxTransformTo(bbox)<EOL>

NOTE: This cannot be called until after this has been added
                 to an Axes, otherwise unit conversion will fail. This
                 maxes it very important to call the accessor method and
                 not directly access the transformation member variable.


return self._x<EOL>


return self._y<EOL>

Return the bottom coord of the rectangle


return self._x, self._y<EOL>

Return the left and bottom coords of the rectangle


return self._width<EOL>


return self._height<EOL>


self._x = x<EOL>

Set the left coord of the rectangle

ACCEPTS: float


self._y = y<EOL>

Set the bottom coord of the rectangle

ACCEPTS: float


self._x, self._y = xy<EOL>

Set the left and bottom coords of the rectangle

ACCEPTS: 2-item sequence


self._width = w<EOL>


self._height = h<EOL>


if len(args)==<NUM_LIT:0>:<EOL><INDENT>l,b,w,h = args[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>l,b,w,h = args<EOL><DEDENT>self._x = l<EOL>self._y = b<EOL>self._width = w<EOL>self._height = h<EOL>

Set the bounds of the rectangle: l,b,w,h

ACCEPTS: (left, bottom, width, height)


def __init__(self, xy, numVertices, radius=<NUM_LIT:5>, orientation=<NUM_LIT:0>,<EOL>**kwargs):

self._xy = xy<EOL>self._numVertices = numVertices<EOL>self._orientation = orientation<EOL>self._radius = radius<EOL>self._path = Path.unit_regular_polygon(numVertices)<EOL>self._poly_transform = transforms.Affine2D()<EOL>self._update_transform()<EOL>Patch.__init__(self, **kwargs)<EOL>

Constructor arguments:

*xy*
  A length 2 tuple (*x*, *y*) of the center.

*numVertices*
  the number of vertices.

*radius*
  The distance from the center to each of the vertices.

*orientation*
  rotates the polygon (in radians).

Valid kwargs are:
%(Patch)s


Patch.__init__(self, **kwargs)<EOL>self._path = path<EOL>

*path* is a :class:`matplotlib.path.Path` object.

Valid kwargs are:
%(Patch)s

.. seealso::
    :class:`Patch`:
        For additional kwargs


def __init__(self, xy, closed=True, **kwargs):

Patch.__init__(self, **kwargs)<EOL>xy = np.asarray(xy, np.float_)<EOL>self._path = Path(xy)<EOL>self.set_closed(closed)<EOL>

*xy* is a numpy array with shape Nx2.

If *closed* is *True*, the polygon will be closed so the
starting and ending points are the same.

Valid kwargs are:
%(Patch)s

.. seealso::
    :class:`Patch`:
        For additional kwargs


def __init__(self, center, r, theta1, theta2, width=None, **kwargs):

Patch.__init__(self, **kwargs)<EOL>self.center = center<EOL>self.r,self.width = r,width<EOL>self.theta1,self.theta2 = theta1,theta2<EOL>delta=theta2-theta1<EOL>if abs((theta2-theta1) - <NUM_LIT>) <= <NUM_LIT>:<EOL><INDENT>theta1,theta2 = <NUM_LIT:0>,<NUM_LIT><EOL>connector = Path.MOVETO<EOL><DEDENT>else:<EOL><INDENT>connector = Path.LINETO<EOL><DEDENT>arc = Path.arc(theta1,theta2)<EOL>if width is not None:<EOL><INDENT>v1 = arc.vertices<EOL>v2 = arc.vertices[::-<NUM_LIT:1>]*float(r-width)/r<EOL>v = np.vstack([v1,v2,v1[<NUM_LIT:0>,:],(<NUM_LIT:0>,<NUM_LIT:0>)])<EOL>c = np.hstack([arc.codes,arc.codes,connector,Path.CLOSEPOLY])<EOL>c[len(arc.codes)]=connector<EOL><DEDENT>else:<EOL><INDENT>v = np.vstack([arc.vertices,[(<NUM_LIT:0>,<NUM_LIT:0>),arc.vertices[<NUM_LIT:0>,:],(<NUM_LIT:0>,<NUM_LIT:0>)]])<EOL>c = np.hstack([arc.codes,[connector,connector,Path.CLOSEPOLY]])<EOL><DEDENT>v *= r<EOL>v += np.asarray(center)<EOL>self._path = Path(v,c)<EOL>self._patch_transform = transforms.IdentityTransform()<EOL>

Draw a wedge centered at *x*, *y* center with radius *r* that
sweeps *theta1* to *theta2* (in degrees).  If *width* is given,
then a partial wedge is drawn from inner radius *r* - *width*
to outer radius *r*.

Valid kwargs are:

%(Patch)s


def __init__( self, x, y, dx, dy, width=<NUM_LIT:1.0>, **kwargs ):

Patch.__init__(self, **kwargs)<EOL>L = np.sqrt(dx**<NUM_LIT:2>+dy**<NUM_LIT:2>) or <NUM_LIT:1> <EOL>cx = float(dx)/L<EOL>sx = float(dy)/L<EOL>trans1 = transforms.Affine2D().scale(L, width)<EOL>trans2 = transforms.Affine2D.from_values(cx, sx, -sx, cx, <NUM_LIT:0.0>, <NUM_LIT:0.0>)<EOL>trans3 = transforms.Affine2D().translate(x, y)<EOL>trans = trans1 + trans2 + trans3<EOL>self._patch_transform = trans.frozen()<EOL>

Draws an arrow, starting at (*x*, *y*), direction and length
given by (*dx*, *dy*) the width of the arrow is scaled by *width*.

Valid kwargs are:
%(Patch)s


def __init__(self, x, y, dx, dy, width=<NUM_LIT>, length_includes_head=False,head_width=None, head_length=None, shape='<STR_LIT>', overhang=<NUM_LIT:0>,head_starts_at_zero=False,**kwargs):

if head_width is None:<EOL><INDENT>head_width = <NUM_LIT:3> * width<EOL><DEDENT>if head_length is None:<EOL><INDENT>head_length = <NUM_LIT> * head_width<EOL><DEDENT>distance = np.sqrt(dx**<NUM_LIT:2> + dy**<NUM_LIT:2>)<EOL>if length_includes_head:<EOL><INDENT>length=distance<EOL><DEDENT>else:<EOL><INDENT>length=distance+head_length<EOL><DEDENT>if not length:<EOL><INDENT>verts = [] <EOL><DEDENT>else:<EOL><INDENT>hw, hl, hs, lw = head_width, head_length, overhang, width<EOL>left_half_arrow = np.array([<EOL>[<NUM_LIT:0.0>,<NUM_LIT:0.0>],                  <EOL>[-hl, -hw/<NUM_LIT>],             <EOL>[-hl*(<NUM_LIT:1>-hs), -lw/<NUM_LIT>], <EOL>[-length, -lw/<NUM_LIT>],          <EOL>[-length, <NUM_LIT:0>],<EOL>])<EOL>if not length_includes_head:<EOL><INDENT>left_half_arrow += [head_length, <NUM_LIT:0>]<EOL><DEDENT>if head_starts_at_zero:<EOL><INDENT>left_half_arrow += [head_length/<NUM_LIT>, <NUM_LIT:0>]<EOL><DEDENT>if shape == '<STR_LIT:left>':<EOL><INDENT>coords = left_half_arrow<EOL><DEDENT>else:<EOL><INDENT>right_half_arrow = left_half_arrow*[<NUM_LIT:1>,-<NUM_LIT:1>]<EOL>if shape == '<STR_LIT:right>':<EOL><INDENT>coords = right_half_arrow<EOL><DEDENT>elif shape == '<STR_LIT>':<EOL><INDENT>coords=np.concatenate([left_half_arrow[:-<NUM_LIT:1>],<EOL>right_half_arrow[-<NUM_LIT:2>::-<NUM_LIT:1>]])<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % shape)<EOL><DEDENT><DEDENT>cx = float(dx)/distance<EOL>sx = float(dy)/distance<EOL>M = np.array([[cx, sx],[-sx,cx]])<EOL>verts = np.dot(coords, M) + (x+dx, y+dy)<EOL><DEDENT>Polygon.__init__(self, list(map(tuple, verts)), **kwargs)<EOL>

Constructor arguments

    *length_includes_head*:
       *True* if head is counted in calculating the length.

    *shape*: ['full', 'left', 'right']

    *overhang*:
      distance that the arrow is swept back (0 overhang means
      triangular shape).

    *head_starts_at_zero*:
      If *True*, the head starts being drawn at coordinate 0
      instead of ending at coordinate 0.

Valid kwargs are:
%(Patch)s


def __init__(self, figure, xytip, xybase, width=<NUM_LIT:4>, frac=<NUM_LIT:0.1>, headwidth=<NUM_LIT:12>, **kwargs):

self.figure = figure<EOL>self.xytip = xytip<EOL>self.xybase = xybase<EOL>self.width = width<EOL>self.frac = frac<EOL>self.headwidth = headwidth<EOL>Patch.__init__(self, **kwargs)<EOL>

Constructor arguments:

*xytip*
  (*x*, *y*) location of arrow tip

*xybase*
  (*x*, *y*) location the arrow base mid point

*figure*
  The :class:`~matplotlib.figure.Figure` instance
  (fig.dpi)

*width*
  The width of the arrow in points

*frac*
  The fraction of the arrow length occupied by the head

*headwidth*
  The width of the base of the arrow head in points

Valid kwargs are:
%(Patch)s


x1,y1,x2,y2,k = list(map(float, (x1,y1,x2,y2,k)))<EOL>if y2-y1 == <NUM_LIT:0>:<EOL><INDENT>return x2, y2+k, x2, y2-k<EOL><DEDENT>elif x2-x1 == <NUM_LIT:0>:<EOL><INDENT>return x2+k, y2, x2-k, y2<EOL><DEDENT>m = (y2-y1)/(x2-x1)<EOL>pm = -<NUM_LIT:1.>/m<EOL>a = <NUM_LIT:1><EOL>b = -<NUM_LIT:2>*y2<EOL>c = y2**<NUM_LIT> - k**<NUM_LIT>*pm**<NUM_LIT>/(<NUM_LIT:1.> + pm**<NUM_LIT>)<EOL>y3a = (-b + math.sqrt(b**<NUM_LIT>-<NUM_LIT:4>*a*c))/(<NUM_LIT>*a)<EOL>x3a = (y3a - y2)/pm + x2<EOL>y3b = (-b - math.sqrt(b**<NUM_LIT>-<NUM_LIT:4>*a*c))/(<NUM_LIT>*a)<EOL>x3b = (y3b - y2)/pm + x2<EOL>return x3a, y3a, x3b, y3b<EOL>

For line segment defined by (*x1*, *y1*) and (*x2*, *y2*)
return the points on the line that is perpendicular to the
line and intersects (*x2*, *y2*) and the distance from (*x2*,
*y2*) of the returned points is *k*.


def __init__(self, xy, radius=<NUM_LIT:5>,<EOL>resolution=<NUM_LIT:20>,  <EOL>**kwargs):

RegularPolygon.__init__(self, xy,<EOL>resolution,<EOL>radius,<EOL>orientation=<NUM_LIT:0>,<EOL>**kwargs)<EOL>

Create a circle at *xy* = (*x*, *y*) with given *radius*.
This circle is approximated by a regular polygon with
*resolution* sides.  For a smoother circle drawn with splines,
see :class:`~matplotlib.patches.Circle`.

Valid kwargs are:
%(Patch)s


def __init__(self, xy, width, height, angle=<NUM_LIT:0.0>, **kwargs):

Patch.__init__(self, **kwargs)<EOL>self.center = xy<EOL>self.width, self.height = width, height<EOL>self.angle = angle<EOL>self._path = Path.unit_circle()<EOL>self._patch_transform = transforms.IdentityTransform()<EOL>

*xy*
  center of ellipse

*width*
  length of horizontal axis

*height*
  length of vertical axis

*angle*
  rotation in degrees (anti-clockwise)

Valid kwargs are:
%(Patch)s


center = (self.convert_xunits(self.center[<NUM_LIT:0>]),<EOL>self.convert_yunits(self.center[<NUM_LIT:1>]))<EOL>width = self.convert_xunits(self.width)<EOL>height = self.convert_yunits(self.height)<EOL>self._patch_transform = transforms.Affine2D().scale(width * <NUM_LIT:0.5>, height * <NUM_LIT:0.5>).rotate_deg(self.angle).translate(*center)<EOL>

NOTE: This cannot be called until after this has been added
                 to an Axes, otherwise unit conversion will fail. This
                 maxes it very important to call the accessor method and
                 not directly access the transformation member variable.


return self._path<EOL>


def __init__(self, xy, radius=<NUM_LIT:5>, **kwargs):

if '<STR_LIT>' in kwargs:<EOL><INDENT>import warnings<EOL>warnings.warn('<STR_LIT>', DeprecationWarning)<EOL>kwargs.pop('<STR_LIT>')<EOL><DEDENT>self.radius = radius<EOL>Ellipse.__init__(self, xy, radius*<NUM_LIT:2>, radius*<NUM_LIT:2>, **kwargs)<EOL>

Create true circle at center *xy* = (*x*, *y*) with given
*radius*.  Unlike :class:`~matplotlib.patches.CirclePolygon`
which is a polygonal approximation, this uses Bézier splines
and is much closer to a scale-free circle.

Valid kwargs are:
%(Patch)s


def __init__(self, xy, width, height, angle=<NUM_LIT:0.0>, theta1=<NUM_LIT:0.0>, theta2=<NUM_LIT>, **kwargs):

fill = kwargs.pop('<STR_LIT>')<EOL>if fill:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>kwargs['<STR_LIT>'] = False<EOL>Ellipse.__init__(self, xy, width, height, angle, **kwargs)<EOL>self.theta1 = theta1<EOL>self.theta2 = theta2<EOL>

The following args are supported:

*xy*
  center of ellipse

*width*
  length of horizontal axis

*height*
  length of vertical axis

*angle*
  rotation in degrees (anti-clockwise)

*theta1*
  starting angle of the arc in degrees

*theta2*
  ending angle of the arc in degrees

If *theta1* and *theta2* are not provided, the arc will form a
complete ellipse.

Valid kwargs are:

%(Patch)s


if not hasattr(self, '<STR_LIT>'):<EOL><INDENT>raise RuntimeError('<STR_LIT>')<EOL><DEDENT>self._recompute_transform()<EOL>width = self.convert_xunits(self.width)<EOL>height = self.convert_yunits(self.height)<EOL>width, height = self.get_transform().transform_point(<EOL>(width, height))<EOL>inv_error = (<NUM_LIT:1.0> / <NUM_LIT>) * <NUM_LIT:0.5><EOL>if width < inv_error and height < inv_error:<EOL><INDENT>self._path = Path.arc(self.theta1, self.theta2)<EOL>return Patch.draw(self, renderer)<EOL><DEDENT>def iter_circle_intersect_on_line(x0, y0, x1, y1):<EOL><INDENT>dx = x1 - x0<EOL>dy = y1 - y0<EOL>dr2 = dx*dx + dy*dy<EOL>D = x0*y1 - x1*y0<EOL>D2 = D*D<EOL>discrim = dr2 - D2<EOL>if discrim == <NUM_LIT:0.0>:<EOL><INDENT>x = (D*dy) / dr2<EOL>y = (-D*dx) / dr2<EOL>yield x, y<EOL><DEDENT>elif discrim > <NUM_LIT:0.0>:<EOL><INDENT>if dy < <NUM_LIT:0.0>:<EOL><INDENT>sign_dy = -<NUM_LIT:1.0><EOL><DEDENT>else:<EOL><INDENT>sign_dy = <NUM_LIT:1.0><EOL><DEDENT>sqrt_discrim = np.sqrt(discrim)<EOL>for sign in (<NUM_LIT:1.>, -<NUM_LIT:1.>):<EOL><INDENT>x = (D*dy + sign * sign_dy * dx * sqrt_discrim) / dr2<EOL>y = (-D*dx + sign * np.abs(dy) * sqrt_discrim) / dr2<EOL>yield x, y<EOL><DEDENT><DEDENT><DEDENT>def iter_circle_intersect_on_line_seg(x0, y0, x1, y1):<EOL><INDENT>epsilon = <NUM_LIT><EOL>if x1 < x0:<EOL><INDENT>x0e, x1e = x1, x0<EOL><DEDENT>else:<EOL><INDENT>x0e, x1e = x0, x1<EOL><DEDENT>if y1 < y0:<EOL><INDENT>y0e, y1e = y1, y0<EOL><DEDENT>else:<EOL><INDENT>y0e, y1e = y0, y1<EOL><DEDENT>x0e -= epsilon<EOL>y0e -= epsilon<EOL>x1e += epsilon<EOL>y1e += epsilon<EOL>for x, y in iter_circle_intersect_on_line(x0, y0, x1, y1):<EOL><INDENT>if x >= x0e and x <= x1e and y >= y0e and y <= y1e:<EOL><INDENT>yield x, y<EOL><DEDENT><DEDENT><DEDENT>box_path = Path.unit_rectangle()<EOL>box_path_transform = transforms.BboxTransformTo(self.axes.bbox) +self.get_transform().inverted()<EOL>box_path = box_path.transformed(box_path_transform)<EOL>PI = np.pi<EOL>TWOPI = PI * <NUM_LIT><EOL>RAD2DEG = <NUM_LIT> / PI<EOL>DEG2RAD = PI / <NUM_LIT><EOL>theta1 = self.theta1<EOL>theta2 = self.theta2<EOL>thetas = {}<EOL>for p0, p1 in zip(box_path.vertices[:-<NUM_LIT:1>], box_path.vertices[<NUM_LIT:1>:]):<EOL><INDENT>x0, y0 = p0<EOL>x1, y1 = p1<EOL>for x, y in iter_circle_intersect_on_line_seg(x0, y0, x1, y1):<EOL><INDENT>theta = np.arccos(x)<EOL>if y < <NUM_LIT:0>:<EOL><INDENT>theta = TWOPI - theta<EOL><DEDENT>theta *= RAD2DEG<EOL>if theta > theta1 and theta < theta2:<EOL><INDENT>thetas[theta] = None<EOL><DEDENT><DEDENT><DEDENT>thetas = list(thetas.keys())<EOL>thetas.sort()<EOL>thetas.append(theta2)<EOL>last_theta = theta1<EOL>theta1_rad = theta1 * DEG2RAD<EOL>inside = box_path.contains_point((np.cos(theta1_rad), np.sin(theta1_rad)))<EOL>for theta in thetas:<EOL><INDENT>if inside:<EOL><INDENT>self._path = Path.arc(last_theta, theta, <NUM_LIT:8>)<EOL>Patch.draw(self, renderer)<EOL>inside = False<EOL><DEDENT>else:<EOL><INDENT>inside = True<EOL><DEDENT>last_theta = theta<EOL><DEDENT>

Ellipses are normally drawn using an approximation that uses
eight cubic bezier splines.  The error of this approximation
is 1.89818e-6, according to this unverified source:

  Lancaster, Don.  Approximating a Circle or an Ellipse Using
  Four Bezier Cubic Splines.

  http://www.tinaja.com/glib/ellipse4.pdf

There is a use case where very large ellipses must be drawn
with very high accuracy, and it is too expensive to render the
entire ellipse with enough segments (either splines or line
segments).  Therefore, in the case where either radius of the
ellipse is large enough that the error of the spline
approximation will be visible (greater than one pixel offset
from the ideal), a different technique is used.

In that case, only the visible parts of the ellipse are drawn,
with each visible arc using a fixed number of spline segments
(8).  The algorithm proceeds as follows:

  1. The points where the ellipse intersects the axes bounding
     box are located.  (This is done be performing an inverse
     transformation on the axes bbox such that it is relative
     to the unit circle -- this makes the intersection
     calculation much easier than doing rotated ellipse
     intersection directly).

     This uses the "line intersecting a circle" algorithm
     from:

       Vince, John.  Geometry for Computer Graphics: Formulae,
       Examples & Proofs.  London: Springer-Verlag, 2005.

  2. The angles of each of the intersection points are
     calculated.

  3. Proceeding counterclockwise starting in the positive
     x-direction, each of the visible arc-segments between the
     pairs of vertices are drawn using the bezier arc
     approximation technique implemented in
     :meth:`matplotlib.path.Path.arc`.


<EOL>_list = stylename.replace("<STR_LIT:U+0020>","<STR_LIT>").split("<STR_LIT:U+002C>")<EOL>_name = _list[<NUM_LIT:0>].lower()<EOL>try:<EOL><INDENT>_cls = self._style_list[_name]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ValueError("<STR_LIT>" % stylename)<EOL><DEDENT>try:<EOL><INDENT>_args_pair = [cs.split("<STR_LIT:=>") for cs in _list[<NUM_LIT:1>:]]<EOL>_args = dict([(k, float(v)) for k, v in _args_pair])<EOL><DEDENT>except ValueError:<EOL><INDENT>raise ValueError("<STR_LIT>" % stylename)<EOL><DEDENT>_args.update(kw)<EOL>return _cls(**_args)<EOL>

return the instance of the subclass with the given style name.


return klass._style_list<EOL>

A class method which returns a dictionary of available styles.


return _pprint_styles(klass._style_list)<EOL>

A class method which returns a string of the available styles.


Patch.__init__(self, **kwargs)<EOL>self._x = xy[<NUM_LIT:0>]<EOL>self._y = xy[<NUM_LIT:1>]<EOL>self._width = width<EOL>self._height = height<EOL>if boxstyle == "<STR_LIT>":<EOL><INDENT>if bbox_transmuter is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self._bbox_transmuter = bbox_transmuter<EOL><DEDENT>else:<EOL><INDENT>self.set_boxstyle(boxstyle)<EOL><DEDENT>self._mutation_scale=mutation_scale<EOL>self._mutation_aspect=mutation_aspect<EOL>

*xy* = lower left corner

*width*, *height*

*boxstyle* determines what kind of fancy box will be drawn. It
can be a string of the style name with a comma separated
attribute, or an instance of :class:`BoxStyle`. Following box
styles are available.

%(AvailableBoxstyles)s

*mutation_scale* : a value with which attributes of boxstyle
(e.g., pad) will be scaled. default=1.

*mutation_aspect* : The height of the rectangle will be
squeezed by this value before the mutation and the mutated
box will be stretched by the inverse of it. default=None.

Valid kwargs are:
%(Patch)s


def set_boxstyle(self, boxstyle=None, **kw):

if boxstyle==None:<EOL><INDENT>return BoxStyle.pprint_styles()<EOL><DEDENT>if isinstance(boxstyle, BoxStyle._Base):<EOL><INDENT>self._bbox_transmuter = boxstyle<EOL><DEDENT>elif callable(boxstyle):<EOL><INDENT>self._bbox_transmuter = boxstyle<EOL><DEDENT>else:<EOL><INDENT>self._bbox_transmuter = BoxStyle(boxstyle, **kw)<EOL><DEDENT>

Set the box style.

*boxstyle* can be a string with boxstyle name with optional
comma-separated attributes. Alternatively, the attrs can
be provided as keywords::

    set_boxstyle("round,pad=0.2")
    set_boxstyle("round", pad=0.2)

Old attrs simply are forgotten.

Without argument (or with *boxstyle* = None), it returns
available box styles.

ACCEPTS: [ %(AvailableBoxstyles)s ]


return self._mutation_scale<EOL>


Set the aspect ratio of the bbox mutation.

ACCEPTS: float


return self._mutation_aspect<EOL>

Return the aspect ratio of the bbox mutation.


return self._bbox_transmuter<EOL>


_path = self.get_boxstyle()(self._x, self._y,<EOL>self._width, self._height,<EOL>self.get_mutation_scale(),<EOL>self.get_mutation_aspect())<EOL>return _path<EOL>

Return the mutated path of the rectangle


return self._x<EOL>


return self._y<EOL>

Return the bottom coord of the rectangle


return self._width<EOL>


return self._height<EOL>


self._x = x<EOL>

Set the left coord of the rectangle

ACCEPTS: float


self._y = y<EOL>

Set the bottom coord of the rectangle

ACCEPTS: float


self._width = w<EOL>


self._height = h<EOL>


if len(args)==<NUM_LIT:0>:<EOL><INDENT>l,b,w,h = args[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>l,b,w,h = args<EOL><DEDENT>self._x = l<EOL>self._y = b<EOL>self._width = w<EOL>self._height = h<EOL>

Set the bounds of the rectangle: l,b,w,h

ACCEPTS: (left, bottom, width, height)


if posA is not None and posB is not None and path is None:<EOL><INDENT>self._posA_posB = [posA, posB]<EOL>if connectionstyle is None:<EOL><INDENT>connectionstyle = "<STR_LIT>"<EOL><DEDENT>self.set_connectionstyle(connectionstyle)<EOL><DEDENT>elif posA is None and posB is None and path is not None:<EOL><INDENT>self._posA_posB = None<EOL>self._connetors = None<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.patchA = patchA<EOL>self.patchB = patchB<EOL>self.shrinkA = shrinkA<EOL>self.shrinkB = shrinkB<EOL>Patch.__init__(self, **kwargs)<EOL>self._path_original = path<EOL>self.set_arrowstyle(arrowstyle)<EOL>self._mutation_scale=mutation_scale<EOL>self._mutation_aspect=mutation_aspect<EOL>

If *posA* and *posB* is given, a path connecting two point are
created according to the connectionstyle. The path will be
clipped with *patchA* and *patchB* and further shirnked by
*shrinkA* and *shrinkB*. An arrow is drawn along this
resulting path using the *arrowstyle* parameter. If *path*
provided, an arrow is drawn along this path and *patchA*,
*patchB*, *shrinkA*, and *shrinkB* are ignored.

The *connectionstyle* describes how *posA* and *posB* are
connected. It can be an instance of the ConnectionStyle class
(matplotlib.patches.ConnectionStlye) or a string of the
connectionstyle name, with optional comma-separated
attributes.  The following connection styles are available.

%(AvailableConnectorstyles)s

The *arrowstyle* describes how the fancy arrow will be
drawn. It can be string of the available arrowstyle names,
with optional comma-separated attributes, or one of the
ArrowStyle instance. The optional attributes are meant to be
scaled with the *mutation_scale*. The following arrow styles are
available.

%(AvailableArrowstyles)s

*mutation_scale* : a value with which attributes of arrowstyle
    (e.g., head_length) will be scaled. default=1.

*mutation_aspect* : The height of the rectangle will be
    squeezed by this value before the mutation and the mutated
    box will be stretched by the inverse of it. default=None.

Valid kwargs are:
%(Patch)s


if posA is not None: self._posA_posB[<NUM_LIT:0>] = posA<EOL>if posB is not None: self._posA_posB[<NUM_LIT:1>] = posB<EOL>

set the begin end end positions of the connecting
        path. Use current vlaue if None.


self.patchA = patchA<EOL>


self.patchB = patchB<EOL>


def set_connectionstyle(self, connectionstyle, **kw):

if connectionstyle==None:<EOL><INDENT>return ConnectionStyle.pprint_styles()<EOL><DEDENT>if isinstance(connectionstyle, ConnectionStyle._Base):<EOL><INDENT>self._connector = connectionstyle<EOL><DEDENT>elif callable(connectionstyle):<EOL><INDENT>self._connector = connectionstyle<EOL><DEDENT>else:<EOL><INDENT>self._connector = ConnectionStyle(connectionstyle, **kw)<EOL><DEDENT>

Set the connection style.

*connectionstyle* can be a string with connectionstyle name with optional
 comma-separated attributes. Alternatively, the attrs can
 be probided as keywords.

 set_connectionstyle("arc,angleA=0,armA=30,rad=10")
 set_connectionstyle("arc", angleA=0,armA=30,rad=10)

Old attrs simply are forgotten.

Without argument (or with connectionstyle=None), return
available styles as a list of strings.


return self._connector<EOL>


def set_arrowstyle(self, arrowstyle=None, **kw):

if arrowstyle==None:<EOL><INDENT>return ArrowStyle.pprint_styles()<EOL><DEDENT>if isinstance(arrowstyle, ConnectionStyle._Base):<EOL><INDENT>self._arrow_transmuter = arrowstyle<EOL><DEDENT>else:<EOL><INDENT>self._arrow_transmuter = ArrowStyle(arrowstyle, **kw)<EOL><DEDENT>

Set the arrow style.

*arrowstyle* can be a string with arrowstyle name with optional
 comma-separated attributes. Alternatively, the attrs can
 be provided as keywords.

 set_arrowstyle("Fancy,head_length=0.2")
 set_arrowstyle("fancy", head_length=0.2)

Old attrs simply are forgotten.

Without argument (or with arrowstyle=None), return
available box styles as a list of strings.


return self._arrow_transmuter<EOL>


return self._mutation_scale<EOL>


return self._mutation_aspect<EOL>


_path = self.get_path_in_displaycoord()<EOL>return self.get_transform().inverted().transform_path(_path)<EOL>

return the path of the arrow in the data coordinate. Use
get_path_in_displaycoord() medthod to retrieve the arrow path
in the disaply coord.


if self._posA_posB is not None:<EOL><INDENT>posA = self.get_transform().transform_point(self._posA_posB[<NUM_LIT:0>])<EOL>posB = self.get_transform().transform_point(self._posA_posB[<NUM_LIT:1>])<EOL>_path = self.get_connectionstyle()(posA, posB,<EOL>patchA=self.patchA,<EOL>patchB=self.patchB,<EOL>shrinkA=self.shrinkA,<EOL>shrinkB=self.shrinkB<EOL>)<EOL><DEDENT>else:<EOL><INDENT>_path = self.get_transform().transform_path(self._path_original)<EOL><DEDENT>_path, closed = self.get_arrowstyle()(_path,<EOL>self.get_mutation_scale(),<EOL>self.get_linewidth(),<EOL>self.get_mutation_aspect()<EOL>)<EOL>if not closed:<EOL><INDENT>self.fill = False<EOL><DEDENT>return _path<EOL>

Return the mutated path of the arrow in the display coord


def __init__(self, axes, loc, label,<EOL>size   = None,  <EOL>gridOn = None, <EOL>tick1On = True,<EOL>tick2On = True,<EOL>label1On = True,<EOL>label2On = False,<EOL>major = True,<EOL>):

artist.Artist.__init__(self)<EOL>if gridOn is None: gridOn = rcParams['<STR_LIT>']<EOL>self.set_figure(axes.figure)<EOL>self.axes = axes<EOL>name = self.__name__.lower()<EOL>if size is None:<EOL><INDENT>if major:<EOL><INDENT>size = rcParams['<STR_LIT>'%name]<EOL>pad = rcParams['<STR_LIT>'%name]<EOL><DEDENT>else:<EOL><INDENT>size = rcParams['<STR_LIT>'%name]<EOL>pad = rcParams['<STR_LIT>'%name]<EOL><DEDENT><DEDENT>self._tickdir = rcParams['<STR_LIT>'%name]<EOL>if self._tickdir == '<STR_LIT>':<EOL><INDENT>self._xtickmarkers = (mlines.TICKUP, mlines.TICKDOWN)<EOL>self._ytickmarkers = (mlines.TICKRIGHT, mlines.TICKLEFT)<EOL>self._pad = pad<EOL><DEDENT>else:<EOL><INDENT>self._xtickmarkers = (mlines.TICKDOWN, mlines.TICKUP)<EOL>self._ytickmarkers = (mlines.TICKLEFT, mlines.TICKRIGHT)<EOL>self._pad = pad + size<EOL><DEDENT>self._loc = loc<EOL>self._size = size<EOL>self.tick1line = self._get_tick1line()<EOL>self.tick2line = self._get_tick2line()<EOL>self.gridline = self._get_gridline()<EOL>self.label1 = self._get_text1()<EOL>self.label = self.label1  <EOL>self.label2 = self._get_text2()<EOL>self.gridOn = gridOn<EOL>self.tick1On = tick1On<EOL>self.tick2On = tick2On<EOL>self.label1On = label1On<EOL>self.label2On = label2On<EOL>self.update_position(loc)<EOL>

bbox is the Bound2D bounding box in display coords of the Axes
loc is the tick location in data coords
size is the tick size in relative, axes coords


if callable(self._contains): return self._contains(self,mouseevent)<EOL>return False,{}<EOL>

Test whether the mouse event occured in the Tick marks.

This function always returns false.  It is more useful to test if the
axis as a whole contains the mouse rather than the set of tick marks.


self._pad = val<EOL>

Set the tick label pad in points

ACCEPTS: float


return self._pad<EOL>

Get the value of the tick label pad in points


pass<EOL>


pass<EOL>

Get the default line2D instance for tick1


pass<EOL>

Get the default line2D instance for tick2


pass<EOL>

Get the default grid Line2d instance for this tick


return self._loc<EOL>

Return the tick location (data coords) as a scalar


Set the text of ticklabel2

ACCEPTS: str


raise NotImplementedError('<STR_LIT>')<EOL>

return the view Interval instance for the axis this tick is ticking


<EOL>trans, vert, horiz = self.axes.get_xaxis_text1_transform(self._pad)<EOL>size = rcParams['<STR_LIT>']<EOL>t = mtext.Text(<EOL>x=<NUM_LIT:0>, y=<NUM_LIT:0>,<EOL>fontproperties=font_manager.FontProperties(size=size),<EOL>color=rcParams['<STR_LIT>'],<EOL>verticalalignment=vert,<EOL>horizontalalignment=horiz,<EOL>)<EOL>t.set_transform(trans)<EOL>self._set_artist_props(t)<EOL>return t<EOL>


<EOL>trans, vert, horiz = self.axes.get_xaxis_text2_transform(self._pad)<EOL>t = mtext.Text(<EOL>x=<NUM_LIT:0>, y=<NUM_LIT:1>,<EOL>fontproperties=font_manager.FontProperties(size=rcParams['<STR_LIT>']),<EOL>color=rcParams['<STR_LIT>'],<EOL>verticalalignment=vert,<EOL>horizontalalignment=horiz,<EOL>)<EOL>t.set_transform(trans)<EOL>self._set_artist_props(t)<EOL>return t<EOL>


<EOL>l = mlines.Line2D(xdata=(<NUM_LIT:0>,), ydata=(<NUM_LIT:0>,),<EOL>color='<STR_LIT:k>',<EOL>linestyle = '<STR_LIT:None>',<EOL>marker = self._xtickmarkers[<NUM_LIT:0>],<EOL>markersize=self._size,<EOL>)<EOL>l.set_transform(self.axes.get_xaxis_transform())<EOL>self._set_artist_props(l)<EOL>return l<EOL>


<EOL>l = mlines.Line2D( xdata=(<NUM_LIT:0>,), ydata=(<NUM_LIT:1>,),<EOL>color='<STR_LIT:k>',<EOL>linestyle = '<STR_LIT:None>',<EOL>marker = self._xtickmarkers[<NUM_LIT:1>],<EOL>markersize=self._size,<EOL>)<EOL>l.set_transform(self.axes.get_xaxis_transform())<EOL>self._set_artist_props(l)<EOL>return l<EOL>


<EOL>l = mlines.Line2D(xdata=(<NUM_LIT:0.0>, <NUM_LIT:0.0>), ydata=(<NUM_LIT:0>, <NUM_LIT:1.0>),<EOL>color=rcParams['<STR_LIT>'],<EOL>linestyle=rcParams['<STR_LIT>'],<EOL>linewidth=rcParams['<STR_LIT>'],<EOL>)<EOL>l.set_transform(self.axes.get_xaxis_transform())<EOL>self._set_artist_props(l)<EOL>return l<EOL>


x = loc<EOL>nonlinear = (hasattr(self.axes, '<STR_LIT>') and<EOL>self.axes.yaxis.get_scale() != '<STR_LIT>' or<EOL>hasattr(self.axes, '<STR_LIT>') and<EOL>self.axes.xaxis.get_scale() != '<STR_LIT>')<EOL>if self.tick1On:<EOL><INDENT>self.tick1line.set_xdata((x,))<EOL><DEDENT>if self.tick2On:<EOL><INDENT>self.tick2line.set_xdata((x,))<EOL><DEDENT>if self.gridOn:<EOL><INDENT>self.gridline.set_xdata((x,))<EOL><DEDENT>if self.label1On:<EOL><INDENT>self.label1.set_x(x)<EOL><DEDENT>if self.label2On:<EOL><INDENT>self.label2.set_x(x)<EOL><DEDENT>if nonlinear:<EOL><INDENT>self.tick1line._invalid = True<EOL>self.tick2line._invalid = True<EOL>self.gridline._invalid = True<EOL><DEDENT>self._loc = loc<EOL>

Set the location of tick in data coords with scalar *loc*


return self.axes.viewLim.intervalx<EOL>

return the Interval instance for this axis view limits


return self.axes.dataLim.intervalx<EOL>

return the Interval instance for this axis data limits


<EOL>trans, vert, horiz = self.axes.get_yaxis_text1_transform(self._pad)<EOL>t = mtext.Text(<EOL>x=<NUM_LIT:0>, y=<NUM_LIT:0>,<EOL>fontproperties=font_manager.FontProperties(size=rcParams['<STR_LIT>']),<EOL>color=rcParams['<STR_LIT>'],<EOL>verticalalignment=vert,<EOL>horizontalalignment=horiz,<EOL>)<EOL>t.set_transform(trans)<EOL>self._set_artist_props(t)<EOL>return t<EOL>


<EOL>trans, vert, horiz = self.axes.get_yaxis_text2_transform(self._pad)<EOL>t = mtext.Text(<EOL>x=<NUM_LIT:1>, y=<NUM_LIT:0>,<EOL>fontproperties=font_manager.FontProperties(size=rcParams['<STR_LIT>']),<EOL>color=rcParams['<STR_LIT>'],<EOL>verticalalignment=vert,<EOL>horizontalalignment=horiz,<EOL>)<EOL>t.set_transform(trans)<EOL>self._set_artist_props(t)<EOL>return t<EOL>


<EOL>l = mlines.Line2D( (<NUM_LIT:0>,), (<NUM_LIT:0>,), color='<STR_LIT:k>',<EOL>marker = self._ytickmarkers[<NUM_LIT:0>],<EOL>linestyle = '<STR_LIT:None>',<EOL>markersize=self._size,<EOL>)<EOL>l.set_transform(self.axes.get_yaxis_transform())<EOL>self._set_artist_props(l)<EOL>return l<EOL>


<EOL>l = mlines.Line2D( (<NUM_LIT:1>,), (<NUM_LIT:0>,), color='<STR_LIT:k>',<EOL>marker = self._ytickmarkers[<NUM_LIT:1>],<EOL>linestyle = '<STR_LIT:None>',<EOL>markersize=self._size,<EOL>)<EOL>l.set_transform(self.axes.get_yaxis_transform())<EOL>self._set_artist_props(l)<EOL>return l<EOL>


<EOL>l = mlines.Line2D( xdata=(<NUM_LIT:0>,<NUM_LIT:1>), ydata=(<NUM_LIT:0>, <NUM_LIT:0>),<EOL>color=rcParams['<STR_LIT>'],<EOL>linestyle=rcParams['<STR_LIT>'],<EOL>linewidth=rcParams['<STR_LIT>'],<EOL>)<EOL>l.set_transform(self.axes.get_yaxis_transform())<EOL>self._set_artist_props(l)<EOL>return l<EOL>


y = loc<EOL>nonlinear = (hasattr(self.axes, '<STR_LIT>') and<EOL>self.axes.yaxis.get_scale() != '<STR_LIT>' or<EOL>hasattr(self.axes, '<STR_LIT>') and<EOL>self.axes.xaxis.get_scale() != '<STR_LIT>')<EOL>if self.tick1On:<EOL><INDENT>self.tick1line.set_ydata((y,))<EOL><DEDENT>if self.tick2On:<EOL><INDENT>self.tick2line.set_ydata((y,))<EOL><DEDENT>if self.gridOn:<EOL><INDENT>self.gridline.set_ydata((y, ))<EOL><DEDENT>if self.label1On:<EOL><INDENT>self.label1.set_y( y )<EOL><DEDENT>if self.label2On:<EOL><INDENT>self.label2.set_y( y )<EOL><DEDENT>if nonlinear:<EOL><INDENT>self.tick1line._invalid = True<EOL>self.tick2line._invalid = True<EOL>self.gridline._invalid = True<EOL><DEDENT>self._loc = loc<EOL>

Set the location of tick in data coords with scalar loc


return self.axes.viewLim.intervaly<EOL>


return self.axes.dataLim.intervaly<EOL>


def __init__(self, axes, pickradius=<NUM_LIT:15>):

artist.Artist.__init__(self)<EOL>self.set_figure(axes.figure)<EOL>self.axes = axes<EOL>self.major = Ticker()<EOL>self.minor = Ticker()<EOL>self.callbacks = cbook.CallbackRegistry(('<STR_LIT>', '<STR_LIT>'))<EOL>self._autolabelpos = True<EOL>self.label = self._get_label()<EOL>self.offsetText = self._get_offset_text()<EOL>self.majorTicks = []<EOL>self.minorTicks = []<EOL>self.pickradius = pickradius<EOL>self.cla()<EOL>self.set_scale('<STR_LIT>')<EOL>

Init the axis with the parent Axes instance


def set_label_coords(self, x, y, transform=None):

self._autolabelpos = False<EOL>if transform is None:<EOL><INDENT>transform = self.axes.transAxes<EOL><DEDENT>self.label.set_transform(transform)<EOL>self.label.set_position((x, y))<EOL>

Set the coordinates of the label.  By default, the x
coordinate of the y label is determined by the tick label
bounding boxes, but this can lead to poor alignment of
multiple ylabels if there are multiple axes.  Ditto for the y
coodinate of the x label.

You can also specify the coordinate system of the label with
the transform.  If None, the default coordinate system will be
the axes coordinate system (0,0) is (left,bottom), (0.5, 0.5)
is middle, etc


self.set_major_locator(mticker.AutoLocator())<EOL>self.set_major_formatter(mticker.ScalarFormatter())<EOL>self.set_minor_locator(mticker.NullLocator())<EOL>self.set_minor_formatter(mticker.NullFormatter())<EOL>self.callbacks = cbook.CallbackRegistry(('<STR_LIT>', '<STR_LIT>'))<EOL>self._gridOnMajor = rcParams['<STR_LIT>']<EOL>self._gridOnMinor = False<EOL>self.label.set_text('<STR_LIT>')<EOL>self._set_artist_props(self.label)<EOL>cbook.popall(self.majorTicks)<EOL>cbook.popall(self.minorTicks)<EOL>self.majorTicks.extend([self._get_tick(major=True)])<EOL>self.minorTicks.extend([self._get_tick(major=False)])<EOL>self._lastNumMajorTicks = <NUM_LIT:1><EOL>self._lastNumMinorTicks = <NUM_LIT:1><EOL>self.converter = None<EOL>self.units = None<EOL>self.set_units(None)<EOL>


majorLocs = self.major.locator()<EOL>majorTicks = self.get_major_ticks(len(majorLocs))<EOL>self.major.formatter.set_locs(majorLocs)<EOL>majorLabels = [self.major.formatter(val, i) for i, val in enumerate(majorLocs)]<EOL>minorLocs = self.minor.locator()<EOL>minorTicks = self.get_minor_ticks(len(minorLocs))<EOL>self.minor.formatter.set_locs(minorLocs)<EOL>minorLabels = [self.minor.formatter(val, i) for i, val in enumerate(minorLocs)]<EOL>major_minor = [<EOL>(majorTicks, majorLocs, majorLabels),<EOL>(minorTicks, minorLocs, minorLabels)]<EOL>for group in major_minor:<EOL><INDENT>for tick in zip(*group):<EOL><INDENT>yield tick<EOL><DEDENT><DEDENT>

Iterate through all of the major and minor ticks.


ticklabelBoxes = []<EOL>ticklabelBoxes2 = []<EOL>interval = self.get_view_interval()<EOL>for tick, loc, label in self.iter_ticks():<EOL><INDENT>if tick is None: continue<EOL>if not mtransforms.interval_contains(interval, loc): continue<EOL>tick.update_position(loc)<EOL>tick.set_label1(label)<EOL>tick.set_label2(label)<EOL>if tick.label1On and tick.label1.get_visible():<EOL><INDENT>extent = tick.label1.get_window_extent(renderer)<EOL>ticklabelBoxes.append(extent)<EOL><DEDENT>if tick.label2On and tick.label2.get_visible():<EOL><INDENT>extent = tick.label2.get_window_extent(renderer)<EOL>ticklabelBoxes2.append(extent)<EOL><DEDENT><DEDENT>if len(ticklabelBoxes):<EOL><INDENT>bbox = mtransforms.Bbox.union(ticklabelBoxes)<EOL><DEDENT>else:<EOL><INDENT>bbox = mtransforms.Bbox.from_extents(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>)<EOL><DEDENT>if len(ticklabelBoxes2):<EOL><INDENT>bbox2 = mtransforms.Bbox.union(ticklabelBoxes2)<EOL><DEDENT>else:<EOL><INDENT>bbox2 = mtransforms.Bbox.from_extents(<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>)<EOL><DEDENT>return bbox, bbox2<EOL>

Get the extents of the tick labels on either side
of the axes.


def draw(self, renderer, *args, **kwargs):

ticklabelBoxes = []<EOL>ticklabelBoxes2 = []<EOL>if not self.get_visible(): return<EOL>renderer.open_group(__name__)<EOL>interval = self.get_view_interval()<EOL>for tick, loc, label in self.iter_ticks():<EOL><INDENT>if tick is None: continue<EOL>if not mtransforms.interval_contains(interval, loc): continue<EOL>tick.update_position(loc)<EOL>tick.set_label1(label)<EOL>tick.set_label2(label)<EOL>tick.draw(renderer)<EOL>if tick.label1On and tick.label1.get_visible():<EOL><INDENT>extent = tick.label1.get_window_extent(renderer)<EOL>ticklabelBoxes.append(extent)<EOL><DEDENT>if tick.label2On and tick.label2.get_visible():<EOL><INDENT>extent = tick.label2.get_window_extent(renderer)<EOL>ticklabelBoxes2.append(extent)<EOL><DEDENT><DEDENT>self._update_label_position(ticklabelBoxes, ticklabelBoxes2)<EOL>self.label.draw(renderer)<EOL>self._update_offset_text_position(ticklabelBoxes, ticklabelBoxes2)<EOL>self.offsetText.set_text( self.major.formatter.get_offset() )<EOL>self.offsetText.draw(renderer)<EOL>if <NUM_LIT:0>: <EOL><INDENT>for tick in majorTicks:<EOL><INDENT>label = tick.label1<EOL>mpatches.bbox_artist(label, renderer)<EOL><DEDENT>mpatches.bbox_artist(self.label, renderer)<EOL><DEDENT>renderer.close_group(__name__)<EOL>

Draw the axis lines, grid lines, tick lines and labels


ticks = self.get_major_ticks()<EOL>return cbook.silent_list('<STR_LIT>', [tick.gridline for tick in ticks])<EOL>

Return the grid lines as a list of Line2D instance


return self.label<EOL>

Return the axis label as a Text instance


return self.offsetText<EOL>

Return the axis offsetText as a Text instance


return self.pickradius<EOL>

Return the depth of the axis used by the picker


ticks = self.get_major_ticks()<EOL>labels1 = [tick.label1 for tick in ticks if tick.label1On]<EOL>labels2 = [tick.label2 for tick in ticks if tick.label2On]<EOL>return cbook.silent_list('<STR_LIT>', labels1+labels2)<EOL>

Return a list of Text instances for the major ticklabels


ticks = self.get_minor_ticks()<EOL>labels1 = [tick.label1 for tick in ticks if tick.label1On]<EOL>labels2 = [tick.label2 for tick in ticks if tick.label2On]<EOL>return cbook.silent_list('<STR_LIT>', labels1+labels2)<EOL>

Return a list of Text instances for the minor ticklabels


if minor:<EOL><INDENT>return self.get_minorticklabels()<EOL><DEDENT>return self.get_majorticklabels()<EOL>

Return a list of Text instances for ticklabels


lines = []<EOL>ticks = self.get_major_ticks()<EOL>for tick in ticks:<EOL><INDENT>lines.append(tick.tick1line)<EOL>lines.append(tick.tick2line)<EOL><DEDENT>return cbook.silent_list('<STR_LIT>', lines)<EOL>

Return the major tick lines as a list of Line2D instances


lines = []<EOL>ticks = self.get_minor_ticks()<EOL>for tick in ticks:<EOL><INDENT>lines.append(tick.tick1line)<EOL>lines.append(tick.tick2line)<EOL><DEDENT>return cbook.silent_list('<STR_LIT>', lines)<EOL>

Return the minor tick lines as a list of Line2D instances


if minor:<EOL><INDENT>return self.get_minorticklines()<EOL><DEDENT>return self.get_majorticklines()<EOL>

Return the tick lines as a list of Line2D instances


return self.major.locator()<EOL>

Get the major tick locations in data coordinates as a numpy array


return self.minor.locator()<EOL>

Get the minor tick locations in data coordinates as a numpy array


if minor:<EOL><INDENT>return self.minor.locator()<EOL><DEDENT>return self.major.locator()<EOL>

Get the tick locations in data coordinates as a numpy array


raise NotImplementedError('<STR_LIT>')<EOL>


if src is None or dest is None: return<EOL>dest.label1.update_from(src.label1)<EOL>dest.label2.update_from(src.label2)<EOL>dest.tick1line.update_from(src.tick1line)<EOL>dest.tick2line.update_from(src.tick2line)<EOL>dest.gridline.update_from(src.gridline)<EOL>dest.tick1On = src.tick1On<EOL>dest.tick2On = src.tick2On<EOL>dest.label1On = src.label1On<EOL>dest.label2On = src.label2On<EOL>

Copy the props from src tick to dest tick


return self.major.locator<EOL>


return self.minor.locator<EOL>


return self.major.formatter<EOL>


return self.minor.formatter<EOL>


if numticks is None:<EOL><INDENT>numticks = len(self.get_major_locator()())<EOL><DEDENT>if len(self.majorTicks) < numticks:<EOL><INDENT>for i in range(numticks - len(self.majorTicks)):<EOL><INDENT>tick = self._get_tick(major=True)<EOL>self.majorTicks.append(tick)<EOL><DEDENT><DEDENT>if self._lastNumMajorTicks < numticks:<EOL><INDENT>protoTick = self.majorTicks[<NUM_LIT:0>]<EOL>for i in range(self._lastNumMajorTicks, len(self.majorTicks)):<EOL><INDENT>tick = self.majorTicks[i]<EOL>if self._gridOnMajor: tick.gridOn = True<EOL>self._copy_tick_props(protoTick, tick)<EOL><DEDENT><DEDENT>self._lastNumMajorTicks = numticks<EOL>ticks = self.majorTicks[:numticks]<EOL>return ticks<EOL>

get the tick instances; grow as necessary


if numticks is None:<EOL><INDENT>numticks = len(self.get_minor_locator()())<EOL><DEDENT>if len(self.minorTicks) < numticks:<EOL><INDENT>for i in range(numticks - len(self.minorTicks)):<EOL><INDENT>tick = self._get_tick(major=False)<EOL>self.minorTicks.append(tick)<EOL><DEDENT><DEDENT>if self._lastNumMinorTicks < numticks:<EOL><INDENT>protoTick = self.minorTicks[<NUM_LIT:0>]<EOL>for i in range(self._lastNumMinorTicks, len(self.minorTicks)):<EOL><INDENT>tick = self.minorTicks[i]<EOL>if self._gridOnMinor: tick.gridOn = True<EOL>self._copy_tick_props(protoTick, tick)<EOL><DEDENT><DEDENT>self._lastNumMinorTicks = numticks<EOL>ticks = self.minorTicks[:numticks]<EOL>return ticks<EOL>

get the minor tick instances; grow as necessary