Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
ParseResults.haskeys
( self )
Since keys() returns an iterator, this method is helpful in bypassing code that looks for the existence of any defined results names.
Since keys() returns an iterator, this method is helpful in bypassing code that looks for the existence of any defined results names.
def haskeys( self ): """Since keys() returns an iterator, this method is helpful in bypassing code that looks for the existence of any defined results names.""" return bool(self.__tokdict)
[ "def", "haskeys", "(", "self", ")", ":", "return", "bool", "(", "self", ".", "__tokdict", ")" ]
[ 505, 4 ]
[ 508, 35 ]
python
en
['en', 'en', 'en']
True
ParseResults.pop
( self, *args, **kwargs)
Removes and returns item at specified index (default=C{last}). Supports both C{list} and C{dict} semantics for C{pop()}. If passed no argument or an integer argument, it will use C{list} semantics and pop tokens from the list of parsed tokens. If passed a non-integer argum...
Removes and returns item at specified index (default=C{last}). Supports both C{list} and C{dict} semantics for C{pop()}. If passed no argument or an integer argument, it will use C{list} semantics and pop tokens from the list of parsed tokens. If passed a non-integer argum...
def pop( self, *args, **kwargs): """ Removes and returns item at specified index (default=C{last}). Supports both C{list} and C{dict} semantics for C{pop()}. If passed no argument or an integer argument, it will use C{list} semantics and pop tokens from the list of parsed to...
[ "def", "pop", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "args", ":", "args", "=", "[", "-", "1", "]", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "k", "==", "'default'", ":",...
[ 510, 4 ]
[ 560, 31 ]
python
en
['en', 'ja', 'th']
False
ParseResults.get
(self, key, defaultValue=None)
Returns named result matching the given key, or if there is no such name, then returns the given C{defaultValue} or C{None} if no C{defaultValue} is specified. Similar to C{dict.get()}. Example:: integer = Word(nums) date_str = integer(...
Returns named result matching the given key, or if there is no such name, then returns the given C{defaultValue} or C{None} if no C{defaultValue} is specified. Similar to C{dict.get()}. Example:: integer = Word(nums) date_str = integer(...
def get(self, key, defaultValue=None): """ Returns named result matching the given key, or if there is no such name, then returns the given C{defaultValue} or C{None} if no C{defaultValue} is specified. Similar to C{dict.get()}. Example:: in...
[ "def", "get", "(", "self", ",", "key", ",", "defaultValue", "=", "None", ")", ":", "if", "key", "in", "self", ":", "return", "self", "[", "key", "]", "else", ":", "return", "defaultValue" ]
[ 562, 4 ]
[ 582, 31 ]
python
en
['en', 'ja', 'th']
False
ParseResults.insert
( self, index, insStr )
Inserts new element at location index in the list of parsed tokens. Similar to C{list.insert()}. Example:: print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] # use a parse action to insert the parse location in the front of ...
Inserts new element at location index in the list of parsed tokens. Similar to C{list.insert()}. Example:: print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] # use a parse action to insert the parse location in the front of ...
def insert( self, index, insStr ): """ Inserts new element at location index in the list of parsed tokens. Similar to C{list.insert()}. Example:: print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] # use a parse actio...
[ "def", "insert", "(", "self", ",", "index", ",", "insStr", ")", ":", "self", ".", "__toklist", ".", "insert", "(", "index", ",", "insStr", ")", "# fixup indices in token dictionary\r", "for", "name", ",", "occurrences", "in", "self", ".", "__tokdict", ".", ...
[ 584, 4 ]
[ 602, 94 ]
python
en
['en', 'ja', 'th']
False
ParseResults.append
( self, item )
Add single element to end of ParseResults list of elements. Example:: print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] # use a parse action to compute the sum of the parsed integers, and add it to the end def append_...
Add single element to end of ParseResults list of elements. Example:: print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] # use a parse action to compute the sum of the parsed integers, and add it to the end def append_...
def append( self, item ): """ Add single element to end of ParseResults list of elements. Example:: print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321'] # use a parse action to compute the sum of the parsed integers, and add ...
[ "def", "append", "(", "self", ",", "item", ")", ":", "self", ".", "__toklist", ".", "append", "(", "item", ")" ]
[ 604, 4 ]
[ 616, 35 ]
python
en
['en', 'ja', 'th']
False
ParseResults.extend
( self, itemseq )
Add sequence of elements to end of ParseResults list of elements. Example:: patt = OneOrMore(Word(alphas)) # use a parse action to append the reverse of the matched strings, to make a palindrome def make_palindrome(tokens): token...
Add sequence of elements to end of ParseResults list of elements. Example:: patt = OneOrMore(Word(alphas)) # use a parse action to append the reverse of the matched strings, to make a palindrome def make_palindrome(tokens): token...
def extend( self, itemseq ): """ Add sequence of elements to end of ParseResults list of elements. Example:: patt = OneOrMore(Word(alphas)) # use a parse action to append the reverse of the matched strings, to make a palindrome def make_p...
[ "def", "extend", "(", "self", ",", "itemseq", ")", ":", "if", "isinstance", "(", "itemseq", ",", "ParseResults", ")", ":", "self", "+=", "itemseq", "else", ":", "self", ".", "__toklist", ".", "extend", "(", "itemseq", ")" ]
[ 618, 4 ]
[ 634, 42 ]
python
en
['en', 'ja', 'th']
False
ParseResults.clear
( self )
Clear all elements and results names.
Clear all elements and results names.
def clear( self ): """ Clear all elements and results names. """ del self.__toklist[:] self.__tokdict.clear()
[ "def", "clear", "(", "self", ")", ":", "del", "self", ".", "__toklist", "[", ":", "]", "self", ".", "__tokdict", ".", "clear", "(", ")" ]
[ 636, 4 ]
[ 641, 30 ]
python
en
['en', 'ja', 'th']
False
ParseResults.asList
( self )
Returns the parse results as a nested list of matching tokens, all converted to strings. Example:: patt = OneOrMore(Word(alphas)) result = patt.parseString("sldkj lsdkj sldkj") # even though the result prints in string-like form, it is actually a pyparsing Par...
Returns the parse results as a nested list of matching tokens, all converted to strings. Example:: patt = OneOrMore(Word(alphas)) result = patt.parseString("sldkj lsdkj sldkj") # even though the result prints in string-like form, it is actually a pyparsing Par...
def asList( self ): """ Returns the parse results as a nested list of matching tokens, all converted to strings. Example:: patt = OneOrMore(Word(alphas)) result = patt.parseString("sldkj lsdkj sldkj") # even though the result prints in string-like form...
[ "def", "asList", "(", "self", ")", ":", "return", "[", "res", ".", "asList", "(", ")", "if", "isinstance", "(", "res", ",", "ParseResults", ")", "else", "res", "for", "res", "in", "self", ".", "__toklist", "]" ]
[ 703, 4 ]
[ 717, 96 ]
python
en
['en', 'ja', 'th']
False
ParseResults.asDict
( self )
Returns the named parse results as a nested dictionary. Example:: integer = Word(nums) date_str = integer("year") + '/' + integer("month") + '/' + integer("day") result = date_str.parseString('12/31/1999') print(type(result), repr(re...
Returns the named parse results as a nested dictionary. Example:: integer = Word(nums) date_str = integer("year") + '/' + integer("month") + '/' + integer("day") result = date_str.parseString('12/31/1999') print(type(result), repr(re...
def asDict( self ): """ Returns the named parse results as a nested dictionary. Example:: integer = Word(nums) date_str = integer("year") + '/' + integer("month") + '/' + integer("day") result = date_str.parseString('12/31/1999') ...
[ "def", "asDict", "(", "self", ")", ":", "if", "PY_3", ":", "item_fn", "=", "self", ".", "items", "else", ":", "item_fn", "=", "self", ".", "iteritems", "def", "toItem", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "ParseResults", ")", ...
[ 719, 4 ]
[ 752, 55 ]
python
en
['en', 'ja', 'th']
False
ParseResults.copy
( self )
Returns a new copy of a C{ParseResults} object.
Returns a new copy of a C{ParseResults} object.
def copy( self ): """ Returns a new copy of a C{ParseResults} object. """ ret = ParseResults( self.__toklist ) ret.__tokdict = self.__tokdict.copy() ret.__parent = self.__parent ret.__accumNames.update( self.__accumNames ) ret.__name = self.__name ...
[ "def", "copy", "(", "self", ")", ":", "ret", "=", "ParseResults", "(", "self", ".", "__toklist", ")", "ret", ".", "__tokdict", "=", "self", ".", "__tokdict", ".", "copy", "(", ")", "ret", ".", "__parent", "=", "self", ".", "__parent", "ret", ".", "...
[ 754, 4 ]
[ 763, 18 ]
python
en
['en', 'ja', 'th']
False
ParseResults.asXML
( self, doctag=None, namedItemsOnly=False, indent="", formatted=True )
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
(Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names.
def asXML( self, doctag=None, namedItemsOnly=False, indent="", formatted=True ): """ (Deprecated) Returns the parse results as XML. Tags are created for tokens and lists that have defined results names. """ nl = "\n" out = [] namedItems = dict((v[1],k) for (k,vlist)...
[ "def", "asXML", "(", "self", ",", "doctag", "=", "None", ",", "namedItemsOnly", "=", "False", ",", "indent", "=", "\"\"", ",", "formatted", "=", "True", ")", ":", "nl", "=", "\"\\n\"", "out", "=", "[", "]", "namedItems", "=", "dict", "(", "(", "v",...
[ 765, 4 ]
[ 824, 27 ]
python
en
['en', 'ja', 'th']
False
ParseResults.getName
(self)
r""" Returns the results name for this token expression. Useful when several different expressions might match at a particular location. Example:: integer = Word(nums) ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d") house_number_expr = Suppress('#') + Word(...
r""" Returns the results name for this token expression. Useful when several different expressions might match at a particular location. Example:: integer = Word(nums) ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d") house_number_expr = Suppress('#') + Word(...
def getName(self): r""" Returns the results name for this token expression. Useful when several different expressions might match at a particular location. Example:: integer = Word(nums) ssn_expr = Regex(r"\d\d\d-\d\d-\d\d\d\d") house_number_...
[ "def", "getName", "(", "self", ")", ":", "if", "self", ".", "__name", ":", "return", "self", ".", "__name", "elif", "self", ".", "__parent", ":", "par", "=", "self", ".", "__parent", "(", ")", "if", "par", ":", "return", "par", ".", "__lookup", "("...
[ 833, 4 ]
[ 868, 23 ]
python
cy
['en', 'cy', 'hi']
False
ParseResults.dump
(self, indent='', depth=0, full=True)
Diagnostic method for listing out the contents of a C{ParseResults}. Accepts an optional C{indent} argument so that this string can be embedded in a nested display of other data. Example:: integer = Word(nums) date_str = integer("year") + '/' + integer("m...
Diagnostic method for listing out the contents of a C{ParseResults}. Accepts an optional C{indent} argument so that this string can be embedded in a nested display of other data. Example:: integer = Word(nums) date_str = integer("year") + '/' + integer("m...
def dump(self, indent='', depth=0, full=True): """ Diagnostic method for listing out the contents of a C{ParseResults}. Accepts an optional C{indent} argument so that this string can be embedded in a nested display of other data. Example:: integer = Word(nums)...
[ "def", "dump", "(", "self", ",", "indent", "=", "''", ",", "depth", "=", "0", ",", "full", "=", "True", ")", ":", "out", "=", "[", "]", "NL", "=", "'\\n'", "out", ".", "append", "(", "indent", "+", "_ustr", "(", "self", ".", "asList", "(", ")...
[ 870, 4 ]
[ 913, 27 ]
python
en
['en', 'ja', 'th']
False
ParseResults.pprint
(self, *args, **kwargs)
Pretty-printer for parsed results as a list, using the C{pprint} module. Accepts additional positional or keyword args as defined for the C{pprint.pprint} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pprint}) Example:: ident = Word(alphas, alphanums...
Pretty-printer for parsed results as a list, using the C{pprint} module. Accepts additional positional or keyword args as defined for the C{pprint.pprint} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pprint}) Example:: ident = Word(alphas, alphanums...
def pprint(self, *args, **kwargs): """ Pretty-printer for parsed results as a list, using the C{pprint} module. Accepts additional positional or keyword args as defined for the C{pprint.pprint} method. (U{http://docs.python.org/3/library/pprint.html#pprint.pprint}) Exampl...
[ "def", "pprint", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pprint", ".", "pprint", "(", "self", ".", "asList", "(", ")", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 915, 4 ]
[ 936, 53 ]
python
en
['en', 'ja', 'th']
False
ParserElement.setDefaultWhitespaceChars
( chars )
r""" Overrides the default whitespace chars Example:: # default whitespace chars are space, <TAB> and newline OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl'] # change to just treat newline as significant ...
r""" Overrides the default whitespace chars Example:: # default whitespace chars are space, <TAB> and newline OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl'] # change to just treat newline as significant ...
def setDefaultWhitespaceChars( chars ): r""" Overrides the default whitespace chars Example:: # default whitespace chars are space, <TAB> and newline OneOrMore(Word(alphas)).parseString("abc def\nghi jkl") # -> ['abc', 'def', 'ghi', 'jkl'] ...
[ "def", "setDefaultWhitespaceChars", "(", "chars", ")", ":", "ParserElement", ".", "DEFAULT_WHITE_CHARS", "=", "chars" ]
[ 1108, 4 ]
[ 1120, 49 ]
python
cy
['en', 'cy', 'hi']
False
ParserElement.inlineLiteralsUsing
(cls)
Set class to be used for inclusion of string literals into a parser. Example:: # default literal class used is Literal integer = Word(nums) date_str = integer("year") + '/' + integer("month") + '/' + integer("day") date_str.pa...
Set class to be used for inclusion of string literals into a parser. Example:: # default literal class used is Literal integer = Word(nums) date_str = integer("year") + '/' + integer("month") + '/' + integer("day") date_str.pa...
def inlineLiteralsUsing(cls): """ Set class to be used for inclusion of string literals into a parser. Example:: # default literal class used is Literal integer = Word(nums) date_str = integer("year") + '/' + integer("month") + '/' + integer("d...
[ "def", "inlineLiteralsUsing", "(", "cls", ")", ":", "ParserElement", ".", "_literalStringClass", "=", "cls" ]
[ 1123, 4 ]
[ 1141, 47 ]
python
en
['en', 'ja', 'th']
False
ParserElement.copy
( self )
Make a copy of this C{ParserElement}. Useful for defining different parse actions for the same parsing pattern, using copies of the original parse element. Example:: integer = Word(nums).setParseAction(lambda toks: int(toks[0])) integerK = integer.copy()....
Make a copy of this C{ParserElement}. Useful for defining different parse actions for the same parsing pattern, using copies of the original parse element. Example:: integer = Word(nums).setParseAction(lambda toks: int(toks[0])) integerK = integer.copy()....
def copy( self ): """ Make a copy of this C{ParserElement}. Useful for defining different parse actions for the same parsing pattern, using copies of the original parse element. Example:: integer = Word(nums).setParseAction(lambda toks: int(toks[0])) ...
[ "def", "copy", "(", "self", ")", ":", "cpy", "=", "copy", ".", "copy", "(", "self", ")", "cpy", ".", "parseAction", "=", "self", ".", "parseAction", "[", ":", "]", "cpy", ".", "ignoreExprs", "=", "self", ".", "ignoreExprs", "[", ":", "]", "if", "...
[ 1166, 4 ]
[ 1187, 18 ]
python
en
['en', 'ja', 'th']
False
ParserElement.setName
( self, name )
Define name for this expression, makes debugging and exception messages clearer. Example:: Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1) Word(nums).setName("integer").parseString("ABC") # -> Exception: Expected in...
Define name for this expression, makes debugging and exception messages clearer. Example:: Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1) Word(nums).setName("integer").parseString("ABC") # -> Exception: Expected in...
def setName( self, name ): """ Define name for this expression, makes debugging and exception messages clearer. Example:: Word(nums).parseString("ABC") # -> Exception: Expected W:(0123...) (at char 0), (line:1, col:1) Word(nums).setName("integer").parseStr...
[ "def", "setName", "(", "self", ",", "name", ")", ":", "self", ".", "name", "=", "name", "self", ".", "errmsg", "=", "\"Expected \"", "+", "self", ".", "name", "if", "hasattr", "(", "self", ",", "\"exception\"", ")", ":", "self", ".", "exception", "."...
[ 1189, 4 ]
[ 1201, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.setResultsName
( self, name, listAllMatches=False )
Define name for referencing matching tokens as a nested attribute of the returned parse results. NOTE: this returns a *copy* of the original C{ParserElement} object; this is so that the client can define a basic element, such as an integer, and reference it in multiple plac...
Define name for referencing matching tokens as a nested attribute of the returned parse results. NOTE: this returns a *copy* of the original C{ParserElement} object; this is so that the client can define a basic element, such as an integer, and reference it in multiple plac...
def setResultsName( self, name, listAllMatches=False ): """ Define name for referencing matching tokens as a nested attribute of the returned parse results. NOTE: this returns a *copy* of the original C{ParserElement} object; this is so that the client can define a basic ele...
[ "def", "setResultsName", "(", "self", ",", "name", ",", "listAllMatches", "=", "False", ")", ":", "newself", "=", "self", ".", "copy", "(", ")", "if", "name", ".", "endswith", "(", "\"*\"", ")", ":", "name", "=", "name", "[", ":", "-", "1", "]", ...
[ 1203, 4 ]
[ 1229, 22 ]
python
en
['en', 'ja', 'th']
False
ParserElement.setBreak
(self,breakFlag = True)
Method to invoke the Python pdb debugger when this element is about to be parsed. Set C{breakFlag} to True to enable, False to disable.
Method to invoke the Python pdb debugger when this element is about to be parsed. Set C{breakFlag} to True to enable, False to disable.
def setBreak(self,breakFlag = True): """Method to invoke the Python pdb debugger when this element is about to be parsed. Set C{breakFlag} to True to enable, False to disable. """ if breakFlag: _parseMethod = self._parse def breaker(instring, ...
[ "def", "setBreak", "(", "self", ",", "breakFlag", "=", "True", ")", ":", "if", "breakFlag", ":", "_parseMethod", "=", "self", ".", "_parse", "def", "breaker", "(", "instring", ",", "loc", ",", "doActions", "=", "True", ",", "callPreParse", "=", "True", ...
[ 1231, 4 ]
[ 1247, 19 ]
python
en
['en', 'en', 'en']
True
ParserElement.setParseAction
( self, *fns, **kwargs )
Define one or more actions to perform when successfully matching parse element definition. Parse action fn is a callable method with 0-3 arguments, called as C{fn(s,loc,toks)}, C{fn(loc,toks)}, C{fn(toks)}, or just C{fn()}, where: - s = the original string being parsed (see note ...
Define one or more actions to perform when successfully matching parse element definition. Parse action fn is a callable method with 0-3 arguments, called as C{fn(s,loc,toks)}, C{fn(loc,toks)}, C{fn(toks)}, or just C{fn()}, where: - s = the original string being parsed (see note ...
def setParseAction( self, *fns, **kwargs ): """ Define one or more actions to perform when successfully matching parse element definition. Parse action fn is a callable method with 0-3 arguments, called as C{fn(s,loc,toks)}, C{fn(loc,toks)}, C{fn(toks)}, or just C{fn()}, where: ...
[ "def", "setParseAction", "(", "self", ",", "*", "fns", ",", "*", "*", "kwargs", ")", ":", "self", ".", "parseAction", "=", "list", "(", "map", "(", "_trim_arity", ",", "list", "(", "fns", ")", ")", ")", "self", ".", "callDuringTry", "=", "kwargs", ...
[ 1249, 4 ]
[ 1285, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.addParseAction
( self, *fns, **kwargs )
Add one or more parse actions to expression's list of parse actions. See L{I{setParseAction}<setParseAction>}. See examples in L{I{copy}<copy>}.
Add one or more parse actions to expression's list of parse actions. See L{I{setParseAction}<setParseAction>}. See examples in L{I{copy}<copy>}.
def addParseAction( self, *fns, **kwargs ): """ Add one or more parse actions to expression's list of parse actions. See L{I{setParseAction}<setParseAction>}. See examples in L{I{copy}<copy>}. """ self.parseAction += list(map(_trim_arity, list(fns))) self....
[ "def", "addParseAction", "(", "self", ",", "*", "fns", ",", "*", "*", "kwargs", ")", ":", "self", ".", "parseAction", "+=", "list", "(", "map", "(", "_trim_arity", ",", "list", "(", "fns", ")", ")", ")", "self", ".", "callDuringTry", "=", "self", "...
[ 1287, 4 ]
[ 1295, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.addCondition
(self, *fns, **kwargs)
Add a boolean predicate function to expression's list of parse actions. See L{I{setParseAction}<setParseAction>} for function call signatures. Unlike C{setParseAction}, functions passed to C{addCondition} need to return boolean success/fail of the condition. Optional keyword arguments: ...
Add a boolean predicate function to expression's list of parse actions. See L{I{setParseAction}<setParseAction>} for function call signatures. Unlike C{setParseAction}, functions passed to C{addCondition} need to return boolean success/fail of the condition. Optional keyword arguments: ...
def addCondition(self, *fns, **kwargs): """Add a boolean predicate function to expression's list of parse actions. See L{I{setParseAction}<setParseAction>} for function call signatures. Unlike C{setParseAction}, functions passed to C{addCondition} need to return boolean success/fail of the ...
[ "def", "addCondition", "(", "self", ",", "*", "fns", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "kwargs", ".", "get", "(", "\"message\"", ",", "\"failed user-defined condition\"", ")", "exc_type", "=", "ParseFatalException", "if", "kwargs", ".", "get", ...
[ 1297, 4 ]
[ 1322, 19 ]
python
en
['en', 'en', 'en']
True
ParserElement.setFailAction
( self, fn )
Define action to perform if parsing fails at this expression. Fail acton fn is a callable function that takes the arguments C{fn(s,loc,expr,err)} where: - s = string being parsed - loc = location where expression match was attempted and failed - expr = the ...
Define action to perform if parsing fails at this expression. Fail acton fn is a callable function that takes the arguments C{fn(s,loc,expr,err)} where: - s = string being parsed - loc = location where expression match was attempted and failed - expr = the ...
def setFailAction( self, fn ): """Define action to perform if parsing fails at this expression. Fail acton fn is a callable function that takes the arguments C{fn(s,loc,expr,err)} where: - s = string being parsed - loc = location where expression match was atte...
[ "def", "setFailAction", "(", "self", ",", "fn", ")", ":", "self", ".", "failAction", "=", "fn", "return", "self" ]
[ 1324, 4 ]
[ 1335, 19 ]
python
en
['en', 'en', 'en']
True
ParserElement.enablePackrat
(cache_size_limit=128)
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 ...
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 ...
def enablePackrat(cache_size_limit=128): """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...
[ "def", "enablePackrat", "(", "cache_size_limit", "=", "128", ")", ":", "if", "not", "ParserElement", ".", "_packratEnabled", ":", "ParserElement", ".", "_packratEnabled", "=", "True", "if", "cache_size_limit", "is", "None", ":", "ParserElement", ".", "packrat_cach...
[ 1573, 4 ]
[ 1605, 60 ]
python
en
['en', 'en', 'en']
True
ParserElement.parseString
( self, instring, parseAll=False )
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 C{parseAll} to True (equivalent...
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 C{parseAll} to True (equivalent...
def parseString( self, instring, parseAll=False ): """ 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 ...
[ "def", "parseString", "(", "self", ",", "instring", ",", "parseAll", "=", "False", ")", ":", "ParserElement", ".", "resetCache", "(", ")", "if", "not", "self", ".", "streamlined", ":", "self", ".", "streamline", "(", ")", "#~ self.saveAsList = True\r", "for"...
[ 1607, 4 ]
[ 1655, 25 ]
python
en
['en', 'ja', 'th']
False
ParserElement.scanString
( self, instring, maxMatches=_MAX_INT, overlap=False )
Scan the input string for expression matches. Each match will return the matching tokens, start location, and end location. May be called with optional C{maxMatches} argument, to clip scanning after 'n' matches are found. If C{overlap} is specified, then overlapping matches will ...
Scan the input string for expression matches. Each match will return the matching tokens, start location, and end location. May be called with optional C{maxMatches} argument, to clip scanning after 'n' matches are found. If C{overlap} is specified, then overlapping matches will ...
def scanString( self, instring, maxMatches=_MAX_INT, overlap=False ): """ Scan the input string for expression matches. Each match will return the matching tokens, start location, and end location. May be called with optional C{maxMatches} argument, to clip scanning after 'n' match...
[ "def", "scanString", "(", "self", ",", "instring", ",", "maxMatches", "=", "_MAX_INT", ",", "overlap", "=", "False", ")", ":", "if", "not", "self", ".", "streamlined", ":", "self", ".", "streamline", "(", ")", "for", "e", "in", "self", ".", "ignoreExpr...
[ 1657, 4 ]
[ 1726, 25 ]
python
en
['en', 'ja', 'th']
False
ParserElement.transformString
( self, instring )
Extension to C{L{scanString}}, to modify matching text with modified tokens that may be returned from a parse action. To use C{transformString}, define a grammar and attach a parse action to it that modifies the returned token list. Invoking C{transformString()} on a target string ...
Extension to C{L{scanString}}, to modify matching text with modified tokens that may be returned from a parse action. To use C{transformString}, define a grammar and attach a parse action to it that modifies the returned token list. Invoking C{transformString()} on a target string ...
def transformString( self, instring ): """ Extension to C{L{scanString}}, to modify matching text with modified tokens that may be returned from a parse action. To use C{transformString}, define a grammar and attach a parse action to it that modifies the returned token list. ...
[ "def", "transformString", "(", "self", ",", "instring", ")", ":", "out", "=", "[", "]", "lastE", "=", "0", "# force preservation of <TAB>s, to minimize unwanted transformation of string, and to\r", "# keep string locs straight between transformString and scanString\r", "self", "....
[ 1728, 4 ]
[ 1769, 25 ]
python
en
['en', 'ja', 'th']
False
ParserElement.searchString
( self, instring, maxMatches=_MAX_INT )
Another extension to C{L{scanString}}, simplifying the access to the tokens found to match the given parse expression. May be called with optional C{maxMatches} argument, to clip searching after 'n' matches are found. Example:: # a capitalized word starts wit...
Another extension to C{L{scanString}}, simplifying the access to the tokens found to match the given parse expression. May be called with optional C{maxMatches} argument, to clip searching after 'n' matches are found. Example:: # a capitalized word starts wit...
def searchString( self, instring, maxMatches=_MAX_INT ): """ Another extension to C{L{scanString}}, simplifying the access to the tokens found to match the given parse expression. May be called with optional C{maxMatches} argument, to clip searching after 'n' matches are found. ...
[ "def", "searchString", "(", "self", ",", "instring", ",", "maxMatches", "=", "_MAX_INT", ")", ":", "try", ":", "return", "ParseResults", "(", "[", "t", "for", "t", ",", "s", ",", "e", "in", "self", ".", "scanString", "(", "instring", ",", "maxMatches",...
[ 1771, 4 ]
[ 1796, 25 ]
python
en
['en', 'ja', 'th']
False
ParserElement.split
(self, instring, maxsplit=_MAX_INT, includeSeparators=False)
Generator method to split a string using the given expression as a separator. May be called with optional C{maxsplit} argument, to limit the number of splits; and the optional C{includeSeparators} argument (default=C{False}), if the separating matching text should be included in the...
Generator method to split a string using the given expression as a separator. May be called with optional C{maxsplit} argument, to limit the number of splits; and the optional C{includeSeparators} argument (default=C{False}), if the separating matching text should be included in the...
def split(self, instring, maxsplit=_MAX_INT, includeSeparators=False): """ Generator method to split a string using the given expression as a separator. May be called with optional C{maxsplit} argument, to limit the number of splits; and the optional C{includeSeparators} argument (de...
[ "def", "split", "(", "self", ",", "instring", ",", "maxsplit", "=", "_MAX_INT", ",", "includeSeparators", "=", "False", ")", ":", "splits", "=", "0", "last", "=", "0", "for", "t", ",", "s", ",", "e", "in", "self", ".", "scanString", "(", "instring", ...
[ 1798, 4 ]
[ 1818, 29 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__add__
(self, other )
Implementation of + operator - returns C{L{And}}. Adding strings to a ParserElement converts them to L{Literal}s by default. Example:: greet = Word(alphas) + "," + Word(alphas) + "!" hello = "Hello, World!" print (hello, "->", greet.parseStrin...
Implementation of + operator - returns C{L{And}}. Adding strings to a ParserElement converts them to L{Literal}s by default. Example:: greet = Word(alphas) + "," + Word(alphas) + "!" hello = "Hello, World!" print (hello, "->", greet.parseStrin...
def __add__(self, other ): """ Implementation of + operator - returns C{L{And}}. Adding strings to a ParserElement converts them to L{Literal}s by default. Example:: greet = Word(alphas) + "," + Word(alphas) + "!" hello = "Hello, World!" ...
[ "def", "__add__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement...
[ 1820, 4 ]
[ 1838, 37 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__radd__
(self, other )
Implementation of + operator when left operand is not a C{L{ParserElement}}
Implementation of + operator when left operand is not a C{L{ParserElement}}
def __radd__(self, other ): """ Implementation of + operator when left operand is not a C{L{ParserElement}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warning...
[ "def", "__radd__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElemen...
[ 1840, 4 ]
[ 1850, 27 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__sub__
(self, other)
Implementation of - operator, returns C{L{And}} with error stop
Implementation of - operator, returns C{L{And}} with error stop
def __sub__(self, other): """ Implementation of - operator, returns C{L{And}} with error stop """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warnings.warn("Cannot...
[ "def", "__sub__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement...
[ 1852, 4 ]
[ 1862, 46 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__rsub__
(self, other )
Implementation of - operator when left operand is not a C{L{ParserElement}}
Implementation of - operator when left operand is not a C{L{ParserElement}}
def __rsub__(self, other ): """ Implementation of - operator when left operand is not a C{L{ParserElement}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warning...
[ "def", "__rsub__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElemen...
[ 1864, 4 ]
[ 1874, 27 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__mul__
(self,other)
Implementation of * operator, allows use of C{expr * 3} in place of C{expr + expr + expr}. Expressions may also me multiplied by a 2-integer tuple, similar to C{{min,max}} multipliers in regular expressions. Tuples may also include C{None} as in: - C{expr*(n,None)} or C{...
Implementation of * operator, allows use of C{expr * 3} in place of C{expr + expr + expr}. Expressions may also me multiplied by a 2-integer tuple, similar to C{{min,max}} multipliers in regular expressions. Tuples may also include C{None} as in: - C{expr*(n,None)} or C{...
def __mul__(self,other): """ Implementation of * operator, allows use of C{expr * 3} in place of C{expr + expr + expr}. Expressions may also me multiplied by a 2-integer tuple, similar to C{{min,max}} multipliers in regular expressions. Tuples may also include C{None} as i...
[ "def", "__mul__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "int", ")", ":", "minElements", ",", "optElements", "=", "other", ",", "0", "elif", "isinstance", "(", "other", ",", "tuple", ")", ":", "other", "=", "(", ...
[ 1876, 4 ]
[ 1942, 18 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__or__
(self, other )
Implementation of | operator - returns C{L{MatchFirst}}
Implementation of | operator - returns C{L{MatchFirst}}
def __or__(self, other ): """ Implementation of | operator - returns C{L{MatchFirst}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warnings.warn("Cannot combine...
[ "def", "__or__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement"...
[ 1947, 4 ]
[ 1957, 44 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__ror__
(self, other )
Implementation of | operator when left operand is not a C{L{ParserElement}}
Implementation of | operator when left operand is not a C{L{ParserElement}}
def __ror__(self, other ): """ Implementation of | operator when left operand is not a C{L{ParserElement}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warnings...
[ "def", "__ror__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement...
[ 1959, 4 ]
[ 1969, 27 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__xor__
(self, other )
Implementation of ^ operator - returns C{L{Or}}
Implementation of ^ operator - returns C{L{Or}}
def __xor__(self, other ): """ Implementation of ^ operator - returns C{L{Or}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warnings.warn("Cannot combine elemen...
[ "def", "__xor__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement...
[ 1971, 4 ]
[ 1981, 36 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__rxor__
(self, other )
Implementation of ^ operator when left operand is not a C{L{ParserElement}}
Implementation of ^ operator when left operand is not a C{L{ParserElement}}
def __rxor__(self, other ): """ Implementation of ^ operator when left operand is not a C{L{ParserElement}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warning...
[ "def", "__rxor__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElemen...
[ 1983, 4 ]
[ 1993, 27 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__and__
(self, other )
Implementation of & operator - returns C{L{Each}}
Implementation of & operator - returns C{L{Each}}
def __and__(self, other ): """ Implementation of & operator - returns C{L{Each}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warnings.warn("Cannot combine elem...
[ "def", "__and__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement...
[ 1995, 4 ]
[ 2005, 38 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__rand__
(self, other )
Implementation of & operator when left operand is not a C{L{ParserElement}}
Implementation of & operator when left operand is not a C{L{ParserElement}}
def __rand__(self, other ): """ Implementation of & operator when left operand is not a C{L{ParserElement}} """ if isinstance( other, basestring ): other = ParserElement._literalStringClass( other ) if not isinstance( other, ParserElement ): warning...
[ "def", "__rand__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "ParserElement", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElemen...
[ 2007, 4 ]
[ 2017, 27 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__invert__
( self )
Implementation of ~ operator - returns C{L{NotAny}}
Implementation of ~ operator - returns C{L{NotAny}}
def __invert__( self ): """ Implementation of ~ operator - returns C{L{NotAny}} """ return NotAny( self )
[ "def", "__invert__", "(", "self", ")", ":", "return", "NotAny", "(", "self", ")" ]
[ 2019, 4 ]
[ 2023, 29 ]
python
en
['en', 'ja', 'th']
False
ParserElement.__call__
(self, name=None)
Shortcut for C{L{setResultsName}}, with C{listAllMatches=False}. If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be passed as C{True}. If C{name} is omitted, same as calling C{L{copy}}. Example:: # thes...
Shortcut for C{L{setResultsName}}, with C{listAllMatches=False}. If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be passed as C{True}. If C{name} is omitted, same as calling C{L{copy}}. Example:: # thes...
def __call__(self, name=None): """ Shortcut for C{L{setResultsName}}, with C{listAllMatches=False}. If C{name} is given with a trailing C{'*'} character, then C{listAllMatches} will be passed as C{True}. If C{name} is omitted, same as calling C{L{copy}...
[ "def", "__call__", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "not", "None", ":", "return", "self", ".", "setResultsName", "(", "name", ")", "else", ":", "return", "self", ".", "copy", "(", ")" ]
[ 2025, 4 ]
[ 2042, 30 ]
python
en
['en', 'ja', 'th']
False
ParserElement.suppress
( self )
Suppresses the output of this C{ParserElement}; useful to keep punctuation from cluttering up returned output.
Suppresses the output of this C{ParserElement}; useful to keep punctuation from cluttering up returned output.
def suppress( self ): """ Suppresses the output of this C{ParserElement}; useful to keep punctuation from cluttering up returned output. """ return Suppress( self )
[ "def", "suppress", "(", "self", ")", ":", "return", "Suppress", "(", "self", ")" ]
[ 2044, 4 ]
[ 2049, 31 ]
python
en
['en', 'ja', 'th']
False
ParserElement.leaveWhitespace
( self )
Disables the skipping of whitespace before matching the characters in the C{ParserElement}'s defined pattern. This is normally only used internally by the pyparsing module, but may be needed in some whitespace-sensitive grammars.
Disables the skipping of whitespace before matching the characters in the C{ParserElement}'s defined pattern. This is normally only used internally by the pyparsing module, but may be needed in some whitespace-sensitive grammars.
def leaveWhitespace( self ): """ Disables the skipping of whitespace before matching the characters in the C{ParserElement}'s defined pattern. This is normally only used internally by the pyparsing module, but may be needed in some whitespace-sensitive grammars. """ ...
[ "def", "leaveWhitespace", "(", "self", ")", ":", "self", ".", "skipWhitespace", "=", "False", "return", "self" ]
[ 2051, 4 ]
[ 2058, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.setWhitespaceChars
( self, chars )
Overrides the default whitespace chars
Overrides the default whitespace chars
def setWhitespaceChars( self, chars ): """ Overrides the default whitespace chars """ self.skipWhitespace = True self.whiteChars = chars self.copyDefaultWhiteChars = False return self
[ "def", "setWhitespaceChars", "(", "self", ",", "chars", ")", ":", "self", ".", "skipWhitespace", "=", "True", "self", ".", "whiteChars", "=", "chars", "self", ".", "copyDefaultWhiteChars", "=", "False", "return", "self" ]
[ 2060, 4 ]
[ 2067, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.parseWithTabs
( self )
Overrides default behavior to expand C{<TAB>}s to spaces before parsing the input string. Must be called before C{parseString} when the input grammar contains elements that match C{<TAB>} characters.
Overrides default behavior to expand C{<TAB>}s to spaces before parsing the input string. Must be called before C{parseString} when the input grammar contains elements that match C{<TAB>} characters.
def parseWithTabs( self ): """ Overrides default behavior to expand C{<TAB>}s to spaces before parsing the input string. Must be called before C{parseString} when the input grammar contains elements that match C{<TAB>} characters. """ self.keepTabs = True r...
[ "def", "parseWithTabs", "(", "self", ")", ":", "self", ".", "keepTabs", "=", "True", "return", "self" ]
[ 2069, 4 ]
[ 2076, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.ignore
( self, other )
Define expression to be ignored (e.g., comments) while doing pattern matching; may be called repeatedly, to define multiple comment or other ignorable patterns. Example:: patt = OneOrMore(Word(alphas)) patt.parseString('ablaj /* comment */ lskjd')...
Define expression to be ignored (e.g., comments) while doing pattern matching; may be called repeatedly, to define multiple comment or other ignorable patterns. Example:: patt = OneOrMore(Word(alphas)) patt.parseString('ablaj /* comment */ lskjd')...
def ignore( self, other ): """ Define expression to be ignored (e.g., comments) while doing pattern matching; may be called repeatedly, to define multiple comment or other ignorable patterns. Example:: patt = OneOrMore(Word(alphas)) patt.p...
[ "def", "ignore", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "Suppress", "(", "other", ")", "if", "isinstance", "(", "other", ",", "Suppress", ")", ":", "if", "other", "not", "in",...
[ 2078, 4 ]
[ 2099, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.setDebugActions
( self, startAction, successAction, exceptionAction )
Enable display of debugging messages while doing pattern matching.
Enable display of debugging messages while doing pattern matching.
def setDebugActions( self, startAction, successAction, exceptionAction ): """ Enable display of debugging messages while doing pattern matching. """ self.debugActions = (startAction or _defaultStartDebugAction, successAction or _defaultSuccessDebugAction...
[ "def", "setDebugActions", "(", "self", ",", "startAction", ",", "successAction", ",", "exceptionAction", ")", ":", "self", ".", "debugActions", "=", "(", "startAction", "or", "_defaultStartDebugAction", ",", "successAction", "or", "_defaultSuccessDebugAction", ",", ...
[ 2101, 4 ]
[ 2109, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.setDebug
( self, flag=True )
Enable display of debugging messages while doing pattern matching. Set C{flag} to True to enable, False to disable. Example:: wd = Word(alphas).setName("alphaword") integer = Word(nums).setName("numword") term = wd | integer ...
Enable display of debugging messages while doing pattern matching. Set C{flag} to True to enable, False to disable. Example:: wd = Word(alphas).setName("alphaword") integer = Word(nums).setName("numword") term = wd | integer ...
def setDebug( self, flag=True ): """ Enable display of debugging messages while doing pattern matching. Set C{flag} to True to enable, False to disable. Example:: wd = Word(alphas).setName("alphaword") integer = Word(nums).setName("numword") t...
[ "def", "setDebug", "(", "self", ",", "flag", "=", "True", ")", ":", "if", "flag", ":", "self", ".", "setDebugActions", "(", "_defaultStartDebugAction", ",", "_defaultSuccessDebugAction", ",", "_defaultExceptionDebugAction", ")", "else", ":", "self", ".", "debug"...
[ 2111, 4 ]
[ 2150, 19 ]
python
en
['en', 'ja', 'th']
False
ParserElement.validate
( self, validateTrace=[] )
Check defined expressions for valid structure, check for infinite recursive definitions.
Check defined expressions for valid structure, check for infinite recursive definitions.
def validate( self, validateTrace=[] ): """ Check defined expressions for valid structure, check for infinite recursive definitions. """ self.checkRecursion( [] )
[ "def", "validate", "(", "self", ",", "validateTrace", "=", "[", "]", ")", ":", "self", ".", "checkRecursion", "(", "[", "]", ")" ]
[ 2166, 4 ]
[ 2170, 33 ]
python
en
['en', 'ja', 'th']
False
ParserElement.parseFile
( self, file_or_filename, parseAll=False )
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.
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.
def parseFile( self, file_or_filename, parseAll=False ): """ 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. """ try: file_con...
[ "def", "parseFile", "(", "self", ",", "file_or_filename", ",", "parseAll", "=", "False", ")", ":", "try", ":", "file_contents", "=", "file_or_filename", ".", "read", "(", ")", "except", "AttributeError", ":", "with", "open", "(", "file_or_filename", ",", "\"...
[ 2172, 4 ]
[ 2190, 25 ]
python
en
['en', 'ja', 'th']
False
ParserElement.matches
(self, testString, parseAll=True)
Method for quick testing of a parser against a test string. Good for simple inline microtests of sub expressions while building up larger parser. Parameters: - testString - to test against this expression for a match - parseAll - (default=C{True}) - flag to ...
Method for quick testing of a parser against a test string. Good for simple inline microtests of sub expressions while building up larger parser. Parameters: - testString - to test against this expression for a match - parseAll - (default=C{True}) - flag to ...
def matches(self, testString, parseAll=True): """ Method for quick testing of a parser against a test string. Good for simple inline microtests of sub expressions while building up larger parser. Parameters: - testString - to test against this expression for a...
[ "def", "matches", "(", "self", ",", "testString", ",", "parseAll", "=", "True", ")", ":", "try", ":", "self", ".", "parseString", "(", "_ustr", "(", "testString", ")", ",", "parseAll", "=", "parseAll", ")", "return", "True", "except", "ParseBaseException",...
[ 2212, 4 ]
[ 2229, 24 ]
python
en
['en', 'ja', 'th']
False
ParserElement.runTests
(self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False)
Execute the parse expression on a series of test strings, showing each test, the parsed results or where the parse failed. Quick and easy way to run a parse expression against a list of sample strings. Parameters: - tests - a list of separate test strings, or ...
Execute the parse expression on a series of test strings, showing each test, the parsed results or where the parse failed. Quick and easy way to run a parse expression against a list of sample strings. Parameters: - tests - a list of separate test strings, or ...
def runTests(self, tests, parseAll=True, comment='#', fullDump=True, printResults=True, failureTests=False): """ Execute the parse expression on a series of test strings, showing each test, the parsed results or where the parse failed. Quick and easy way to run a parse expression aga...
[ "def", "runTests", "(", "self", ",", "tests", ",", "parseAll", "=", "True", ",", "comment", "=", "'#'", ",", "fullDump", "=", "True", ",", "printResults", "=", "True", ",", "failureTests", "=", "False", ")", ":", "if", "isinstance", "(", "tests", ",", ...
[ 2231, 4 ]
[ 2360, 34 ]
python
en
['en', 'ja', 'th']
False
get_message
(tweet)
Robustly get a message on a tweet. Even if not extended mode or is a retweet (always truncated).
Robustly get a message on a tweet. Even if not extended mode or is a retweet (always truncated).
def get_message(tweet): """ Robustly get a message on a tweet. Even if not extended mode or is a retweet (always truncated). """ try: return tweet.full_text except AttributeError: return tweet.text
[ "def", "get_message", "(", "tweet", ")", ":", "try", ":", "return", "tweet", ".", "full_text", "except", "AttributeError", ":", "return", "tweet", ".", "text" ]
[ 0, 0 ]
[ 9, 25 ]
python
en
['en', 'error', 'th']
False
f
(x)
Noise free objective.
Noise free objective.
def f(x): """Noise free objective.""" return np.sin(10 * x) * x * 100
[ "def", "f", "(", "x", ")", ":", "return", "np", ".", "sin", "(", "10", "*", "x", ")", "*", "x", "*", "100" ]
[ 22, 0 ]
[ 25, 35 ]
python
en
['en', 'en', 'en']
True
EmailLogBackEnd.log_email
(email: EmailMultiAlternatives)
Used in development to record sent emails in a nice HTML log
Used in development to record sent emails in a nice HTML log
def log_email(email: EmailMultiAlternatives) -> None: """Used in development to record sent emails in a nice HTML log""" html_message = "Missing HTML message" if len(email.alternatives) > 0: html_message = email.alternatives[0][0] context = { "subject": email.sub...
[ "def", "log_email", "(", "email", ":", "EmailMultiAlternatives", ")", "->", "None", ":", "html_message", "=", "\"Missing HTML message\"", "if", "len", "(", "email", ".", "alternatives", ")", ">", "0", ":", "html_message", "=", "email", ".", "alternatives", "["...
[ 34, 4 ]
[ 61, 48 ]
python
en
['en', 'en', 'en']
True
EmailBackend._get_filename
(self)
Return a unique file name.
Return a unique file name.
def _get_filename(self): """Return a unique file name.""" if self._fname is None: timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S") fname = "%s-%s.log" % (timestamp, abs(id(self))) self._fname = os.path.join(self.file_path, fname) return self._fnam...
[ "def", "_get_filename", "(", "self", ")", ":", "if", "self", ".", "_fname", "is", "None", ":", "timestamp", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "strftime", "(", "\"%Y%m%d-%H%M%S\"", ")", "fname", "=", "\"%s-%s.log\"", "%", "(", ...
[ 50, 4 ]
[ 56, 26 ]
python
en
['fr', 'it', 'en']
False
get_signage_point_vdf_info
( constants: ConsensusConstants, finished_sub_slots: List[EndOfSubSlotBundle], overflow: bool, prev_b: Optional[BlockRecord], blocks: BlockchainInterface, sp_total_iters: uint128, sp_iters: uint64, )
Returns the following information, for the VDF of the signage point at sp_total_iters. cc and rc challenge hash cc and rc input cc and rc iterations
Returns the following information, for the VDF of the signage point at sp_total_iters. cc and rc challenge hash cc and rc input cc and rc iterations
def get_signage_point_vdf_info( constants: ConsensusConstants, finished_sub_slots: List[EndOfSubSlotBundle], overflow: bool, prev_b: Optional[BlockRecord], blocks: BlockchainInterface, sp_total_iters: uint128, sp_iters: uint64, ): """ Returns the following information, for the VDF of...
[ "def", "get_signage_point_vdf_info", "(", "constants", ":", "ConsensusConstants", ",", "finished_sub_slots", ":", "List", "[", "EndOfSubSlotBundle", "]", ",", "overflow", ":", "bool", ",", "prev_b", ":", "Optional", "[", "BlockRecord", "]", ",", "blocks", ":", "...
[ 11, 0 ]
[ 153, 5 ]
python
en
['en', 'error', 'th']
False
import_backend
(dotted_path)
There's two formats for the dotted_path. One with the backend class (old) and one without (new) eg: old: wagtail.search.backends.elasticsearch.ElasticsearchSearchBackend new: wagtail.search.backends.elasticsearch If a new style dotted path was specified, this function would look for a ...
There's two formats for the dotted_path. One with the backend class (old) and one without (new) eg: old: wagtail.search.backends.elasticsearch.ElasticsearchSearchBackend new: wagtail.search.backends.elasticsearch
def import_backend(dotted_path): """ There's two formats for the dotted_path. One with the backend class (old) and one without (new) eg: old: wagtail.search.backends.elasticsearch.ElasticsearchSearchBackend new: wagtail.search.backends.elasticsearch If a new style dotted path was specif...
[ "def", "import_backend", "(", "dotted_path", ")", ":", "try", ":", "# New", "backend_module", "=", "import_module", "(", "dotted_path", ")", "return", "backend_module", ".", "SearchBackend", "except", "ImportError", "as", "e", ":", "try", ":", "# Old", "return",...
[ 26, 0 ]
[ 46, 36 ]
python
en
['en', 'error', 'th']
False
normalize
(pattern)
r""" Given a reg-exp pattern, normalizes it to an iterable of forms that suffice for reverse matching. This does the following: (1) For any repeating sections, keeps the minimum number of occurrences permitted (this means zero for optional groups). (2) If an optional group includes parameters, ...
r""" Given a reg-exp pattern, normalizes it to an iterable of forms that suffice for reverse matching. This does the following:
def normalize(pattern): r""" Given a reg-exp pattern, normalizes it to an iterable of forms that suffice for reverse matching. This does the following: (1) For any repeating sections, keeps the minimum number of occurrences permitted (this means zero for optional groups). (2) If an optional...
[ "def", "normalize", "(", "pattern", ")", ":", "# Do a linear scan to work out the special features of this pattern. The", "# idea is that we scan once here and collect all the information we need to", "# make future decisions.", "result", "=", "[", "]", "non_capturing_groups", "=", "["...
[ 52, 0 ]
[ 208, 45 ]
python
cy
['en', 'cy', 'hi']
False
next_char
(input_iter)
r""" An iterator that yields the next character from "pattern_iter", respecting escape sequences. An escaped character is replaced by a representative of its class (e.g. \w -> "x"). If the escaped character is one that is skipped, it is not returned (the next character is returned instead). Yields ...
r""" An iterator that yields the next character from "pattern_iter", respecting escape sequences. An escaped character is replaced by a representative of its class (e.g. \w -> "x"). If the escaped character is one that is skipped, it is not returned (the next character is returned instead).
def next_char(input_iter): r""" An iterator that yields the next character from "pattern_iter", respecting escape sequences. An escaped character is replaced by a representative of its class (e.g. \w -> "x"). If the escaped character is one that is skipped, it is not returned (the next character is ...
[ "def", "next_char", "(", "input_iter", ")", ":", "for", "ch", "in", "input_iter", ":", "if", "ch", "!=", "'\\\\'", ":", "yield", "ch", ",", "False", "continue", "ch", "=", "next", "(", "input_iter", ")", "representative", "=", "ESCAPE_MAPPINGS", ".", "ge...
[ 211, 0 ]
[ 229, 34 ]
python
cy
['en', 'cy', 'hi']
False
walk_to_end
(ch, input_iter)
The iterator is currently inside a capturing group. We want to walk to the close of this group, skipping over any nested groups and handling escaped parentheses correctly.
The iterator is currently inside a capturing group. We want to walk to the close of this group, skipping over any nested groups and handling escaped parentheses correctly.
def walk_to_end(ch, input_iter): """ The iterator is currently inside a capturing group. We want to walk to the close of this group, skipping over any nested groups and handling escaped parentheses correctly. """ if ch == '(': nesting = 1 else: nesting = 0 for ch, escaped...
[ "def", "walk_to_end", "(", "ch", ",", "input_iter", ")", ":", "if", "ch", "==", "'('", ":", "nesting", "=", "1", "else", ":", "nesting", "=", "0", "for", "ch", ",", "escaped", "in", "input_iter", ":", "if", "escaped", ":", "continue", "elif", "ch", ...
[ 232, 0 ]
[ 250, 24 ]
python
en
['en', 'error', 'th']
False
get_quantifier
(ch, input_iter)
Parse a quantifier from the input, where "ch" is the first character in the quantifier. Returns the minimum number of occurrences permitted by the quantifier and either None or the next character from the input_iter if the next character is not part of the quantifier.
Parse a quantifier from the input, where "ch" is the first character in the quantifier.
def get_quantifier(ch, input_iter): """ Parse a quantifier from the input, where "ch" is the first character in the quantifier. Returns the minimum number of occurrences permitted by the quantifier and either None or the next character from the input_iter if the next character is not part of th...
[ "def", "get_quantifier", "(", "ch", ",", "input_iter", ")", ":", "if", "ch", "in", "'*?+'", ":", "try", ":", "ch2", ",", "escaped", "=", "next", "(", "input_iter", ")", "except", "StopIteration", ":", "ch2", "=", "None", "if", "ch2", "==", "'?'", ":"...
[ 253, 0 ]
[ 287, 29 ]
python
en
['en', 'error', 'th']
False
contains
(source, inst)
Returns True if the "source" contains an instance of "inst". False, otherwise.
Returns True if the "source" contains an instance of "inst". False, otherwise.
def contains(source, inst): """ Returns True if the "source" contains an instance of "inst". False, otherwise. """ if isinstance(source, inst): return True if isinstance(source, NonCapture): for elt in source: if contains(elt, inst): return True re...
[ "def", "contains", "(", "source", ",", "inst", ")", ":", "if", "isinstance", "(", "source", ",", "inst", ")", ":", "return", "True", "if", "isinstance", "(", "source", ",", "NonCapture", ")", ":", "for", "elt", "in", "source", ":", "if", "contains", ...
[ 290, 0 ]
[ 301, 16 ]
python
en
['en', 'error', 'th']
False
flatten_result
(source)
Turns the given source sequence into a list of reg-exp possibilities and their arguments. Returns a list of strings and a list of argument lists. Each of the two lists will be of the same length.
Turns the given source sequence into a list of reg-exp possibilities and their arguments. Returns a list of strings and a list of argument lists. Each of the two lists will be of the same length.
def flatten_result(source): """ Turns the given source sequence into a list of reg-exp possibilities and their arguments. Returns a list of strings and a list of argument lists. Each of the two lists will be of the same length. """ if source is None: return [''], [[]] if isinstance(s...
[ "def", "flatten_result", "(", "source", ")", ":", "if", "source", "is", "None", ":", "return", "[", "''", "]", ",", "[", "[", "]", "]", "if", "isinstance", "(", "source", ",", "Group", ")", ":", "if", "source", "[", "1", "]", "is", "None", ":", ...
[ 304, 0 ]
[ 355, 30 ]
python
en
['en', 'error', 'th']
False
conditional_content_removal
(request, response)
Simulate the behavior of most Web servers by removing the content of responses for HEAD requests, 1xx, 204, and 304 responses. Ensures compliance with RFC 7230, section 3.3.3.
Simulate the behavior of most Web servers by removing the content of responses for HEAD requests, 1xx, 204, and 304 responses. Ensures compliance with RFC 7230, section 3.3.3.
def conditional_content_removal(request, response): """ Simulate the behavior of most Web servers by removing the content of responses for HEAD requests, 1xx, 204, and 304 responses. Ensures compliance with RFC 7230, section 3.3.3. """ if 100 <= response.status_code < 200 or response.status_code...
[ "def", "conditional_content_removal", "(", "request", ",", "response", ")", ":", "if", "100", "<=", "response", ".", "status_code", "<", "200", "or", "response", ".", "status_code", "in", "(", "204", ",", "304", ")", ":", "if", "response", ".", "streaming"...
[ 96, 0 ]
[ 113, 19 ]
python
en
['en', 'error', 'th']
False
store_rendered_templates
(store, signal, sender, template, context, **kwargs)
Stores templates and contexts that are rendered. The context is copied so that it is an accurate representation at the time of rendering.
Stores templates and contexts that are rendered.
def store_rendered_templates(store, signal, sender, template, context, **kwargs): """ Stores templates and contexts that are rendered. The context is copied so that it is an accurate representation at the time of rendering. """ store.setdefault('templates', []).append(template) if 'context'...
[ "def", "store_rendered_templates", "(", "store", ",", "signal", ",", "sender", ",", "template", ",", "context", ",", "*", "*", "kwargs", ")", ":", "store", ".", "setdefault", "(", "'templates'", ",", "[", "]", ")", ".", "append", "(", "template", ")", ...
[ 165, 0 ]
[ 175, 42 ]
python
en
['en', 'error', 'th']
False
encode_multipart
(boundary, data)
Encodes multipart POST data from a dictionary of form values. The key will be used as the form data name; the value will be transmitted as content. If the value is a file, the contents of the file will be sent as an application/octet-stream; otherwise, str(value) will be sent.
Encodes multipart POST data from a dictionary of form values.
def encode_multipart(boundary, data): """ Encodes multipart POST data from a dictionary of form values. The key will be used as the form data name; the value will be transmitted as content. If the value is a file, the contents of the file will be sent as an application/octet-stream; otherwise, str(...
[ "def", "encode_multipart", "(", "boundary", ",", "data", ")", ":", "lines", "=", "[", "]", "def", "to_bytes", "(", "s", ")", ":", "return", "force_bytes", "(", "s", ",", "settings", ".", "DEFAULT_CHARSET", ")", "# Not by any means perfect, but good enough for ou...
[ 178, 0 ]
[ 224, 30 ]
python
en
['en', 'error', 'th']
False
RequestFactory._base_environ
(self, **request)
The base environment for a request.
The base environment for a request.
def _base_environ(self, **request): """ The base environment for a request. """ # This is a minimal valid WSGI environ dictionary, plus: # - HTTP_COOKIE: for cookie support, # - REMOTE_ADDR: often useful, see #8551. # See http://www.python.org/dev/peps/pep-3333/#e...
[ "def", "_base_environ", "(", "self", ",", "*", "*", "request", ")", ":", "# This is a minimal valid WSGI environ dictionary, plus:", "# - HTTP_COOKIE: for cookie support,", "# - REMOTE_ADDR: often useful, see #8551.", "# See http://www.python.org/dev/peps/pep-3333/#environ-variables", "e...
[ 275, 4 ]
[ 302, 22 ]
python
en
['en', 'error', 'th']
False
RequestFactory.request
(self, **request)
Construct a generic request object.
Construct a generic request object.
def request(self, **request): "Construct a generic request object." return WSGIRequest(self._base_environ(**request))
[ "def", "request", "(", "self", ",", "*", "*", "request", ")", ":", "return", "WSGIRequest", "(", "self", ".", "_base_environ", "(", "*", "*", "request", ")", ")" ]
[ 304, 4 ]
[ 306, 57 ]
python
en
['en', 'en', 'en']
True
RequestFactory.get
(self, path, data=None, secure=False, **extra)
Construct a GET request.
Construct a GET request.
def get(self, path, data=None, secure=False, **extra): "Construct a GET request." data = {} if data is None else data r = { 'QUERY_STRING': urlencode(data, doseq=True), } r.update(extra) return self.generic('GET', path, secure=secure, **r)
[ "def", "get", "(", "self", ",", "path", ",", "data", "=", "None", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "{", "}", "if", "data", "is", "None", "else", "data", "r", "=", "{", "'QUERY_STRING'", ":", "urlencode",...
[ 331, 4 ]
[ 339, 60 ]
python
en
['en', 'en', 'en']
True
RequestFactory.post
(self, path, data=None, content_type=MULTIPART_CONTENT, secure=False, **extra)
Construct a POST request.
Construct a POST request.
def post(self, path, data=None, content_type=MULTIPART_CONTENT, secure=False, **extra): "Construct a POST request." data = {} if data is None else data post_data = self._encode_data(data, content_type) return self.generic('POST', path, post_data, content_type, ...
[ "def", "post", "(", "self", ",", "path", ",", "data", "=", "None", ",", "content_type", "=", "MULTIPART_CONTENT", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "{", "}", "if", "data", "is", "None", "else", "data", "pos...
[ 341, 4 ]
[ 349, 51 ]
python
en
['en', 'en', 'en']
True
RequestFactory.head
(self, path, data=None, secure=False, **extra)
Construct a HEAD request.
Construct a HEAD request.
def head(self, path, data=None, secure=False, **extra): "Construct a HEAD request." data = {} if data is None else data r = { 'QUERY_STRING': urlencode(data, doseq=True), } r.update(extra) return self.generic('HEAD', path, secure=secure, **r)
[ "def", "head", "(", "self", ",", "path", ",", "data", "=", "None", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "data", "=", "{", "}", "if", "data", "is", "None", "else", "data", "r", "=", "{", "'QUERY_STRING'", ":", "urlencode"...
[ 351, 4 ]
[ 359, 61 ]
python
en
['en', 'en', 'en']
True
RequestFactory.trace
(self, path, secure=False, **extra)
Construct a TRACE request.
Construct a TRACE request.
def trace(self, path, secure=False, **extra): "Construct a TRACE request." return self.generic('TRACE', path, secure=secure, **extra)
[ "def", "trace", "(", "self", ",", "path", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "return", "self", ".", "generic", "(", "'TRACE'", ",", "path", ",", "secure", "=", "secure", ",", "*", "*", "extra", ")" ]
[ 361, 4 ]
[ 363, 66 ]
python
en
['en', 'en', 'en']
True
RequestFactory.options
(self, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct an OPTIONS request.
Construct an OPTIONS request.
def options(self, path, data='', content_type='application/octet-stream', secure=False, **extra): "Construct an OPTIONS request." return self.generic('OPTIONS', path, data, content_type, secure=secure, **extra)
[ "def", "options", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "return", "self", ".", "generic", "(", "'OPTIONS'", ",", "path", ...
[ 365, 4 ]
[ 369, 51 ]
python
en
['en', 'en', 'en']
True
RequestFactory.put
(self, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct a PUT request.
Construct a PUT request.
def put(self, path, data='', content_type='application/octet-stream', secure=False, **extra): "Construct a PUT request." return self.generic('PUT', path, data, content_type, secure=secure, **extra)
[ "def", "put", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "return", "self", ".", "generic", "(", "'PUT'", ",", "path", ",", "...
[ 371, 4 ]
[ 375, 51 ]
python
en
['en', 'en', 'en']
True
RequestFactory.patch
(self, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct a PATCH request.
Construct a PATCH request.
def patch(self, path, data='', content_type='application/octet-stream', secure=False, **extra): "Construct a PATCH request." return self.generic('PATCH', path, data, content_type, secure=secure, **extra)
[ "def", "patch", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "return", "self", ".", "generic", "(", "'PATCH'", ",", "path", ",",...
[ 377, 4 ]
[ 381, 51 ]
python
en
['en', 'en', 'en']
True
RequestFactory.delete
(self, path, data='', content_type='application/octet-stream', secure=False, **extra)
Construct a DELETE request.
Construct a DELETE request.
def delete(self, path, data='', content_type='application/octet-stream', secure=False, **extra): "Construct a DELETE request." return self.generic('DELETE', path, data, content_type, secure=secure, **extra)
[ "def", "delete", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "return", "self", ".", "generic", "(", "'DELETE'", ",", "path", ",...
[ 383, 4 ]
[ 387, 51 ]
python
en
['en', 'it', 'en']
True
RequestFactory.generic
(self, method, path, data='', content_type='application/octet-stream', secure=False, **extra)
Constructs an arbitrary HTTP request.
Constructs an arbitrary HTTP request.
def generic(self, method, path, data='', content_type='application/octet-stream', secure=False, **extra): """Constructs an arbitrary HTTP request.""" parsed = urlparse(force_str(path)) data = force_bytes(data, settings.DEFAULT_CHARSET) r = { 'P...
[ "def", "generic", "(", "self", ",", "method", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "parsed", "=", "urlparse", "(", "force_str", "(", ...
[ 389, 4 ]
[ 415, 32 ]
python
en
['en', 'en', 'en']
True
Client.store_exc_info
(self, **kwargs)
Stores exceptions when they are generated by a view.
Stores exceptions when they are generated by a view.
def store_exc_info(self, **kwargs): """ Stores exceptions when they are generated by a view. """ self.exc_info = sys.exc_info()
[ "def", "store_exc_info", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "exc_info", "=", "sys", ".", "exc_info", "(", ")" ]
[ 441, 4 ]
[ 445, 38 ]
python
en
['en', 'error', 'th']
False
Client.session
(self)
Obtains the current session variables.
Obtains the current session variables.
def session(self): """ Obtains the current session variables. """ engine = import_module(settings.SESSION_ENGINE) cookie = self.cookies.get(settings.SESSION_COOKIE_NAME) if cookie: return engine.SessionStore(cookie.value) session = engine.SessionStore...
[ "def", "session", "(", "self", ")", ":", "engine", "=", "import_module", "(", "settings", ".", "SESSION_ENGINE", ")", "cookie", "=", "self", ".", "cookies", ".", "get", "(", "settings", ".", "SESSION_COOKIE_NAME", ")", "if", "cookie", ":", "return", "engin...
[ 448, 4 ]
[ 460, 22 ]
python
en
['en', 'error', 'th']
False
Client.request
(self, **request)
The master request method. Composes the environment dictionary and passes to the handler, returning the result of the handler. Assumes defaults for the query environment, which can be overridden using the arguments to the request.
The master request method. Composes the environment dictionary and passes to the handler, returning the result of the handler. Assumes defaults for the query environment, which can be overridden using the arguments to the request.
def request(self, **request): """ The master request method. Composes the environment dictionary and passes to the handler, returning the result of the handler. Assumes defaults for the query environment, which can be overridden using the arguments to the request. """ ...
[ "def", "request", "(", "self", ",", "*", "*", "request", ")", ":", "environ", "=", "self", ".", "_base_environ", "(", "*", "*", "request", ")", "# Curry a data dictionary into an instance of the template renderer", "# callback function.", "data", "=", "{", "}", "o...
[ 462, 4 ]
[ 528, 72 ]
python
en
['en', 'error', 'th']
False
Client.get
(self, path, data=None, follow=False, secure=False, **extra)
Requests a response from the server using GET.
Requests a response from the server using GET.
def get(self, path, data=None, follow=False, secure=False, **extra): """ Requests a response from the server using GET. """ response = super(Client, self).get(path, data=data, secure=secure, **extra) if follow: response = sel...
[ "def", "get", "(", "self", ",", "path", ",", "data", "=", "None", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", "Client", ",", "self", ")", ".", "get", "(", "path", ",...
[ 530, 4 ]
[ 538, 23 ]
python
en
['en', 'error', 'th']
False
Client.post
(self, path, data=None, content_type=MULTIPART_CONTENT, follow=False, secure=False, **extra)
Requests a response from the server using POST.
Requests a response from the server using POST.
def post(self, path, data=None, content_type=MULTIPART_CONTENT, follow=False, secure=False, **extra): """ Requests a response from the server using POST. """ response = super(Client, self).post(path, data=data, content_type=content...
[ "def", "post", "(", "self", ",", "path", ",", "data", "=", "None", ",", "content_type", "=", "MULTIPART_CONTENT", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", "Client", ","...
[ 540, 4 ]
[ 550, 23 ]
python
en
['en', 'error', 'th']
False
Client.head
(self, path, data=None, follow=False, secure=False, **extra)
Request a response from the server using HEAD.
Request a response from the server using HEAD.
def head(self, path, data=None, follow=False, secure=False, **extra): """ Request a response from the server using HEAD. """ response = super(Client, self).head(path, data=data, secure=secure, **extra) if follow: response = ...
[ "def", "head", "(", "self", ",", "path", ",", "data", "=", "None", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", "Client", ",", "self", ")", ".", "head", "(", "path", ...
[ 552, 4 ]
[ 560, 23 ]
python
en
['en', 'error', 'th']
False
Client.options
(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra)
Request a response from the server using OPTIONS.
Request a response from the server using OPTIONS.
def options(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra): """ Request a response from the server using OPTIONS. """ response = super(Client, self).options(path, data=data, ...
[ "def", "options", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", "Clie...
[ 562, 4 ]
[ 572, 23 ]
python
en
['en', 'error', 'th']
False
Client.put
(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra)
Send a resource to the server using PUT.
Send a resource to the server using PUT.
def put(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra): """ Send a resource to the server using PUT. """ response = super(Client, self).put(path, data=data, content_type=content_typ...
[ "def", "put", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", "Client",...
[ 574, 4 ]
[ 584, 23 ]
python
en
['en', 'error', 'th']
False
Client.patch
(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra)
Send a resource to the server using PATCH.
Send a resource to the server using PATCH.
def patch(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra): """ Send a resource to the server using PATCH. """ response = super(Client, self).patch(path, data=data, content_type=c...
[ "def", "patch", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", "Client...
[ 586, 4 ]
[ 596, 23 ]
python
en
['en', 'error', 'th']
False
Client.delete
(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra)
Send a DELETE request to the server.
Send a DELETE request to the server.
def delete(self, path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra): """ Send a DELETE request to the server. """ response = super(Client, self).delete(path, data=data, content_type=con...
[ "def", "delete", "(", "self", ",", "path", ",", "data", "=", "''", ",", "content_type", "=", "'application/octet-stream'", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", "Clien...
[ 598, 4 ]
[ 608, 23 ]
python
en
['en', 'error', 'th']
False
Client.trace
(self, path, data='', follow=False, secure=False, **extra)
Send a TRACE request to the server.
Send a TRACE request to the server.
def trace(self, path, data='', follow=False, secure=False, **extra): """ Send a TRACE request to the server. """ response = super(Client, self).trace(path, data=data, secure=secure, **extra) if follow: response = self._handle_redirects(response, **extra) retur...
[ "def", "trace", "(", "self", ",", "path", ",", "data", "=", "''", ",", "follow", "=", "False", ",", "secure", "=", "False", ",", "*", "*", "extra", ")", ":", "response", "=", "super", "(", "Client", ",", "self", ")", ".", "trace", "(", "path", ...
[ 610, 4 ]
[ 617, 23 ]
python
en
['en', 'error', 'th']
False
Client.login
(self, **credentials)
Sets the Factory to appear as if it has successfully logged into a site. Returns True if login is possible; False if the provided credentials are incorrect.
Sets the Factory to appear as if it has successfully logged into a site.
def login(self, **credentials): """ Sets the Factory to appear as if it has successfully logged into a site. Returns True if login is possible; False if the provided credentials are incorrect. """ from django.contrib.auth import authenticate user = authenticate(*...
[ "def", "login", "(", "self", ",", "*", "*", "credentials", ")", ":", "from", "django", ".", "contrib", ".", "auth", "import", "authenticate", "user", "=", "authenticate", "(", "*", "*", "credentials", ")", "if", "user", ":", "self", ".", "_login", "(",...
[ 619, 4 ]
[ 632, 24 ]
python
en
['en', 'error', 'th']
False
Client.logout
(self)
Removes the authenticated user's cookies and session object. Causes the authenticated user to be logged out.
Removes the authenticated user's cookies and session object.
def logout(self): """ Removes the authenticated user's cookies and session object. Causes the authenticated user to be logged out. """ from django.contrib.auth import get_user, logout request = HttpRequest() engine = import_module(settings.SESSION_ENGINE) ...
[ "def", "logout", "(", "self", ")", ":", "from", "django", ".", "contrib", ".", "auth", "import", "get_user", ",", "logout", "request", "=", "HttpRequest", "(", ")", "engine", "=", "import_module", "(", "settings", ".", "SESSION_ENGINE", ")", "if", "self", ...
[ 674, 4 ]
[ 690, 37 ]
python
en
['en', 'error', 'th']
False
Client._handle_redirects
(self, response, **extra)
Follows any redirects by requesting responses from the server using GET.
Follows any redirects by requesting responses from the server using GET.
def _handle_redirects(self, response, **extra): "Follows any redirects by requesting responses from the server using GET." response.redirect_chain = [] while response.status_code in (301, 302, 303, 307): response_url = response.url redirect_chain = response.redirect_chai...
[ "def", "_handle_redirects", "(", "self", ",", "response", ",", "*", "*", "extra", ")", ":", "response", ".", "redirect_chain", "=", "[", "]", "while", "response", ".", "status_code", "in", "(", "301", ",", "302", ",", "303", ",", "307", ")", ":", "re...
[ 702, 4 ]
[ 737, 23 ]
python
en
['en', 'en', 'en']
True
ImagePalette.getdata
(self)
Get palette contents in format suitable for the low-level ``im.putpalette`` primitive. .. warning:: This method is experimental.
Get palette contents in format suitable for the low-level ``im.putpalette`` primitive.
def getdata(self): """ Get palette contents in format suitable for the low-level ``im.putpalette`` primitive. .. warning:: This method is experimental. """ if self.rawmode: return self.rawmode, self.palette return self.mode + ";L", self.tobytes()
[ "def", "getdata", "(", "self", ")", ":", "if", "self", ".", "rawmode", ":", "return", "self", ".", "rawmode", ",", "self", ".", "palette", "return", "self", ".", "mode", "+", "\";L\"", ",", "self", ".", "tobytes", "(", ")" ]
[ 61, 4 ]
[ 70, 47 ]
python
en
['en', 'error', 'th']
False
ImagePalette.tobytes
(self)
Convert palette to bytes. .. warning:: This method is experimental.
Convert palette to bytes.
def tobytes(self): """Convert palette to bytes. .. warning:: This method is experimental. """ if self.rawmode: raise ValueError("palette contains raw palette data") if isinstance(self.palette, bytes): return self.palette arr = array.array("B", sel...
[ "def", "tobytes", "(", "self", ")", ":", "if", "self", ".", "rawmode", ":", "raise", "ValueError", "(", "\"palette contains raw palette data\"", ")", "if", "isinstance", "(", "self", ".", "palette", ",", "bytes", ")", ":", "return", "self", ".", "palette", ...
[ 72, 4 ]
[ 84, 29 ]
python
en
['en', 'en', 'en']
True
ImagePalette.getcolor
(self, color)
Given an rgb tuple, allocate palette entry. .. warning:: This method is experimental.
Given an rgb tuple, allocate palette entry.
def getcolor(self, color): """Given an rgb tuple, allocate palette entry. .. warning:: This method is experimental. """ if self.rawmode: raise ValueError("palette contains raw palette data") if isinstance(color, tuple): try: return self.co...
[ "def", "getcolor", "(", "self", ",", "color", ")", ":", "if", "self", ".", "rawmode", ":", "raise", "ValueError", "(", "\"palette contains raw palette data\"", ")", "if", "isinstance", "(", "color", ",", "tuple", ")", ":", "try", ":", "return", "self", "."...
[ 89, 4 ]
[ 113, 71 ]
python
en
['en', 'en', 'it']
True
ImagePalette.save
(self, fp)
Save palette to text file. .. warning:: This method is experimental.
Save palette to text file.
def save(self, fp): """Save palette to text file. .. warning:: This method is experimental. """ if self.rawmode: raise ValueError("palette contains raw palette data") if isinstance(fp, str): fp = open(fp, "w") fp.write("# Palette\n") fp.wr...
[ "def", "save", "(", "self", ",", "fp", ")", ":", "if", "self", ".", "rawmode", ":", "raise", "ValueError", "(", "\"palette contains raw palette data\"", ")", "if", "isinstance", "(", "fp", ",", "str", ")", ":", "fp", "=", "open", "(", "fp", ",", "\"w\"...
[ 115, 4 ]
[ 134, 18 ]
python
en
['en', 'en', 'en']
True
parse
(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs)
Parse an HTML document as a string or file-like object into a tree :arg doc: the document to parse as a string or file-like object :arg treebuilder: the treebuilder to use when parsing :arg namespaceHTMLElements: whether or not to namespace HTML elements :returns: parsed tree Example: >>> ...
Parse an HTML document as a string or file-like object into a tree
def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs): """Parse an HTML document as a string or file-like object into a tree :arg doc: the document to parse as a string or file-like object :arg treebuilder: the treebuilder to use when parsing :arg namespaceHTMLElements: whether or...
[ "def", "parse", "(", "doc", ",", "treebuilder", "=", "\"etree\"", ",", "namespaceHTMLElements", "=", "True", ",", "*", "*", "kwargs", ")", ":", "tb", "=", "treebuilders", ".", "getTreeBuilder", "(", "treebuilder", ")", "p", "=", "HTMLParser", "(", "tb", ...
[ 25, 0 ]
[ 45, 33 ]
python
en
['en', 'en', 'en']
True
parseFragment
(doc, container="div", treebuilder="etree", namespaceHTMLElements=True, **kwargs)
Parse an HTML fragment as a string or file-like object into a tree :arg doc: the fragment to parse as a string or file-like object :arg container: the container context to parse the fragment in :arg treebuilder: the treebuilder to use when parsing :arg namespaceHTMLElements: whether or not to namesp...
Parse an HTML fragment as a string or file-like object into a tree
def parseFragment(doc, container="div", treebuilder="etree", namespaceHTMLElements=True, **kwargs): """Parse an HTML fragment as a string or file-like object into a tree :arg doc: the fragment to parse as a string or file-like object :arg container: the container context to parse the fragment in :arg...
[ "def", "parseFragment", "(", "doc", ",", "container", "=", "\"div\"", ",", "treebuilder", "=", "\"etree\"", ",", "namespaceHTMLElements", "=", "True", ",", "*", "*", "kwargs", ")", ":", "tb", "=", "treebuilders", ".", "getTreeBuilder", "(", "treebuilder", ")...
[ 48, 0 ]
[ 70, 62 ]
python
en
['en', 'en', 'en']
True