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
ParserElement.addCondition
(self, *fns, **kwargs)
Add a boolean predicate function to expression's list of parse actions. See :class:`setParseAction` for function call signatures. Unlike ``setParseAction``, functions passed to ``addCondition`` need to return boolean success/fail of the condition. Optional keyword arguments: - message =...
Add a boolean predicate function to expression's list of parse actions. See :class:`setParseAction` for function call signatures. Unlike ``setParseAction``, functions passed to ``addCondition`` need to return boolean success/fail of the condition.
def addCondition(self, *fns, **kwargs): """Add a boolean predicate function to expression's list of parse actions. See :class:`setParseAction` for function call signatures. Unlike ``setParseAction``, functions passed to ``addCondition`` need to return boolean success/fail of the condition. ...
[ "def", "addCondition", "(", "self", ",", "*", "fns", ",", "*", "*", "kwargs", ")", ":", "for", "fn", "in", "fns", ":", "self", ".", "parseAction", ".", "append", "(", "conditionAsParseAction", "(", "fn", ",", "message", "=", "kwargs", ".", "get", "("...
[ 1576, 4 ]
[ 1599, 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 ``fn(s, loc, expr, err)`` where: - s = string being parsed - loc = location where expression match was attempted and failed - expr = the pars...
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 pars...
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 ``fn(s, loc, expr, err)`` where: - s = string being parsed - loc = location where expression match was attempted...
[ "def", "setFailAction", "(", "self", ",", "fn", ")", ":", "self", ".", "failAction", "=", "fn", "return", "self" ]
[ 1601, 4 ]
[ 1612, 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 par...
[ "def", "enablePackrat", "(", "cache_size_limit", "=", "128", ")", ":", "if", "not", "ParserElement", ".", "_packratEnabled", ":", "ParserElement", ".", "_packratEnabled", "=", "True", "if", "cache_size_limit", "is", "None", ":", "ParserElement", ".", "packrat_cach...
[ 1866, 4 ]
[ 1898, 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. Returns the parsed data as a :class:`ParseResults` object, which may be accessed as a list, or as a dict or object with attributes if ...
Execute the parse expression with the given string. This is the main interface to the client code, once the complete expression has been built.
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. Returns the parsed data as a :class:`ParseResults` object, which may be ac...
[ "def", "parseString", "(", "self", ",", "instring", ",", "parseAll", "=", "False", ")", ":", "ParserElement", ".", "resetCache", "(", ")", "if", "not", "self", ".", "streamlined", ":", "self", ".", "streamline", "(", ")", "# ~ self.saveAsList = True", "for",...
[ 1900, 4 ]
[ 1956, 25 ]
python
en
['en', 'error', '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 ``maxMatches`` argument, to clip scanning after 'n' matches are found. If ``overlap`` is specified, then overlapping matches will be...
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. If ``overlap`` is specified, then overlapping matches will be...
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 ``maxMatches`` argument, to clip scanning after 'n' matches ar...
[ "def", "scanString", "(", "self", ",", "instring", ",", "maxMatches", "=", "_MAX_INT", ",", "overlap", "=", "False", ")", ":", "if", "not", "self", ".", "streamlined", ":", "self", ".", "streamline", "(", ")", "for", "e", "in", "self", ".", "ignoreExpr...
[ 1958, 4 ]
[ 2030, 25 ]
python
en
['en', 'error', 'th']
False
ParserElement.transformString
(self, instring)
Extension to :class:`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...
Extension to :class:`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...
def transformString(self, instring): """ Extension to :class:`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. I...
[ "def", "transformString", "(", "self", ",", "instring", ")", ":", "out", "=", "[", "]", "lastE", "=", "0", "# force preservation of <TAB>s, to minimize unwanted transformation of string, and to", "# keep string locs straight between transformString and scanString", "self", ".", ...
[ 2032, 4 ]
[ 2078, 25 ]
python
en
['en', 'error', 'th']
False
ParserElement.searchString
(self, instring, maxMatches=_MAX_INT)
Another extension to :class:`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. Example:: # a capitalized word starts with an uppe...
Another extension to :class:`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.
def searchString(self, instring, maxMatches=_MAX_INT): """ Another extension to :class:`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. ...
[ "def", "searchString", "(", "self", ",", "instring", ",", "maxMatches", "=", "_MAX_INT", ")", ":", "try", ":", "return", "ParseResults", "(", "[", "t", "for", "t", ",", "s", ",", "e", "in", "self", ".", "scanString", "(", "instring", ",", "maxMatches",...
[ 2080, 4 ]
[ 2110, 25 ]
python
en
['en', 'error', '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 ``maxsplit`` argument, to limit the number of splits; and the optional ``includeSeparators`` argument (default= ``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 ``maxsplit`` argument, to limit the number of splits; and the optional ``includeSeparators`` argument (default= ``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 ``maxsplit`` argument, to limit the number of splits; and the optional ``includeSeparators`` argument (defa...
[ "def", "split", "(", "self", ",", "instring", ",", "maxsplit", "=", "_MAX_INT", ",", "includeSeparators", "=", "False", ")", ":", "splits", "=", "0", "last", "=", "0", "for", "t", ",", "s", ",", "e", "in", "self", ".", "scanString", "(", "instring", ...
[ 2112, 4 ]
[ 2135, 29 ]
python
en
['en', 'error', 'th']
False
ParserElement.__add__
(self, other)
Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement converts them to :class:`Literal`s by default. Example:: greet = Word(alphas) + "," + Word(alphas) + "!" hello = "Hello, World!" print (hello, "->", greet.parseString(hel...
Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement converts them to :class:`Literal`s by default.
def __add__(self, other): """ Implementation of + operator - returns :class:`And`. Adding strings to a ParserElement converts them to :class:`Literal`s by default. Example:: greet = Word(alphas) + "," + Word(alphas) + "!" hello = "Hello, World!" prin...
[ "def", "__add__", "(", "self", ",", "other", ")", ":", "if", "other", "is", "Ellipsis", ":", "return", "_PendingSkip", "(", "self", ")", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ".", "_literalStringClass", "(",...
[ 2137, 4 ]
[ 2173, 33 ]
python
en
['en', 'error', 'th']
False
ParserElement.__radd__
(self, other)
Implementation of + operator when left operand is not a :class:`ParserElement`
Implementation of + operator when left operand is not a :class:`ParserElement`
def __radd__(self, other): """ Implementation of + operator when left operand is not a :class:`ParserElement` """ if other is Ellipsis: return SkipTo(self)("_skipped*") + self if isinstance(other, basestring): other = self._literalStringClass(other) ...
[ "def", "__radd__", "(", "self", ",", "other", ")", ":", "if", "other", "is", "Ellipsis", ":", "return", "SkipTo", "(", "self", ")", "(", "\"_skipped*\"", ")", "+", "self", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "...
[ 2175, 4 ]
[ 2188, 27 ]
python
en
['en', 'error', 'th']
False
ParserElement.__sub__
(self, other)
Implementation of - operator, returns :class:`And` with error stop
Implementation of - operator, returns :class:`And` with error stop
def __sub__(self, other): """ Implementation of - operator, returns :class:`And` with error stop """ if isinstance(other, basestring): other = self._literalStringClass(other) if not isinstance(other, ParserElement): warnings.warn("Cannot combine element of...
[ "def", "__sub__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement", ")",...
[ 2190, 4 ]
[ 2200, 46 ]
python
en
['en', 'error', 'th']
False
ParserElement.__rsub__
(self, other)
Implementation of - operator when left operand is not a :class:`ParserElement`
Implementation of - operator when left operand is not a :class:`ParserElement`
def __rsub__(self, other): """ Implementation of - operator when left operand is not a :class:`ParserElement` """ if isinstance(other, basestring): other = self._literalStringClass(other) if not isinstance(other, ParserElement): warnings.warn("Cannot combi...
[ "def", "__rsub__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement", ")"...
[ 2202, 4 ]
[ 2212, 27 ]
python
en
['en', 'error', 'th']
False
ParserElement.__mul__
(self, other)
Implementation of * operator, allows use of ``expr * 3`` in place of ``expr + expr + expr``. Expressions may also me multiplied by a 2-integer tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples may also include ``None`` as in: - ``expr*(n, None)`` or ...
Implementation of * operator, allows use of ``expr * 3`` in place of ``expr + expr + expr``. Expressions may also me multiplied by a 2-integer tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples may also include ``None`` as in: - ``expr*(n, None)`` or ...
def __mul__(self, other): """ Implementation of * operator, allows use of ``expr * 3`` in place of ``expr + expr + expr``. Expressions may also me multiplied by a 2-integer tuple, similar to ``{min, max}`` multipliers in regular expressions. Tuples may also include ``None`` as ...
[ "def", "__mul__", "(", "self", ",", "other", ")", ":", "if", "other", "is", "Ellipsis", ":", "other", "=", "(", "0", ",", "None", ")", "elif", "isinstance", "(", "other", ",", "tuple", ")", "and", "other", "[", ":", "1", "]", "==", "(", "Ellipsis...
[ 2214, 4 ]
[ 2286, 18 ]
python
en
['en', 'error', 'th']
False
ParserElement.__or__
(self, other)
Implementation of | operator - returns :class:`MatchFirst`
Implementation of | operator - returns :class:`MatchFirst`
def __or__(self, other): """ Implementation of | operator - returns :class:`MatchFirst` """ if other is Ellipsis: return _PendingSkip(self, must_skip=True) if isinstance(other, basestring): other = self._literalStringClass(other) if not isinstance...
[ "def", "__or__", "(", "self", ",", "other", ")", ":", "if", "other", "is", "Ellipsis", ":", "return", "_PendingSkip", "(", "self", ",", "must_skip", "=", "True", ")", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ...
[ 2291, 4 ]
[ 2304, 40 ]
python
en
['en', 'error', 'th']
False
ParserElement.__ror__
(self, other)
Implementation of | operator when left operand is not a :class:`ParserElement`
Implementation of | operator when left operand is not a :class:`ParserElement`
def __ror__(self, other): """ Implementation of | operator when left operand is not a :class:`ParserElement` """ if isinstance(other, basestring): other = self._literalStringClass(other) if not isinstance(other, ParserElement): warnings.warn("Cannot combin...
[ "def", "__ror__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement", ")",...
[ 2306, 4 ]
[ 2316, 27 ]
python
en
['en', 'error', 'th']
False
ParserElement.__xor__
(self, other)
Implementation of ^ operator - returns :class:`Or`
Implementation of ^ operator - returns :class:`Or`
def __xor__(self, other): """ Implementation of ^ operator - returns :class:`Or` """ if isinstance(other, basestring): other = self._literalStringClass(other) if not isinstance(other, ParserElement): warnings.warn("Cannot combine element of type %s with Pa...
[ "def", "__xor__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement", ")",...
[ 2318, 4 ]
[ 2328, 32 ]
python
en
['en', 'error', 'th']
False
ParserElement.__rxor__
(self, other)
Implementation of ^ operator when left operand is not a :class:`ParserElement`
Implementation of ^ operator when left operand is not a :class:`ParserElement`
def __rxor__(self, other): """ Implementation of ^ operator when left operand is not a :class:`ParserElement` """ if isinstance(other, basestring): other = self._literalStringClass(other) if not isinstance(other, ParserElement): warnings.warn("Cannot combi...
[ "def", "__rxor__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement", ")"...
[ 2330, 4 ]
[ 2340, 27 ]
python
en
['en', 'error', 'th']
False
ParserElement.__and__
(self, other)
Implementation of & operator - returns :class:`Each`
Implementation of & operator - returns :class:`Each`
def __and__(self, other): """ Implementation of & operator - returns :class:`Each` """ if isinstance(other, basestring): other = self._literalStringClass(other) if not isinstance(other, ParserElement): warnings.warn("Cannot combine element of type %s with ...
[ "def", "__and__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement", ")",...
[ 2342, 4 ]
[ 2352, 34 ]
python
en
['en', 'error', 'th']
False
ParserElement.__rand__
(self, other)
Implementation of & operator when left operand is not a :class:`ParserElement`
Implementation of & operator when left operand is not a :class:`ParserElement`
def __rand__(self, other): """ Implementation of & operator when left operand is not a :class:`ParserElement` """ if isinstance(other, basestring): other = self._literalStringClass(other) if not isinstance(other, ParserElement): warnings.warn("Cannot combi...
[ "def", "__rand__", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "self", ".", "_literalStringClass", "(", "other", ")", "if", "not", "isinstance", "(", "other", ",", "ParserElement", ")"...
[ 2354, 4 ]
[ 2364, 27 ]
python
en
['en', 'error', 'th']
False
ParserElement.__invert__
(self)
Implementation of ~ operator - returns :class:`NotAny`
Implementation of ~ operator - returns :class:`NotAny`
def __invert__(self): """ Implementation of ~ operator - returns :class:`NotAny` """ return NotAny(self)
[ "def", "__invert__", "(", "self", ")", ":", "return", "NotAny", "(", "self", ")" ]
[ 2366, 4 ]
[ 2370, 27 ]
python
en
['en', 'error', 'th']
False
ParserElement.__getitem__
(self, key)
use ``[]`` indexing notation as a short form for expression repetition: - ``expr[n]`` is equivalent to ``expr*n`` - ``expr[m, n]`` is equivalent to ``expr*(m, n)`` - ``expr[n, ...]`` or ``expr[n,]`` is equivalent to ``expr*n + ZeroOrMore(expr)`` (read as "...
use ``[]`` indexing notation as a short form for expression repetition: - ``expr[n]`` is equivalent to ``expr*n`` - ``expr[m, n]`` is equivalent to ``expr*(m, n)`` - ``expr[n, ...]`` or ``expr[n,]`` is equivalent to ``expr*n + ZeroOrMore(expr)`` (read as "...
def __getitem__(self, key): """ use ``[]`` indexing notation as a short form for expression repetition: - ``expr[n]`` is equivalent to ``expr*n`` - ``expr[m, n]`` is equivalent to ``expr*(m, n)`` - ``expr[n, ...]`` or ``expr[n,]`` is equivalent to ``expr*n + Zero...
[ "def", "__getitem__", "(", "self", ",", "key", ")", ":", "# convert single arg keys to tuples", "try", ":", "if", "isinstance", "(", "key", ",", "str", ")", ":", "key", "=", "(", "key", ",", ")", "iter", "(", "key", ")", "except", "TypeError", ":", "ke...
[ 2377, 4 ]
[ 2411, 18 ]
python
en
['en', 'error', 'th']
False
ParserElement.__call__
(self, name=None)
Shortcut for :class:`setResultsName`, with ``listAllMatches=False``. If ``name`` is given with a trailing ``'*'`` character, then ``listAllMatches`` will be passed as ``True``. If ``name` is omitted, same as calling :class:`copy`. Example:: # these are equivalent...
Shortcut for :class:`setResultsName`, with ``listAllMatches=False``.
def __call__(self, name=None): """ Shortcut for :class:`setResultsName`, with ``listAllMatches=False``. If ``name`` is given with a trailing ``'*'`` character, then ``listAllMatches`` will be passed as ``True``. If ``name` is omitted, same as calling :class:`copy`. Exa...
[ "def", "__call__", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "not", "None", ":", "return", "self", ".", "_setResultsName", "(", "name", ")", "else", ":", "return", "self", ".", "copy", "(", ")" ]
[ 2413, 4 ]
[ 2431, 30 ]
python
en
['en', 'error', 'th']
False
ParserElement.suppress
(self)
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from cluttering up returned output.
Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from cluttering up returned output.
def suppress(self): """ Suppresses the output of this :class:`ParserElement`; useful to keep punctuation from cluttering up returned output. """ return Suppress(self)
[ "def", "suppress", "(", "self", ")", ":", "return", "Suppress", "(", "self", ")" ]
[ 2433, 4 ]
[ 2438, 29 ]
python
en
['en', 'error', 'th']
False
ParserElement.leaveWhitespace
(self)
Disables the skipping of whitespace before matching the characters in the :class:`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 :class:`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 :class:`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" ]
[ 2440, 4 ]
[ 2447, 19 ]
python
en
['en', 'error', '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" ]
[ 2449, 4 ]
[ 2456, 19 ]
python
en
['en', 'error', 'th']
False
ParserElement.parseWithTabs
(self)
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.
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.
def parseWithTabs(self): """ 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. """ self.keepTabs = True return ...
[ "def", "parseWithTabs", "(", "self", ")", ":", "self", ".", "keepTabs", "=", "True", "return", "self" ]
[ 2458, 4 ]
[ 2465, 19 ]
python
en
['en', 'error', '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') # -> ['ablaj'...
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 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...
[ "def", "ignore", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "basestring", ")", ":", "other", "=", "Suppress", "(", "other", ")", "if", "isinstance", "(", "other", ",", "Suppress", ")", ":", "if", "other", "not", "in",...
[ 2467, 4 ]
[ 2489, 19 ]
python
en
['en', 'error', '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", ",", ...
[ 2491, 4 ]
[ 2499, 19 ]
python
en
['en', 'error', 'th']
False
ParserElement.setDebug
(self, flag=True)
Enable display of debugging messages while doing pattern matching. Set ``flag`` to True to enable, False to disable. Example:: wd = Word(alphas).setName("alphaword") integer = Word(nums).setName("numword") term = wd | integer # turn on debuggin...
Enable display of debugging messages while doing pattern matching. Set ``flag`` to True to enable, False to disable.
def setDebug(self, flag=True): """ Enable display of debugging messages while doing pattern matching. Set ``flag`` to True to enable, False to disable. Example:: wd = Word(alphas).setName("alphaword") integer = Word(nums).setName("numword") term = wd...
[ "def", "setDebug", "(", "self", ",", "flag", "=", "True", ")", ":", "if", "flag", ":", "self", ".", "setDebugActions", "(", "_defaultStartDebugAction", ",", "_defaultSuccessDebugAction", ",", "_defaultExceptionDebugAction", ")", "else", ":", "self", ".", "debug"...
[ 2501, 4 ]
[ 2542, 19 ]
python
en
['en', 'error', 'th']
False
exit
(msg)
exit testing process as if KeyboardInterrupt was triggered.
exit testing process as if KeyboardInterrupt was triggered.
def exit(msg): """ exit testing process as if KeyboardInterrupt was triggered. """ __tracebackhide__ = True raise Exit(msg)
[ "def", "exit", "(", "msg", ")", ":", "__tracebackhide__", "=", "True", "raise", "Exit", "(", "msg", ")" ]
[ 55, 0 ]
[ 58, 19 ]
python
en
['en', 'en', 'en']
True
skip
(msg="", **kwargs)
skip an executing test with the given message. Note: it's usually better to use the pytest.mark.skipif marker to declare a test to be skipped under certain conditions like mismatching platforms or dependencies. See the pytest_skipping plugin for details. :kwarg bool allow_module_level: allows this f...
skip an executing test with the given message. Note: it's usually better to use the pytest.mark.skipif marker to declare a test to be skipped under certain conditions like mismatching platforms or dependencies. See the pytest_skipping plugin for details.
def skip(msg="", **kwargs): """ skip an executing test with the given message. Note: it's usually better to use the pytest.mark.skipif marker to declare a test to be skipped under certain conditions like mismatching platforms or dependencies. See the pytest_skipping plugin for details. :kwarg boo...
[ "def", "skip", "(", "msg", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "__tracebackhide__", "=", "True", "allow_module_level", "=", "kwargs", ".", "pop", "(", "'allow_module_level'", ",", "False", ")", "if", "kwargs", ":", "keys", "=", "[", "k", "f...
[ 64, 0 ]
[ 78, 65 ]
python
en
['en', 'en', 'en']
True
fail
(msg="", pytrace=True)
explicitly fail an currently-executing test with the given Message. :arg pytrace: if false the msg represents the full failure information and no python traceback will be reported.
explicitly fail an currently-executing test with the given Message.
def fail(msg="", pytrace=True): """ explicitly fail an currently-executing test with the given Message. :arg pytrace: if false the msg represents the full failure information and no python traceback will be reported. """ __tracebackhide__ = True raise Failed(msg=msg, pytrace=pytra...
[ "def", "fail", "(", "msg", "=", "\"\"", ",", "pytrace", "=", "True", ")", ":", "__tracebackhide__", "=", "True", "raise", "Failed", "(", "msg", "=", "msg", ",", "pytrace", "=", "pytrace", ")" ]
[ 84, 0 ]
[ 91, 42 ]
python
en
['en', 'en', 'en']
True
xfail
(reason="")
xfail an executing test or setup functions with the given reason.
xfail an executing test or setup functions with the given reason.
def xfail(reason=""): """ xfail an executing test or setup functions with the given reason.""" __tracebackhide__ = True raise XFailed(reason)
[ "def", "xfail", "(", "reason", "=", "\"\"", ")", ":", "__tracebackhide__", "=", "True", "raise", "XFailed", "(", "reason", ")" ]
[ 101, 0 ]
[ 104, 25 ]
python
en
['en', 'en', 'en']
True
importorskip
(modname, minversion=None)
return imported module if it has at least "minversion" as its __version__ attribute. If no minversion is specified the a skip is only triggered if the module can not be imported.
return imported module if it has at least "minversion" as its __version__ attribute. If no minversion is specified the a skip is only triggered if the module can not be imported.
def importorskip(modname, minversion=None): """ return imported module if it has at least "minversion" as its __version__ attribute. If no minversion is specified the a skip is only triggered if the module can not be imported. """ import warnings __tracebackhide__ = True compile(modname, ''...
[ "def", "importorskip", "(", "modname", ",", "minversion", "=", "None", ")", ":", "import", "warnings", "__tracebackhide__", "=", "True", "compile", "(", "modname", ",", "''", ",", "'eval'", ")", "# to catch syntaxerrors", "should_skip", "=", "False", "with", "...
[ 110, 0 ]
[ 146, 14 ]
python
en
['en', 'en', 'en']
True
Cache.get
(self, id)
Get a object from the cache by ID. @param id: The object ID. @type id: str @return: The object, else None @rtype: any
Get a object from the cache by ID.
def get(self, id): """ Get a object from the cache by ID. @param id: The object ID. @type id: str @return: The object, else None @rtype: any """ raise Exception('not-implemented')
[ "def", "get", "(", "self", ",", "id", ")", ":", "raise", "Exception", "(", "'not-implemented'", ")" ]
[ 43, 4 ]
[ 51, 42 ]
python
en
['en', 'error', 'th']
False
Cache.getf
(self, id)
Get a object from the cache by ID. @param id: The object ID. @type id: str @return: The object, else None @rtype: any
Get a object from the cache by ID.
def getf(self, id): """ Get a object from the cache by ID. @param id: The object ID. @type id: str @return: The object, else None @rtype: any """ raise Exception('not-implemented')
[ "def", "getf", "(", "self", ",", "id", ")", ":", "raise", "Exception", "(", "'not-implemented'", ")" ]
[ 53, 4 ]
[ 61, 42 ]
python
en
['en', 'error', 'th']
False
Cache.put
(self, id, object)
Put a object into the cache. @param id: The object ID. @type id: str @param object: The object to add. @type object: any
Put a object into the cache.
def put(self, id, object): """ Put a object into the cache. @param id: The object ID. @type id: str @param object: The object to add. @type object: any """ raise Exception('not-implemented')
[ "def", "put", "(", "self", ",", "id", ",", "object", ")", ":", "raise", "Exception", "(", "'not-implemented'", ")" ]
[ 63, 4 ]
[ 71, 42 ]
python
en
['en', 'error', 'th']
False
Cache.putf
(self, id, fp)
Write a fp into the cache. @param id: The object ID. @type id: str @param fp: File pointer. @type fp: file-like object.
Write a fp into the cache.
def putf(self, id, fp): """ Write a fp into the cache. @param id: The object ID. @type id: str @param fp: File pointer. @type fp: file-like object. """ raise Exception('not-implemented')
[ "def", "putf", "(", "self", ",", "id", ",", "fp", ")", ":", "raise", "Exception", "(", "'not-implemented'", ")" ]
[ 73, 4 ]
[ 81, 42 ]
python
en
['en', 'error', 'th']
False
Cache.purge
(self, id)
Purge a object from the cache by id. @param id: A object ID. @type id: str
Purge a object from the cache by id.
def purge(self, id): """ Purge a object from the cache by id. @param id: A object ID. @type id: str """ raise Exception('not-implemented')
[ "def", "purge", "(", "self", ",", "id", ")", ":", "raise", "Exception", "(", "'not-implemented'", ")" ]
[ 83, 4 ]
[ 89, 42 ]
python
en
['en', 'error', 'th']
False
Cache.clear
(self)
Clear all objects from the cache.
Clear all objects from the cache.
def clear(self): """ Clear all objects from the cache. """ raise Exception('not-implemented')
[ "def", "clear", "(", "self", ")", ":", "raise", "Exception", "(", "'not-implemented'", ")" ]
[ 91, 4 ]
[ 95, 42 ]
python
en
['en', 'error', 'th']
False
FileCache.__init__
(self, location=None, **duration)
@param location: The directory for the cached files. @type location: str @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. The duration may be: (months|weeks|days|hours|minutes|seconds). @type d...
def __init__(self, location=None, **duration): """ @param location: The directory for the cached files. @type location: str @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. The duration may be: ...
[ "def", "__init__", "(", "self", ",", "location", "=", "None", ",", "*", "*", "duration", ")", ":", "if", "location", "is", "None", ":", "location", "=", "os", ".", "path", ".", "join", "(", "tmp", "(", ")", ",", "'suds'", ")", "self", ".", "locat...
[ 130, 4 ]
[ 144, 27 ]
python
en
['en', 'error', 'th']
False
FileCache.fnsuffix
(self)
Get the file name suffix @return: The suffix @rtype: str
Get the file name suffix
def fnsuffix(self): """ Get the file name suffix @return: The suffix @rtype: str """ return 'gcf'
[ "def", "fnsuffix", "(", "self", ")", ":", "return", "'gcf'" ]
[ 146, 4 ]
[ 152, 20 ]
python
en
['en', 'error', 'th']
False
FileCache.setduration
(self, **duration)
Set the caching duration which defines how long the file will be cached. @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. The duration may be: (months|weeks|days|hours|minutes|seconds). @type ...
Set the caching duration which defines how long the file will be cached.
def setduration(self, **duration): """ Set the caching duration which defines how long the file will be cached. @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. The duration may be: (months|wee...
[ "def", "setduration", "(", "self", ",", "*", "*", "duration", ")", ":", "if", "len", "(", "duration", ")", "==", "1", ":", "arg", "=", "duration", ".", "items", "(", ")", "[", "0", "]", "if", "not", "arg", "[", "0", "]", "in", "self", ".", "u...
[ 154, 4 ]
[ 168, 19 ]
python
en
['en', 'error', 'th']
False
FileCache.setlocation
(self, location)
Set the location (directory) for the cached files. @param location: The directory for the cached files. @type location: str
Set the location (directory) for the cached files.
def setlocation(self, location): """ Set the location (directory) for the cached files. @param location: The directory for the cached files. @type location: str """ self.location = location
[ "def", "setlocation", "(", "self", ",", "location", ")", ":", "self", ".", "location", "=", "location" ]
[ 170, 4 ]
[ 176, 32 ]
python
en
['en', 'error', 'th']
False
FileCache.mktmp
(self)
Make the I{location} directory if it doesn't already exits.
Make the I{location} directory if it doesn't already exits.
def mktmp(self): """ Make the I{location} directory if it doesn't already exits. """ try: if not os.path.isdir(self.location): os.makedirs(self.location) except: log.debug(self.location, exc_info=1) return self
[ "def", "mktmp", "(", "self", ")", ":", "try", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "self", ".", "location", ")", ":", "os", ".", "makedirs", "(", "self", ".", "location", ")", "except", ":", "log", ".", "debug", "(", "self", ...
[ 178, 4 ]
[ 187, 19 ]
python
en
['en', 'error', 'th']
False
FileCache.validate
(self, fn)
Validate that the file has not expired based on the I{duration}. @param fn: The file name. @type fn: str
Validate that the file has not expired based on the I{duration}.
def validate(self, fn): """ Validate that the file has not expired based on the I{duration}. @param fn: The file name. @type fn: str """ if self.duration[1] < 1: return created = dt.fromtimestamp(os.path.getctime(fn)) d = { self.duration[0]:sel...
[ "def", "validate", "(", "self", ",", "fn", ")", ":", "if", "self", ".", "duration", "[", "1", "]", "<", "1", ":", "return", "created", "=", "dt", ".", "fromtimestamp", "(", "os", ".", "path", ".", "getctime", "(", "fn", ")", ")", "d", "=", "{",...
[ 229, 4 ]
[ 242, 25 ]
python
en
['en', 'error', 'th']
False
FileCache.open
(self, fn, *args)
Open the cache file making sure the directory is created.
Open the cache file making sure the directory is created.
def open(self, fn, *args): """ Open the cache file making sure the directory is created. """ self.mktmp() return open(fn, *args)
[ "def", "open", "(", "self", ",", "fn", ",", "*", "args", ")", ":", "self", ".", "mktmp", "(", ")", "return", "open", "(", "fn", ",", "*", "args", ")" ]
[ 259, 4 ]
[ 264, 30 ]
python
en
['en', 'error', 'th']
False
Postprocessor.run
(self, text)
Subclasses of Postprocessor should implement a `run` method, which takes the html document as a single text string and returns a (possibly modified) string.
Subclasses of Postprocessor should implement a `run` method, which takes the html document as a single text string and returns a (possibly modified) string.
def run(self, text): """ Subclasses of Postprocessor should implement a `run` method, which takes the html document as a single text string and returns a (possibly modified) string. """ pass
[ "def", "run", "(", "self", ",", "text", ")", ":", "pass" ]
[ 29, 4 ]
[ 36, 12 ]
python
en
['en', 'error', 'th']
False
RawHtmlPostprocessor.run
(self, text)
Iterate over html stash and restore "safe" html.
Iterate over html stash and restore "safe" html.
def run(self, text): """ Iterate over html stash and restore "safe" html. """ for i in range(self.markdown.htmlStash.html_counter): html, safe = self.markdown.htmlStash.rawHtmlBlocks[i] if self.markdown.safeMode and not safe: if str(self.markdown.safeMode).lower(...
[ "def", "run", "(", "self", ",", "text", ")", ":", "for", "i", "in", "range", "(", "self", ".", "markdown", ".", "htmlStash", ".", "html_counter", ")", ":", "html", ",", "safe", "=", "self", ".", "markdown", ".", "htmlStash", ".", "rawHtmlBlocks", "["...
[ 42, 4 ]
[ 59, 19 ]
python
en
['en', 'en', 'en']
True
RawHtmlPostprocessor.escape
(self, html)
Basic html escaping
Basic html escaping
def escape(self, html): """ Basic html escaping """ html = html.replace('&', '&amp;') html = html.replace('<', '&lt;') html = html.replace('>', '&gt;') return html.replace('"', '&quot;')
[ "def", "escape", "(", "self", ",", "html", ")", ":", "html", "=", "html", ".", "replace", "(", "'&'", ",", "'&amp;'", ")", "html", "=", "html", ".", "replace", "(", "'<'", ",", "'&lt;'", ")", "html", "=", "html", ".", "replace", "(", "'>'", ",", ...
[ 61, 4 ]
[ 66, 42 ]
python
en
['es', 'en', 'en']
True
precook
(s, n=4, out=False)
Takes a string as input and returns an object that can be given to either cook_refs or cook_test. This is optional: cook_refs and cook_test can take string arguments as well.
Takes a string as input and returns an object that can be given to either cook_refs or cook_test. This is optional: cook_refs and cook_test can take string arguments as well.
def precook(s, n=4, out=False): """Takes a string as input and returns an object that can be given to either cook_refs or cook_test. This is optional: cook_refs and cook_test can take string arguments as well.""" words = s.split() counts = defaultdict(int) for k in range(1, n + 1): for i...
[ "def", "precook", "(", "s", ",", "n", "=", "4", ",", "out", "=", "False", ")", ":", "words", "=", "s", ".", "split", "(", ")", "counts", "=", "defaultdict", "(", "int", ")", "for", "k", "in", "range", "(", "1", ",", "n", "+", "1", ")", ":",...
[ 23, 0 ]
[ 33, 31 ]
python
en
['en', 'en', 'en']
True
cook_refs
(refs, eff=None, n=4)
Takes a list of reference sentences for a single segment and returns an object that encapsulates everything that BLEU needs to know about them.
Takes a list of reference sentences for a single segment and returns an object that encapsulates everything that BLEU needs to know about them.
def cook_refs(refs, eff=None, n=4): ## lhuang: oracle will call with "average" '''Takes a list of reference sentences for a single segment and returns an object that encapsulates everything that BLEU needs to know about them.''' reflen = [] maxcounts = {} for ref in refs: rl, counts = ...
[ "def", "cook_refs", "(", "refs", ",", "eff", "=", "None", ",", "n", "=", "4", ")", ":", "## lhuang: oracle will call with \"average\"", "reflen", "=", "[", "]", "maxcounts", "=", "{", "}", "for", "ref", "in", "refs", ":", "rl", ",", "counts", "=", "pre...
[ 36, 0 ]
[ 59, 30 ]
python
en
['en', 'en', 'en']
True
cook_test
(test, ref_tuple, eff=None, n=4)
Takes a test sentence and returns an object that encapsulates everything that BLEU needs to know about it.
Takes a test sentence and returns an object that encapsulates everything that BLEU needs to know about it.
def cook_test(test, ref_tuple, eff=None, n=4): '''Takes a test sentence and returns an object that encapsulates everything that BLEU needs to know about it.''' testlen, counts = precook(test, n, True) reflen, refmaxcounts = ref_tuple result = {} # Calculate effective reference sentence length...
[ "def", "cook_test", "(", "test", ",", "ref_tuple", ",", "eff", "=", "None", ",", "n", "=", "4", ")", ":", "testlen", ",", "counts", "=", "precook", "(", "test", ",", "n", ",", "True", ")", "reflen", ",", "refmaxcounts", "=", "ref_tuple", "result", ...
[ 62, 0 ]
[ 86, 17 ]
python
en
['en', 'en', 'en']
True
BleuScorer.copy
(self)
copy the refs.
copy the refs.
def copy(self): ''' copy the refs.''' new = BleuScorer(n=self.n) new.ctest = copy.copy(self.ctest) new.crefs = copy.copy(self.crefs) new._score = None return new
[ "def", "copy", "(", "self", ")", ":", "new", "=", "BleuScorer", "(", "n", "=", "self", ".", "n", ")", "new", ".", "ctest", "=", "copy", ".", "copy", "(", "self", ".", "ctest", ")", "new", ".", "crefs", "=", "copy", ".", "copy", "(", "self", "...
[ 97, 4 ]
[ 103, 18 ]
python
en
['en', 'it', 'en']
True
BleuScorer.__init__
(self, test=None, refs=None, n=4, special_reflen=None)
singular instance
singular instance
def __init__(self, test=None, refs=None, n=4, special_reflen=None): ''' singular instance ''' self.n = n self.crefs = [] self.ctest = [] self.cook_append(test, refs) self.special_reflen = special_reflen
[ "def", "__init__", "(", "self", ",", "test", "=", "None", ",", "refs", "=", "None", ",", "n", "=", "4", ",", "special_reflen", "=", "None", ")", ":", "self", ".", "n", "=", "n", "self", ".", "crefs", "=", "[", "]", "self", ".", "ctest", "=", ...
[ 105, 4 ]
[ 112, 44 ]
python
en
['en', 'de', 'en']
False
BleuScorer.cook_append
(self, test, refs)
called by constructor and __iadd__ to avoid creating new instances.
called by constructor and __iadd__ to avoid creating new instances.
def cook_append(self, test, refs): '''called by constructor and __iadd__ to avoid creating new instances.''' if refs is not None: self.crefs.append(cook_refs(refs)) if test is not None: cooked_test = cook_test(test, self.crefs[-1]) self.ctest.appe...
[ "def", "cook_append", "(", "self", ",", "test", ",", "refs", ")", ":", "if", "refs", "is", "not", "None", ":", "self", ".", "crefs", ".", "append", "(", "cook_refs", "(", "refs", ")", ")", "if", "test", "is", "not", "None", ":", "cooked_test", "=",...
[ 114, 4 ]
[ 125, 26 ]
python
en
['en', 'en', 'en']
True
BleuScorer.score_ratio
(self, option=None)
return (bleu, len_ratio) pair
return (bleu, len_ratio) pair
def score_ratio(self, option=None): ''' return (bleu, len_ratio) pair ''' return self.fscore(option=option), self.ratio(option=option)
[ "def", "score_ratio", "(", "self", ",", "option", "=", "None", ")", ":", "return", "self", ".", "fscore", "(", "option", "=", "option", ")", ",", "self", ".", "ratio", "(", "option", "=", "option", ")" ]
[ 131, 4 ]
[ 136, 68 ]
python
en
['en', 'error', 'th']
False
BleuScorer.rescore
(self, new_test)
replace test(s) with new test(s), and returns the new score.
replace test(s) with new test(s), and returns the new score.
def rescore(self, new_test): ''' replace test(s) with new test(s), and returns the new score.''' return self.retest(new_test).compute_score()
[ "def", "rescore", "(", "self", ",", "new_test", ")", ":", "return", "self", ".", "retest", "(", "new_test", ")", ".", "compute_score", "(", ")" ]
[ 160, 4 ]
[ 163, 52 ]
python
en
['en', 'en', 'en']
True
BleuScorer.__iadd__
(self, other)
add an instance (e.g., from another sentence).
add an instance (e.g., from another sentence).
def __iadd__(self, other): '''add an instance (e.g., from another sentence).''' if type(other) is tuple: ## avoid creating new BleuScorer instances self.cook_append(other[0], other[1]) else: assert self.compatible(other), "incompatible BLEUs." sel...
[ "def", "__iadd__", "(", "self", ",", "other", ")", ":", "if", "type", "(", "other", ")", "is", "tuple", ":", "## avoid creating new BleuScorer instances", "self", ".", "cook_append", "(", "other", "[", "0", "]", ",", "other", "[", "1", "]", ")", "else", ...
[ 169, 4 ]
[ 181, 19 ]
python
en
['en', 'en', 'en']
True
TreeWalker.__init__
(self, tree)
Creates a TreeWalker :arg tree: the tree to walk
Creates a TreeWalker
def __init__(self, tree): """Creates a TreeWalker :arg tree: the tree to walk """ self.tree = tree
[ "def", "__init__", "(", "self", ",", "tree", ")", ":", "self", ".", "tree", "=", "tree" ]
[ 26, 4 ]
[ 32, 24 ]
python
en
['en', 'et', 'en']
True
TreeWalker.error
(self, msg)
Generates an error token with the given message :arg msg: the error message :returns: SerializeError token
Generates an error token with the given message
def error(self, msg): """Generates an error token with the given message :arg msg: the error message :returns: SerializeError token """ return {"type": "SerializeError", "data": msg}
[ "def", "error", "(", "self", ",", "msg", ")", ":", "return", "{", "\"type\"", ":", "\"SerializeError\"", ",", "\"data\"", ":", "msg", "}" ]
[ 37, 4 ]
[ 45, 54 ]
python
en
['en', 'en', 'en']
True
TreeWalker.emptyTag
(self, namespace, name, attrs, hasChildren=False)
Generates an EmptyTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :arg hasChildren: whether or not to yield a SerializationError because this tag shouldn't have ch...
Generates an EmptyTag token
def emptyTag(self, namespace, name, attrs, hasChildren=False): """Generates an EmptyTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :arg hasChildren: whether or not to...
[ "def", "emptyTag", "(", "self", ",", "namespace", ",", "name", ",", "attrs", ",", "hasChildren", "=", "False", ")", ":", "yield", "{", "\"type\"", ":", "\"EmptyTag\"", ",", "\"name\"", ":", "name", ",", "\"namespace\"", ":", "namespace", ",", "\"data\"", ...
[ 47, 4 ]
[ 66, 57 ]
python
de
['en', 'de', 'nl']
False
TreeWalker.startTag
(self, namespace, name, attrs)
Generates a StartTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :returns: StartTag token
Generates a StartTag token
def startTag(self, namespace, name, attrs): """Generates a StartTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :arg attrs: the attributes of the element as a dict :returns: StartTag token """ return {"...
[ "def", "startTag", "(", "self", ",", "namespace", ",", "name", ",", "attrs", ")", ":", "return", "{", "\"type\"", ":", "\"StartTag\"", ",", "\"name\"", ":", "name", ",", "\"namespace\"", ":", "namespace", ",", "\"data\"", ":", "attrs", "}" ]
[ 68, 4 ]
[ 83, 30 ]
python
en
['en', 'de', 'en']
True
TreeWalker.endTag
(self, namespace, name)
Generates an EndTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :returns: EndTag token
Generates an EndTag token
def endTag(self, namespace, name): """Generates an EndTag token :arg namespace: the namespace of the token--can be ``None`` :arg name: the name of the element :returns: EndTag token """ return {"type": "EndTag", "name": name, "namespace...
[ "def", "endTag", "(", "self", ",", "namespace", ",", "name", ")", ":", "return", "{", "\"type\"", ":", "\"EndTag\"", ",", "\"name\"", ":", "name", ",", "\"namespace\"", ":", "namespace", "}" ]
[ 85, 4 ]
[ 97, 39 ]
python
en
['en', 'en', 'nl']
True
TreeWalker.text
(self, data)
Generates SpaceCharacters and Characters tokens Depending on what's in the data, this generates one or more ``SpaceCharacters`` and ``Characters`` tokens. For example: >>> from html5lib.treewalkers.base import TreeWalker >>> # Give it an empty tree just so it instantia...
Generates SpaceCharacters and Characters tokens
def text(self, data): """Generates SpaceCharacters and Characters tokens Depending on what's in the data, this generates one or more ``SpaceCharacters`` and ``Characters`` tokens. For example: >>> from html5lib.treewalkers.base import TreeWalker >>> # Give it a...
[ "def", "text", "(", "self", ",", "data", ")", ":", "data", "=", "data", "middle", "=", "data", ".", "lstrip", "(", "spaceCharacters", ")", "left", "=", "data", "[", ":", "len", "(", "data", ")", "-", "len", "(", "middle", ")", "]", "if", "left", ...
[ 99, 4 ]
[ 135, 60 ]
python
en
['en', 'en', 'en']
True
TreeWalker.comment
(self, data)
Generates a Comment token :arg data: the comment :returns: Comment token
Generates a Comment token
def comment(self, data): """Generates a Comment token :arg data: the comment :returns: Comment token """ return {"type": "Comment", "data": data}
[ "def", "comment", "(", "self", ",", "data", ")", ":", "return", "{", "\"type\"", ":", "\"Comment\"", ",", "\"data\"", ":", "data", "}" ]
[ 137, 4 ]
[ 145, 48 ]
python
en
['en', 'en', 'en']
True
TreeWalker.doctype
(self, name, publicId=None, systemId=None)
Generates a Doctype token :arg name: :arg publicId: :arg systemId: :returns: the Doctype token
Generates a Doctype token
def doctype(self, name, publicId=None, systemId=None): """Generates a Doctype token :arg name: :arg publicId: :arg systemId: :returns: the Doctype token """ return {"type": "Doctype", "name": name, "publicId": publicId, ...
[ "def", "doctype", "(", "self", ",", "name", ",", "publicId", "=", "None", ",", "systemId", "=", "None", ")", ":", "return", "{", "\"type\"", ":", "\"Doctype\"", ",", "\"name\"", ":", "name", ",", "\"publicId\"", ":", "publicId", ",", "\"systemId\"", ":",...
[ 147, 4 ]
[ 162, 37 ]
python
en
['en', 'en', 'en']
True
TreeWalker.entity
(self, name)
Generates an Entity token :arg name: the entity name :returns: an Entity token
Generates an Entity token
def entity(self, name): """Generates an Entity token :arg name: the entity name :returns: an Entity token """ return {"type": "Entity", "name": name}
[ "def", "entity", "(", "self", ",", "name", ")", ":", "return", "{", "\"type\"", ":", "\"Entity\"", ",", "\"name\"", ":", "name", "}" ]
[ 164, 4 ]
[ 172, 47 ]
python
en
['en', 'en', 'nl']
True
TreeWalker.unknown
(self, nodeType)
Handles unknown node types
Handles unknown node types
def unknown(self, nodeType): """Handles unknown node types""" return self.error("Unknown node type: " + nodeType)
[ "def", "unknown", "(", "self", ",", "nodeType", ")", ":", "return", "self", ".", "error", "(", "\"Unknown node type: \"", "+", "nodeType", ")" ]
[ 174, 4 ]
[ 176, 59 ]
python
en
['en', 'de', 'en']
True
generate_test_data
(service_providers=False, endpoint='localhost')
Builds a set of test_data data as returned by Keystone V2.
Builds a set of test_data data as returned by Keystone V2.
def generate_test_data(service_providers=False, endpoint='localhost'): '''Builds a set of test_data data as returned by Keystone V2.''' test_data = TestDataContainer() keystone_service = { 'type': 'identity', 'id': uuid.uuid4().hex, 'endpoints': [ { 'url'...
[ "def", "generate_test_data", "(", "service_providers", "=", "False", ",", "endpoint", "=", "'localhost'", ")", ":", "test_data", "=", "TestDataContainer", "(", ")", "keystone_service", "=", "{", "'type'", ":", "'identity'", ",", "'id'", ":", "uuid", ".", "uuid...
[ 56, 0 ]
[ 353, 20 ]
python
en
['en', 'en', 'en']
True
CacheControlAdapter.send
(self, request, cacheable_methods=None, **kw)
Send a request. Use the request information to see if it exists in the cache and cache the response if we need to and can.
Send a request. Use the request information to see if it exists in the cache and cache the response if we need to and can.
def send(self, request, cacheable_methods=None, **kw): """ Send a request. Use the request information to see if it exists in the cache and cache the response if we need to and can. """ cacheable = cacheable_methods or self.cacheable_methods if request.method in cacheable...
[ "def", "send", "(", "self", ",", "request", ",", "cacheable_methods", "=", "None", ",", "*", "*", "kw", ")", ":", "cacheable", "=", "cacheable_methods", "or", "self", ".", "cacheable_methods", "if", "request", ".", "method", "in", "cacheable", ":", "try", ...
[ 35, 4 ]
[ 54, 19 ]
python
en
['en', 'error', 'th']
False
CacheControlAdapter.build_response
( self, request, response, from_cache=False, cacheable_methods=None )
Build a response by making a request or using the cache. This will end up calling send and returning a potentially cached response
Build a response by making a request or using the cache.
def build_response( self, request, response, from_cache=False, cacheable_methods=None ): """ Build a response by making a request or using the cache. This will end up calling send and returning a potentially cached response """ cacheable = cacheable_methods o...
[ "def", "build_response", "(", "self", ",", "request", ",", "response", ",", "from_cache", "=", "False", ",", "cacheable_methods", "=", "None", ")", ":", "cacheable", "=", "cacheable_methods", "or", "self", ".", "cacheable_methods", "if", "not", "from_cache", "...
[ 56, 4 ]
[ 128, 19 ]
python
en
['en', 'error', 'th']
False
_program_and_is_drum_from_sequence
(sequence, instrument=None)
Get MIDI program and is_drum from sequence and (optional) instrument. Args: sequence: The NoteSequence from which MIDI program and is_drum will be extracted. instrument: The instrument in `sequence` from which MIDI program and is_drum will be extracted, or None to consider all instruments. ...
Get MIDI program and is_drum from sequence and (optional) instrument.
def _program_and_is_drum_from_sequence(sequence, instrument=None): """Get MIDI program and is_drum from sequence and (optional) instrument. Args: sequence: The NoteSequence from which MIDI program and is_drum will be extracted. instrument: The instrument in `sequence` from which MIDI program and ...
[ "def", "_program_and_is_drum_from_sequence", "(", "sequence", ",", "instrument", "=", "None", ")", ":", "notes", "=", "[", "note", "for", "note", "in", "sequence", ".", "notes", "if", "instrument", "is", "None", "or", "note", ".", "instrument", "==", "instru...
[ 96, 0 ]
[ 124, 25 ]
python
en
['en', 'en', 'en']
True
BasePerformance.__init__
(self, start_step, num_velocity_bins, max_shift_steps, program=None, is_drum=None)
Construct a BasePerformance. Args: start_step: The offset of this sequence relative to the beginning of the source sequence. num_velocity_bins: Number of velocity bins to use. max_shift_steps: Maximum number of steps for a single time-shift event. program: MIDI program used for th...
Construct a BasePerformance.
def __init__(self, start_step, num_velocity_bins, max_shift_steps, program=None, is_drum=None): """Construct a BasePerformance. Args: start_step: The offset of this sequence relative to the beginning of the source sequence. num_velocity_bins: Number of velocity bins to use....
[ "def", "__init__", "(", "self", ",", "start_step", ",", "num_velocity_bins", ",", "max_shift_steps", ",", "program", "=", "None", ",", "is_drum", "=", "None", ")", ":", "if", "num_velocity_bins", ">", "MAX_MIDI_VELOCITY", "-", "MIN_MIDI_VELOCITY", "+", "1", ":...
[ 134, 2 ]
[ 159, 27 ]
python
en
['en', 'en', 'en']
True
BasePerformance._append_steps
(self, num_steps)
Adds steps to the end of the sequence.
Adds steps to the end of the sequence.
def _append_steps(self, num_steps): """Adds steps to the end of the sequence.""" if (self._events and self._events[-1].event_type == PerformanceEvent.TIME_SHIFT and self._events[-1].event_value < self._max_shift_steps): # Last event is already non-maximal time shift. Increase its duration....
[ "def", "_append_steps", "(", "self", ",", "num_steps", ")", ":", "if", "(", "self", ".", "_events", "and", "self", ".", "_events", "[", "-", "1", "]", ".", "event_type", "==", "PerformanceEvent", ".", "TIME_SHIFT", "and", "self", ".", "_events", "[", "...
[ 177, 2 ]
[ 199, 50 ]
python
en
['en', 'en', 'en']
True
BasePerformance._trim_steps
(self, num_steps)
Trims a given number of steps from the end of the sequence.
Trims a given number of steps from the end of the sequence.
def _trim_steps(self, num_steps): """Trims a given number of steps from the end of the sequence.""" steps_trimmed = 0 while self._events and steps_trimmed < num_steps: if self._events[-1].event_type == PerformanceEvent.TIME_SHIFT: if steps_trimmed + self._events[-1].event_value > num_steps: ...
[ "def", "_trim_steps", "(", "self", ",", "num_steps", ")", ":", "steps_trimmed", "=", "0", "while", "self", ".", "_events", "and", "steps_trimmed", "<", "num_steps", ":", "if", "self", ".", "_events", "[", "-", "1", "]", ".", "event_type", "==", "Performa...
[ 201, 2 ]
[ 216, 26 ]
python
en
['en', 'en', 'en']
True
BasePerformance.set_length
(self, steps, from_left=False)
Sets the length of the sequence to the specified number of steps. If the event sequence is not long enough, pads with time shifts to make the sequence the specified length. If it is too long, it will be truncated to the requested length. Args: steps: How many quantized steps long the event seque...
Sets the length of the sequence to the specified number of steps.
def set_length(self, steps, from_left=False): """Sets the length of the sequence to the specified number of steps. If the event sequence is not long enough, pads with time shifts to make the sequence the specified length. If it is too long, it will be truncated to the requested length. Args: ...
[ "def", "set_length", "(", "self", ",", "steps", ",", "from_left", "=", "False", ")", ":", "if", "from_left", ":", "raise", "NotImplementedError", "(", "'from_left is not supported'", ")", "if", "self", ".", "num_steps", "<", "steps", ":", "self", ".", "_appe...
[ 218, 2 ]
[ 237, 34 ]
python
en
['en', 'en', 'en']
True
BasePerformance.append
(self, event)
Appends the event to the end of the sequence. Args: event: The performance event to append to the end. Raises: ValueError: If `event` is not a valid performance event.
Appends the event to the end of the sequence.
def append(self, event): """Appends the event to the end of the sequence. Args: event: The performance event to append to the end. Raises: ValueError: If `event` is not a valid performance event. """ if not isinstance(event, PerformanceEvent): raise ValueError('Invalid performanc...
[ "def", "append", "(", "self", ",", "event", ")", ":", "if", "not", "isinstance", "(", "event", ",", "PerformanceEvent", ")", ":", "raise", "ValueError", "(", "'Invalid performance event: %s'", "%", "event", ")", "self", ".", "_events", ".", "append", "(", ...
[ 239, 2 ]
[ 250, 30 ]
python
en
['en', 'en', 'en']
True
BasePerformance.truncate
(self, num_events)
Truncates this Performance to the specified number of events. Args: num_events: The number of events to which this performance will be truncated.
Truncates this Performance to the specified number of events.
def truncate(self, num_events): """Truncates this Performance to the specified number of events. Args: num_events: The number of events to which this performance will be truncated. """ self._events = self._events[:num_events]
[ "def", "truncate", "(", "self", ",", "num_events", ")", ":", "self", ".", "_events", "=", "self", ".", "_events", "[", ":", "num_events", "]" ]
[ 252, 2 ]
[ 259, 44 ]
python
en
['en', 'en', 'en']
True
BasePerformance.__len__
(self)
How many events are in this sequence. Returns: Number of events as an integer.
How many events are in this sequence.
def __len__(self): """How many events are in this sequence. Returns: Number of events as an integer. """ return len(self._events)
[ "def", "__len__", "(", "self", ")", ":", "return", "len", "(", "self", ".", "_events", ")" ]
[ 261, 2 ]
[ 267, 28 ]
python
en
['en', 'en', 'en']
True
BasePerformance.__getitem__
(self, i)
Returns the event at the given index.
Returns the event at the given index.
def __getitem__(self, i): """Returns the event at the given index.""" return self._events[i]
[ "def", "__getitem__", "(", "self", ",", "i", ")", ":", "return", "self", ".", "_events", "[", "i", "]" ]
[ 269, 2 ]
[ 271, 26 ]
python
en
['en', 'en', 'en']
True
BasePerformance.__iter__
(self)
Return an iterator over the events in this sequence.
Return an iterator over the events in this sequence.
def __iter__(self): """Return an iterator over the events in this sequence.""" return iter(self._events)
[ "def", "__iter__", "(", "self", ")", ":", "return", "iter", "(", "self", ".", "_events", ")" ]
[ 273, 2 ]
[ 275, 29 ]
python
en
['en', 'en', 'en']
True
BasePerformance.num_steps
(self)
Returns how many steps long this sequence is. Returns: Length of the sequence in quantized steps.
Returns how many steps long this sequence is.
def num_steps(self): """Returns how many steps long this sequence is. Returns: Length of the sequence in quantized steps. """ steps = 0 for event in self: if event.event_type == PerformanceEvent.TIME_SHIFT: steps += event.event_value return steps
[ "def", "num_steps", "(", "self", ")", ":", "steps", "=", "0", "for", "event", "in", "self", ":", "if", "event", ".", "event_type", "==", "PerformanceEvent", ".", "TIME_SHIFT", ":", "steps", "+=", "event", ".", "event_value", "return", "steps" ]
[ 297, 2 ]
[ 307, 16 ]
python
en
['en', 'en', 'en']
True
BasePerformance.steps
(self)
Return a Python list of the time step at each event in this sequence.
Return a Python list of the time step at each event in this sequence.
def steps(self): """Return a Python list of the time step at each event in this sequence.""" step = self.start_step result = [] for event in self: result.append(step) if event.event_type == PerformanceEvent.TIME_SHIFT: step += event.event_value return result
[ "def", "steps", "(", "self", ")", ":", "step", "=", "self", ".", "start_step", "result", "=", "[", "]", "for", "event", "in", "self", ":", "result", ".", "append", "(", "step", ")", "if", "event", ".", "event_type", "==", "PerformanceEvent", ".", "TI...
[ 310, 2 ]
[ 318, 17 ]
python
en
['en', 'en', 'en']
True
BasePerformance._from_quantized_sequence
(quantized_sequence, start_step, num_velocity_bins, max_shift_steps, instrument=None)
Extract a list of events from the given quantized NoteSequence object. Within a step, new pitches are started with NOTE_ON and existing pitches are ended with NOTE_OFF. TIME_SHIFT shifts the current step forward in time. VELOCITY changes the current velocity value that will be applied to all NOTE_ON ev...
Extract a list of events from the given quantized NoteSequence object.
def _from_quantized_sequence(quantized_sequence, start_step, num_velocity_bins, max_shift_steps, instrument=None): """Extract a list of events from the given quantized NoteSequence object. Within a step, new pitches are started with NOTE_ON and exis...
[ "def", "_from_quantized_sequence", "(", "quantized_sequence", ",", "start_step", ",", "num_velocity_bins", ",", "max_shift_steps", ",", "instrument", "=", "None", ")", ":", "notes", "=", "[", "note", "for", "note", "in", "quantized_sequence", ".", "notes", "if", ...
[ 321, 2 ]
[ 391, 29 ]
python
en
['en', 'en', 'en']
True
BasePerformance.to_sequence
(self, velocity, instrument, program, max_note_duration=None)
Converts the Performance to NoteSequence proto. Args: velocity: MIDI velocity to give each note. Between 1 and 127 (inclusive). If the performance contains velocity events, those will be used instead. instrument: MIDI instrument to give each note. program: MIDI program to give...
Converts the Performance to NoteSequence proto.
def to_sequence(self, velocity, instrument, program, max_note_duration=None): """Converts the Performance to NoteSequence proto. Args: velocity: MIDI velocity to give each note. Between 1 and 127 (inclusive). If the performance contains velocity events, those will be used instead. ...
[ "def", "to_sequence", "(", "self", ",", "velocity", ",", "instrument", ",", "program", ",", "max_note_duration", "=", "None", ")", ":", "pass" ]
[ 394, 2 ]
[ 411, 8 ]
python
en
['en', 'en', 'en']
True
Performance.__init__
(self, quantized_sequence=None, steps_per_second=None, start_step=0, num_velocity_bins=0, max_shift_steps=DEFAULT_MAX_SHIFT_STEPS, instrument=None, program=None, is_drum=None)
Construct a Performance. Either quantized_sequence or steps_per_second should be supplied. Args: quantized_sequence: A quantized NoteSequence proto. steps_per_second: Number of quantized time steps per second, if using absolute quantization. start_step: The offset of this sequence ...
Construct a Performance.
def __init__(self, quantized_sequence=None, steps_per_second=None, start_step=0, num_velocity_bins=0, max_shift_steps=DEFAULT_MAX_SHIFT_STEPS, instrument=None, program=None, is_drum=None): """Construct a Performance. Either quantized_sequence or steps_per_second sho...
[ "def", "__init__", "(", "self", ",", "quantized_sequence", "=", "None", ",", "steps_per_second", "=", "None", ",", "start_step", "=", "0", ",", "num_velocity_bins", "=", "0", ",", "max_shift_steps", "=", "DEFAULT_MAX_SHIFT_STEPS", ",", "instrument", "=", "None",...
[ 499, 2 ]
[ 551, 24 ]
python
en
['en', 'en', 'en']
True
Performance.to_sequence
(self, velocity=100, instrument=0, program=None, max_note_duration=None)
Converts the Performance to NoteSequence proto. Args: velocity: MIDI velocity to give each note. Between 1 and 127 (inclusive). If the performance contains velocity events, those will be used instead. instrument: MIDI instrument to give each note. program: MIDI program to give...
Converts the Performance to NoteSequence proto.
def to_sequence(self, velocity=100, instrument=0, program=None, max_note_duration=None): """Converts the Performance to NoteSequence proto. Args: velocity: MIDI velocity to give each note. Between 1 and 127 (inclusive). If ...
[ "def", "to_sequence", "(", "self", ",", "velocity", "=", "100", ",", "instrument", "=", "0", ",", "program", "=", "None", ",", "max_note_duration", "=", "None", ")", ":", "seconds_per_step", "=", "1.0", "/", "self", ".", "steps_per_second", "return", "self...
[ 557, 2 ]
[ 584, 44 ]
python
en
['en', 'en', 'en']
True
MetricPerformance.__init__
(self, quantized_sequence=None, steps_per_quarter=None, start_step=0, num_velocity_bins=0, max_shift_quarters=DEFAULT_MAX_SHIFT_QUARTERS, instrument=None, program=None, is_drum=None)
Construct a MetricPerformance. Either quantized_sequence or steps_per_quarter should be supplied. Args: quantized_sequence: A quantized NoteSequence proto. steps_per_quarter: Number of quantized time steps per quarter note, if using metric quantization. start_step: The offset of th...
Construct a MetricPerformance.
def __init__(self, quantized_sequence=None, steps_per_quarter=None, start_step=0, num_velocity_bins=0, max_shift_quarters=DEFAULT_MAX_SHIFT_QUARTERS, instrument=None, program=None, is_drum=None): """Construct a MetricPerformance. Either quantized_sequence or steps_p...
[ "def", "__init__", "(", "self", ",", "quantized_sequence", "=", "None", ",", "steps_per_quarter", "=", "None", ",", "start_step", "=", "0", ",", "num_velocity_bins", "=", "0", ",", "max_shift_quarters", "=", "DEFAULT_MAX_SHIFT_QUARTERS", ",", "instrument", "=", ...
[ 590, 2 ]
[ 644, 24 ]
python
en
['en', 'en', 'it']
True
MetricPerformance.to_sequence
(self, velocity=100, instrument=0, program=None, max_note_duration=None, qpm=120.0)
Converts the Performance to NoteSequence proto. Args: velocity: MIDI velocity to give each note. Between 1 and 127 (inclusive). If the performance contains velocity events, those will be used instead. instrument: MIDI instrument to give each note. program: MIDI program to give...
Converts the Performance to NoteSequence proto.
def to_sequence(self, velocity=100, instrument=0, program=None, max_note_duration=None, qpm=120.0): """Converts the Performance to NoteSequence proto. Args: velocity: MIDI velocity to give each note. Between 1 and 1...
[ "def", "to_sequence", "(", "self", ",", "velocity", "=", "100", ",", "instrument", "=", "0", ",", "program", "=", "None", ",", "max_note_duration", "=", "None", ",", "qpm", "=", "120.0", ")", ":", "seconds_per_step", "=", "60.0", "/", "(", "self", ".",...
[ 650, 2 ]
[ 681, 19 ]
python
en
['en', 'en', 'en']
True
NotePerformance.__init__
(self, quantized_sequence, num_velocity_bins, instrument=0, start_step=0, max_shift_steps=1000, max_duration_steps=1000)
Construct a NotePerformance. Args: quantized_sequence: A quantized NoteSequence proto. num_velocity_bins: Number of velocity bins to use. instrument: If not None, extract only the specified instrument from `quantized_sequence`. Otherwise, extract all instruments. start_step: The o...
Construct a NotePerformance.
def __init__(self, quantized_sequence, num_velocity_bins, instrument=0, start_step=0, max_shift_steps=1000, max_duration_steps=1000): """Construct a NotePerformance. Args: quantized_sequence: A quantized NoteSequence proto. num_velocity_bins: Number of velocity bins to use. ins...
[ "def", "__init__", "(", "self", ",", "quantized_sequence", ",", "num_velocity_bins", ",", "instrument", "=", "0", ",", "start_step", "=", "0", ",", "max_shift_steps", "=", "1000", ",", "max_duration_steps", "=", "1000", ")", ":", "program", ",", "is_drum", "...
[ 704, 2 ]
[ 738, 39 ]
python
en
['en', 'en', 'en']
True
NotePerformance.append
(self, event)
Appends the event to the end of the sequence. Args: event: The performance event tuple to append to the end. Raises: ValueError: If `event` is not a valid performance event tuple.
Appends the event to the end of the sequence.
def append(self, event): """Appends the event to the end of the sequence. Args: event: The performance event tuple to append to the end. Raises: ValueError: If `event` is not a valid performance event tuple. """ if not isinstance(event, tuple): raise ValueError('Invalid performan...
[ "def", "append", "(", "self", ",", "event", ")", ":", "if", "not", "isinstance", "(", "event", ",", "tuple", ")", ":", "raise", "ValueError", "(", "'Invalid performance event tuple: %s'", "%", "event", ")", "self", ".", "_events", ".", "append", "(", "even...
[ 750, 2 ]
[ 761, 30 ]
python
en
['en', 'en', 'en']
True
NotePerformance.num_steps
(self)
Returns how many steps long this sequence is. Returns: Length of the sequence in quantized steps.
Returns how many steps long this sequence is.
def num_steps(self): """Returns how many steps long this sequence is. Returns: Length of the sequence in quantized steps. """ steps = 0 for event in self._events: steps += event[0].event_value if self._events: steps += self._events[-1][3].event_value return steps
[ "def", "num_steps", "(", "self", ")", ":", "steps", "=", "0", "for", "event", "in", "self", ".", "_events", ":", "steps", "+=", "event", "[", "0", "]", ".", "event_value", "if", "self", ".", "_events", ":", "steps", "+=", "self", ".", "_events", "[...
[ 772, 2 ]
[ 783, 16 ]
python
en
['en', 'en', 'en']
True
NotePerformance.steps
(self)
Return a Python list of the time step at each event in this sequence.
Return a Python list of the time step at each event in this sequence.
def steps(self): """Return a Python list of the time step at each event in this sequence.""" step = self.start_step result = [] for event in self: step += event[0].event_value result.append(step) return result
[ "def", "steps", "(", "self", ")", ":", "step", "=", "self", ".", "start_step", "result", "=", "[", "]", "for", "event", "in", "self", ":", "step", "+=", "event", "[", "0", "]", ".", "event_value", "result", ".", "append", "(", "step", ")", "return"...
[ 786, 2 ]
[ 793, 17 ]
python
en
['en', 'en', 'en']
True
NotePerformance._from_quantized_sequence
(self, quantized_sequence, instrument)
Extract a list of events from the given quantized NoteSequence object. Within a step, new pitches are started with NOTE_ON and existing pitches are ended with NOTE_OFF. TIME_SHIFT shifts the current step forward in time. VELOCITY changes the current velocity value that will be applied to all NOTE_ON ev...
Extract a list of events from the given quantized NoteSequence object.
def _from_quantized_sequence(self, quantized_sequence, instrument): """Extract a list of events from the given quantized NoteSequence object. Within a step, new pitches are started with NOTE_ON and existing pitches are ended with NOTE_OFF. TIME_SHIFT shifts the current step forward in time. VELOCITY ch...
[ "def", "_from_quantized_sequence", "(", "self", ",", "quantized_sequence", ",", "instrument", ")", ":", "notes", "=", "[", "note", "for", "note", "in", "quantized_sequence", ".", "notes", "if", "note", ".", "quantized_start_step", ">=", "self", ".", "start_step"...
[ 795, 2 ]
[ 861, 29 ]
python
en
['en', 'en', 'en']
True
NotePerformance.to_sequence
(self, instrument=0, program=None, max_note_duration=None)
Converts the Performance to NoteSequence proto. Args: instrument: MIDI instrument to give each note. program: MIDI program to give each note, or None to use the program associated with the Performance (or the default program if none exists). max_note_duration: Not used in this...
Converts the Performance to NoteSequence proto.
def to_sequence(self, instrument=0, program=None, max_note_duration=None): """Converts the Performance to NoteSequence proto. Args: instrument: MIDI instrument to give each note. program: MIDI program to give each note, or None to use the program associated with the Performance (or the de...
[ "def", "to_sequence", "(", "self", ",", "instrument", "=", "0", ",", "program", "=", "None", ",", "max_note_duration", "=", "None", ")", ":", "seconds_per_step", "=", "1.0", "/", "self", ".", "steps_per_second", "sequence_start_time", "=", "self", ".", "star...
[ 863, 2 ]
[ 906, 19 ]
python
en
['en', 'en', 'en']
True
horizon
(request)
The main Horizon context processor. Required for Horizon to function. It adds the Horizon config to the context as well as setting the names ``True`` and ``False`` in the context to their boolean equivalents for convenience. .. warning:: Don't put API calls in context processors; they will be...
The main Horizon context processor. Required for Horizon to function.
def horizon(request): """The main Horizon context processor. Required for Horizon to function. It adds the Horizon config to the context as well as setting the names ``True`` and ``False`` in the context to their boolean equivalents for convenience. .. warning:: Don't put API calls in con...
[ "def", "horizon", "(", "request", ")", ":", "context", "=", "{", "\"HORIZON_CONFIG\"", ":", "conf", ".", "HORIZON_CONFIG", ",", "\"True\"", ":", "True", ",", "\"False\"", ":", "False", "}", "return", "context" ]
[ 24, 0 ]
[ 41, 18 ]
python
en
['en', 'en', 'en']
True
ServiceDefinition.__init__
(self, wsdl, service)
@param wsdl: A wsdl object @type wsdl: L{Definitions} @param service: A service B{name}. @type service: str
def __init__(self, wsdl, service): """ @param wsdl: A wsdl object @type wsdl: L{Definitions} @param service: A service B{name}. @type service: str """ self.wsdl = wsdl self.service = service self.ports = [] self.params = [] self.typ...
[ "def", "__init__", "(", "self", ",", "wsdl", ",", "service", ")", ":", "self", ".", "wsdl", "=", "wsdl", "self", ".", "service", "=", "service", "self", ".", "ports", "=", "[", "]", "self", ".", "params", "=", "[", "]", "self", ".", "types", "=",...
[ 43, 4 ]
[ 60, 27 ]
python
en
['en', 'error', 'th']
False
ServiceDefinition.pushprefixes
(self)
Add our prefixes to the wsdl so that when users invoke methods and reference the prefixes, the will resolve properly.
Add our prefixes to the wsdl so that when users invoke methods and reference the prefixes, the will resolve properly.
def pushprefixes(self): """ Add our prefixes to the wsdl so that when users invoke methods and reference the prefixes, the will resolve properly. """ for ns in self.prefixes: self.wsdl.root.addPrefix(ns[0], ns[1])
[ "def", "pushprefixes", "(", "self", ")", ":", "for", "ns", "in", "self", ".", "prefixes", ":", "self", ".", "wsdl", ".", "root", ".", "addPrefix", "(", "ns", "[", "0", "]", ",", "ns", "[", "1", "]", ")" ]
[ 62, 4 ]
[ 68, 50 ]
python
en
['en', 'error', 'th']
False
ServiceDefinition.addports
(self)
Look through the list of service ports and construct a list of tuples where each tuple is used to describe a port and it's list of methods as: (port, [method]). Each method is tuple: (name, [pdef,..] where each pdef is a tuple: (param-name, type).
Look through the list of service ports and construct a list of tuples where each tuple is used to describe a port and it's list of methods as: (port, [method]). Each method is tuple: (name, [pdef,..] where each pdef is a tuple: (param-name, type).
def addports(self): """ Look through the list of service ports and construct a list of tuples where each tuple is used to describe a port and it's list of methods as: (port, [method]). Each method is tuple: (name, [pdef,..] where each pdef is a tuple: (param-name, type). ...
[ "def", "addports", "(", "self", ")", ":", "timer", "=", "metrics", ".", "Timer", "(", ")", "timer", ".", "start", "(", ")", "for", "port", "in", "self", ".", "service", ".", "ports", ":", "p", "=", "self", ".", "findport", "(", "port", ")", "for"...
[ 70, 4 ]
[ 88, 20 ]
python
en
['en', 'error', 'th']
False