partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
zfill
zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated.
third_party/stdlib/string.py
def zfill(x, width): """zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated. """ if not isinstance(x, basestring): x = repr(x) return x.zfill(width)
def zfill(x, width): """zfill(x, width) -> string Pad a numeric string x with zeros on the left, to fill a field of the specified width. The string x is never truncated. """ if not isinstance(x, basestring): x = repr(x) return x.zfill(width)
[ "zfill", "(", "x", "width", ")", "-", ">", "string" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/string.py#L473-L482
[ "def", "zfill", "(", "x", ",", "width", ")", ":", "if", "not", "isinstance", "(", "x", ",", "basestring", ")", ":", "x", "=", "repr", "(", "x", ")", "return", "x", ".", "zfill", "(", "width", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
translate
translate(s,table [,deletions]) -> string Return a copy of the string s, where all characters occurring in the optional argument deletions are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. The deletions argument is...
third_party/stdlib/string.py
def translate(s, table, deletions=""): """translate(s,table [,deletions]) -> string Return a copy of the string s, where all characters occurring in the optional argument deletions are removed, and the remaining characters have been mapped through the given translation table, which must be a string...
def translate(s, table, deletions=""): """translate(s,table [,deletions]) -> string Return a copy of the string s, where all characters occurring in the optional argument deletions are removed, and the remaining characters have been mapped through the given translation table, which must be a string...
[ "translate", "(", "s", "table", "[", "deletions", "]", ")", "-", ">", "string" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/string.py#L497-L513
[ "def", "translate", "(", "s", ",", "table", ",", "deletions", "=", "\"\"", ")", ":", "if", "deletions", "or", "table", "is", "None", ":", "return", "s", ".", "translate", "(", "table", ",", "deletions", ")", "else", ":", "# Add s[:0] so that if s is Unicod...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
replace
replace (str, old, new[, maxreplace]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxreplace is given, only the first maxreplace occurrences are replaced.
third_party/stdlib/string.py
def replace(s, old, new, maxreplace=-1): """replace (str, old, new[, maxreplace]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxreplace is given, only the first maxreplace occurrences are replaced. """ return s.replace(...
def replace(s, old, new, maxreplace=-1): """replace (str, old, new[, maxreplace]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxreplace is given, only the first maxreplace occurrences are replaced. """ return s.replace(...
[ "replace", "(", "str", "old", "new", "[", "maxreplace", "]", ")", "-", ">", "string" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/string.py#L526-L534
[ "def", "replace", "(", "s", ",", "old", ",", "new", ",", "maxreplace", "=", "-", "1", ")", ":", "return", "s", ".", "replace", "(", "old", ",", "new", ",", "maxreplace", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
get_close_matches
Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of strings). Optional arg n (default 3) is the maximum number of cl...
third_party/stdlib/difflib.py
def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of s...
def get_close_matches(word, possibilities, n=3, cutoff=0.6): """Use SequenceMatcher to return list of the best "good enough" matches. word is a sequence for which close matches are desired (typically a string). possibilities is a list of sequences against which to match word (typically a list of s...
[ "Use", "SequenceMatcher", "to", "return", "list", "of", "the", "best", "good", "enough", "matches", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L764-L810
[ "def", "get_close_matches", "(", "word", ",", "possibilities", ",", "n", "=", "3", ",", "cutoff", "=", "0.6", ")", ":", "if", "not", "n", ">", "0", ":", "raise", "ValueError", "(", "\"n must be > 0: %r\"", "%", "(", "n", ",", ")", ")", "if", "not", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_count_leading
Return number of `ch` characters at the start of `line`. Example: >>> _count_leading(' abc', ' ') 3
third_party/stdlib/difflib.py
def _count_leading(line, ch): """ Return number of `ch` characters at the start of `line`. Example: >>> _count_leading(' abc', ' ') 3 """ i, n = 0, len(line) while i < n and line[i] == ch: i += 1 return i
def _count_leading(line, ch): """ Return number of `ch` characters at the start of `line`. Example: >>> _count_leading(' abc', ' ') 3 """ i, n = 0, len(line) while i < n and line[i] == ch: i += 1 return i
[ "Return", "number", "of", "ch", "characters", "at", "the", "start", "of", "line", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L812-L825
[ "def", "_count_leading", "(", "line", ",", "ch", ")", ":", "i", ",", "n", "=", "0", ",", "len", "(", "line", ")", "while", "i", "<", "n", "and", "line", "[", "i", "]", "==", "ch", ":", "i", "+=", "1", "return", "i" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_format_range_unified
Convert range to the "ed" format
third_party/stdlib/difflib.py
def _format_range_unified(start, stop): 'Convert range to the "ed" format' # Per the diff spec at http://www.unix.org/single_unix_specification/ beginning = start + 1 # lines start numbering with one length = stop - start if length == 1: # return '{}'.format(beginning) return '%s...
def _format_range_unified(start, stop): 'Convert range to the "ed" format' # Per the diff spec at http://www.unix.org/single_unix_specification/ beginning = start + 1 # lines start numbering with one length = stop - start if length == 1: # return '{}'.format(beginning) return '%s...
[ "Convert", "range", "to", "the", "ed", "format" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1208-L1218
[ "def", "_format_range_unified", "(", "start", ",", "stop", ")", ":", "# Per the diff spec at http://www.unix.org/single_unix_specification/", "beginning", "=", "start", "+", "1", "# lines start numbering with one", "length", "=", "stop", "-", "start", "if", "length", "=="...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
unified_diff
r""" Compare two sequences of lines; generate the delta as a unified diff. Unified diffs are a compact way of showing line changes and a few lines of context. The number of context lines is set by 'n' which defaults to three. By default, the diff control lines (those with ---, +++, or @@) are ...
third_party/stdlib/difflib.py
def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'): r""" Compare two sequences of lines; generate the delta as a unified diff. Unified diffs are a compact way of showing line changes and a few lines of context. The number of context line...
def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'): r""" Compare two sequences of lines; generate the delta as a unified diff. Unified diffs are a compact way of showing line changes and a few lines of context. The number of context line...
[ "r", "Compare", "two", "sequences", "of", "lines", ";", "generate", "the", "delta", "as", "a", "unified", "diff", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1220-L1290
[ "def", "unified_diff", "(", "a", ",", "b", ",", "fromfile", "=", "''", ",", "tofile", "=", "''", ",", "fromfiledate", "=", "''", ",", "tofiledate", "=", "''", ",", "n", "=", "3", ",", "lineterm", "=", "'\\n'", ")", ":", "started", "=", "False", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_format_range_context
Convert range to the "ed" format
third_party/stdlib/difflib.py
def _format_range_context(start, stop): 'Convert range to the "ed" format' # Per the diff spec at http://www.unix.org/single_unix_specification/ beginning = start + 1 # lines start numbering with one length = stop - start if not length: beginning -= 1 # empty ranges begin at line ...
def _format_range_context(start, stop): 'Convert range to the "ed" format' # Per the diff spec at http://www.unix.org/single_unix_specification/ beginning = start + 1 # lines start numbering with one length = stop - start if not length: beginning -= 1 # empty ranges begin at line ...
[ "Convert", "range", "to", "the", "ed", "format" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1297-L1308
[ "def", "_format_range_context", "(", "start", ",", "stop", ")", ":", "# Per the diff spec at http://www.unix.org/single_unix_specification/", "beginning", "=", "start", "+", "1", "# lines start numbering with one", "length", "=", "stop", "-", "start", "if", "not", "length...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
context_diff
r""" Compare two sequences of lines; generate the delta as a context diff. Context diffs are a compact way of showing line changes and a few lines of context. The number of context lines is set by 'n' which defaults to three. By default, the diff control lines (those with *** or ---) are crea...
third_party/stdlib/difflib.py
def context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'): r""" Compare two sequences of lines; generate the delta as a context diff. Context diffs are a compact way of showing line changes and a few lines of context. The number of context line...
def context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'): r""" Compare two sequences of lines; generate the delta as a context diff. Context diffs are a compact way of showing line changes and a few lines of context. The number of context line...
[ "r", "Compare", "two", "sequences", "of", "lines", ";", "generate", "the", "delta", "as", "a", "context", "diff", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1311-L1389
[ "def", "context_diff", "(", "a", ",", "b", ",", "fromfile", "=", "''", ",", "tofile", "=", "''", ",", "fromfiledate", "=", "''", ",", "tofiledate", "=", "''", ",", "n", "=", "3", ",", "lineterm", "=", "'\\n'", ")", ":", "prefix", "=", "dict", "("...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
ndiff
r""" Compare `a` and `b` (lists of strings); return a `Differ`-style delta. Optional keyword parameters `linejunk` and `charjunk` are for filter functions (or None): - linejunk: A function that should accept a single string argument, and return true iff the string is junk. The default is None, ...
third_party/stdlib/difflib.py
def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK): r""" Compare `a` and `b` (lists of strings); return a `Differ`-style delta. Optional keyword parameters `linejunk` and `charjunk` are for filter functions (or None): - linejunk: A function that should accept a single string argument, and ...
def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK): r""" Compare `a` and `b` (lists of strings); return a `Differ`-style delta. Optional keyword parameters `linejunk` and `charjunk` are for filter functions (or None): - linejunk: A function that should accept a single string argument, and ...
[ "r", "Compare", "a", "and", "b", "(", "lists", "of", "strings", ")", ";", "return", "a", "Differ", "-", "style", "delta", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1391-L1425
[ "def", "ndiff", "(", "a", ",", "b", ",", "linejunk", "=", "None", ",", "charjunk", "=", "IS_CHARACTER_JUNK", ")", ":", "return", "Differ", "(", "linejunk", ",", "charjunk", ")", ".", "compare", "(", "a", ",", "b", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_mdiff
r"""Returns generator yielding marked up from/to side by side differences. Arguments: fromlines -- list of text lines to compared to tolines tolines -- list of text lines to be compared to fromlines context -- number of context lines to display on each side of difference, if None, all fr...
third_party/stdlib/difflib.py
def _mdiff(fromlines, tolines, context=None, linejunk=None, charjunk=IS_CHARACTER_JUNK): r"""Returns generator yielding marked up from/to side by side differences. Arguments: fromlines -- list of text lines to compared to tolines tolines -- list of text lines to be compared to fromlines ...
def _mdiff(fromlines, tolines, context=None, linejunk=None, charjunk=IS_CHARACTER_JUNK): r"""Returns generator yielding marked up from/to side by side differences. Arguments: fromlines -- list of text lines to compared to tolines tolines -- list of text lines to be compared to fromlines ...
[ "r", "Returns", "generator", "yielding", "marked", "up", "from", "/", "to", "side", "by", "side", "differences", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1427-L1688
[ "def", "_mdiff", "(", "fromlines", ",", "tolines", ",", "context", "=", "None", ",", "linejunk", "=", "None", ",", "charjunk", "=", "IS_CHARACTER_JUNK", ")", ":", "import", "re", "# regular expression for finding intraline change indices", "change_re", "=", "re", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
restore
r""" Generate one of the two sequences that generated a delta. Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract lines originating from file 1 or 2 (parameter `which`), stripping off line prefixes. Examples: >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1), ... ...
third_party/stdlib/difflib.py
def restore(delta, which): r""" Generate one of the two sequences that generated a delta. Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract lines originating from file 1 or 2 (parameter `which`), stripping off line prefixes. Examples: >>> diff = ndiff('one\ntwo\nthree\n...
def restore(delta, which): r""" Generate one of the two sequences that generated a delta. Given a `delta` produced by `Differ.compare()` or `ndiff()`, extract lines originating from file 1 or 2 (parameter `which`), stripping off line prefixes. Examples: >>> diff = ndiff('one\ntwo\nthree\n...
[ "r", "Generate", "one", "of", "the", "two", "sequences", "that", "generated", "a", "delta", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L2097-L2127
[ "def", "restore", "(", "delta", ",", "which", ")", ":", "try", ":", "tag", "=", "{", "1", ":", "\"- \"", ",", "2", ":", "\"+ \"", "}", "[", "int", "(", "which", ")", "]", "except", "KeyError", ":", "raise", "ValueError", ",", "(", "'unknown delta c...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Match._make
Make a new Match object from a sequence or iterable
third_party/stdlib/difflib.py
def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new Match object from a sequence or iterable' result = new(cls, iterable) if len(result) != 3: raise TypeError('Expected 3 arguments, got %d' % len(result)) return result
def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new Match object from a sequence or iterable' result = new(cls, iterable) if len(result) != 3: raise TypeError('Expected 3 arguments, got %d' % len(result)) return result
[ "Make", "a", "new", "Match", "object", "from", "a", "sequence", "or", "iterable" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L62-L67
[ "def", "_make", "(", "cls", ",", "iterable", ",", "new", "=", "tuple", ".", "__new__", ",", "len", "=", "len", ")", ":", "result", "=", "new", "(", "cls", ",", "iterable", ")", "if", "len", "(", "result", ")", "!=", "3", ":", "raise", "TypeError"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.set_seq1
Set the first sequence to be compared. The second sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq1("bcde") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed ...
third_party/stdlib/difflib.py
def set_seq1(self, a): """Set the first sequence to be compared. The second sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq1("bcde") >>> s.ratio() 1.0 >>> SequenceMat...
def set_seq1(self, a): """Set the first sequence to be compared. The second sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq1("bcde") >>> s.ratio() 1.0 >>> SequenceMat...
[ "Set", "the", "first", "sequence", "to", "be", "compared", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L295-L319
[ "def", "set_seq1", "(", "self", ",", "a", ")", ":", "if", "a", "is", "self", ".", "a", ":", "return", "self", ".", "a", "=", "a", "self", ".", "matching_blocks", "=", "self", ".", "opcodes", "=", "None" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.set_seq2
Set the second sequence to be compared. The first sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq2("abcd") >>> s.ratio() 1.0 >>> SequenceMatcher computes and caches detailed ...
third_party/stdlib/difflib.py
def set_seq2(self, b): """Set the second sequence to be compared. The first sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq2("abcd") >>> s.ratio() 1.0 >>> SequenceMat...
def set_seq2(self, b): """Set the second sequence to be compared. The first sequence to be compared is not changed. >>> s = SequenceMatcher(None, "abcd", "bcde") >>> s.ratio() 0.75 >>> s.set_seq2("abcd") >>> s.ratio() 1.0 >>> SequenceMat...
[ "Set", "the", "second", "sequence", "to", "be", "compared", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L321-L347
[ "def", "set_seq2", "(", "self", ",", "b", ")", ":", "if", "b", "is", "self", ".", "b", ":", "return", "self", ".", "b", "=", "b", "self", ".", "matching_blocks", "=", "self", ".", "opcodes", "=", "None", "self", ".", "fullbcount", "=", "None", "s...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.find_longest_match
Find longest matching block in a[alo:ahi] and b[blo:bhi]. If isjunk is not defined: Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where alo <= i <= i+k <= ahi blo <= j <= j+k <= bhi and for all (i',j',k') meeting those conditions, k >= k' ...
third_party/stdlib/difflib.py
def find_longest_match(self, alo, ahi, blo, bhi): """Find longest matching block in a[alo:ahi] and b[blo:bhi]. If isjunk is not defined: Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where alo <= i <= i+k <= ahi blo <= j <= j+k <= bhi and for all (i',j...
def find_longest_match(self, alo, ahi, blo, bhi): """Find longest matching block in a[alo:ahi] and b[blo:bhi]. If isjunk is not defined: Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where alo <= i <= i+k <= ahi blo <= j <= j+k <= bhi and for all (i',j...
[ "Find", "longest", "matching", "block", "in", "a", "[", "alo", ":", "ahi", "]", "and", "b", "[", "blo", ":", "bhi", "]", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L411-L519
[ "def", "find_longest_match", "(", "self", ",", "alo", ",", "ahi", ",", "blo", ",", "bhi", ")", ":", "# CAUTION: stripping common prefix or suffix would be incorrect.", "# E.g.,", "# ab", "# acab", "# Longest matching block is \"ab\", but if common prefix is", "# stripped...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.get_matching_blocks
Return list of triples describing matching subsequences. Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in i and in j. New in Python 2.5, it's also guaranteed that if (i, j, n) and (i', j', n') are adjacent triples i...
third_party/stdlib/difflib.py
def get_matching_blocks(self): """Return list of triples describing matching subsequences. Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in i and in j. New in Python 2.5, it's also guaranteed that if (i, j, ...
def get_matching_blocks(self): """Return list of triples describing matching subsequences. Each triple is of the form (i, j, n), and means that a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in i and in j. New in Python 2.5, it's also guaranteed that if (i, j, ...
[ "Return", "list", "of", "triples", "describing", "matching", "subsequences", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L521-L590
[ "def", "get_matching_blocks", "(", "self", ")", ":", "if", "self", ".", "matching_blocks", "is", "not", "None", ":", "return", "self", ".", "matching_blocks", "la", ",", "lb", "=", "len", "(", "self", ".", "a", ")", ",", "len", "(", "self", ".", "b",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.get_opcodes
Return list of 5-tuples describing how to turn a into b. Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the tuple preceding it, and likewise for j1 == the previous j2. The tags are strings, with these mea...
third_party/stdlib/difflib.py
def get_opcodes(self): """Return list of 5-tuples describing how to turn a into b. Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the tuple preceding it, and likewise for j1 == the previous j2. Th...
def get_opcodes(self): """Return list of 5-tuples describing how to turn a into b. Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the tuple preceding it, and likewise for j1 == the previous j2. Th...
[ "Return", "list", "of", "5", "-", "tuples", "describing", "how", "to", "turn", "a", "into", "b", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L592-L645
[ "def", "get_opcodes", "(", "self", ")", ":", "if", "self", ".", "opcodes", "is", "not", "None", ":", "return", "self", ".", "opcodes", "i", "=", "j", "=", "0", "self", ".", "opcodes", "=", "answer", "=", "[", "]", "for", "ai", ",", "bj", ",", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.get_grouped_opcodes
Isolate change clusters by eliminating ranges with no changes. Return a generator of groups with up to n lines of context. Each group is in the same format as returned by get_opcodes(). >>> from pprint import pprint >>> a = map(str, range(1,40)) >>> b = a[:] >>> b[8:8] ...
third_party/stdlib/difflib.py
def get_grouped_opcodes(self, n=3): """ Isolate change clusters by eliminating ranges with no changes. Return a generator of groups with up to n lines of context. Each group is in the same format as returned by get_opcodes(). >>> from pprint import pprint >>> a = map(str, range...
def get_grouped_opcodes(self, n=3): """ Isolate change clusters by eliminating ranges with no changes. Return a generator of groups with up to n lines of context. Each group is in the same format as returned by get_opcodes(). >>> from pprint import pprint >>> a = map(str, range...
[ "Isolate", "change", "clusters", "by", "eliminating", "ranges", "with", "no", "changes", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L647-L695
[ "def", "get_grouped_opcodes", "(", "self", ",", "n", "=", "3", ")", ":", "codes", "=", "self", ".", "get_opcodes", "(", ")", "if", "not", "codes", ":", "codes", "=", "[", "(", "\"equal\"", ",", "0", ",", "1", ",", "0", ",", "1", ")", "]", "# Fi...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.ratio
Return a measure of the sequences' similarity (float in [0,1]). Where T is the total number of elements in both sequences, and M is the number of matches, this is 2.0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in common. .ratio() is ex...
third_party/stdlib/difflib.py
def ratio(self): """Return a measure of the sequences' similarity (float in [0,1]). Where T is the total number of elements in both sequences, and M is the number of matches, this is 2.0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in com...
def ratio(self): """Return a measure of the sequences' similarity (float in [0,1]). Where T is the total number of elements in both sequences, and M is the number of matches, this is 2.0*M / T. Note that this is 1 if the sequences are identical, and 0 if they have nothing in com...
[ "Return", "a", "measure", "of", "the", "sequences", "similarity", "(", "float", "in", "[", "0", "1", "]", ")", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L697-L721
[ "def", "ratio", "(", "self", ")", ":", "matches", "=", "reduce", "(", "lambda", "sum", ",", "triple", ":", "sum", "+", "triple", "[", "-", "1", "]", ",", "self", ".", "get_matching_blocks", "(", ")", ",", "0", ")", "return", "_calculate_ratio", "(", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.quick_ratio
Return an upper bound on ratio() relatively quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute.
third_party/stdlib/difflib.py
def quick_ratio(self): """Return an upper bound on ratio() relatively quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute. """ # viewing a and b as multisets, set matches to the cardinality # of their intersection; this cou...
def quick_ratio(self): """Return an upper bound on ratio() relatively quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute. """ # viewing a and b as multisets, set matches to the cardinality # of their intersection; this cou...
[ "Return", "an", "upper", "bound", "on", "ratio", "()", "relatively", "quickly", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L723-L750
[ "def", "quick_ratio", "(", "self", ")", ":", "# viewing a and b as multisets, set matches to the cardinality", "# of their intersection; this counts the number of matches", "# without regard to order, so is clearly an upper bound", "if", "self", ".", "fullbcount", "is", "None", ":", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SequenceMatcher.real_quick_ratio
Return an upper bound on ratio() very quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute than either .ratio() or .quick_ratio().
third_party/stdlib/difflib.py
def real_quick_ratio(self): """Return an upper bound on ratio() very quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute than either .ratio() or .quick_ratio(). """ la, lb = len(self.a), len(self.b) # can't have more matche...
def real_quick_ratio(self): """Return an upper bound on ratio() very quickly. This isn't defined beyond that it is an upper bound on .ratio(), and is faster to compute than either .ratio() or .quick_ratio(). """ la, lb = len(self.a), len(self.b) # can't have more matche...
[ "Return", "an", "upper", "bound", "on", "ratio", "()", "very", "quickly", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L752-L762
[ "def", "real_quick_ratio", "(", "self", ")", ":", "la", ",", "lb", "=", "len", "(", "self", ".", "a", ")", ",", "len", "(", "self", ".", "b", ")", "# can't have more matches than the number of elements in the", "# shorter sequence", "return", "_calculate_ratio", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Differ.compare
r""" Compare two sequences of lines; generate the resulting delta. Each sequence must contain individual single-line strings ending with newlines. Such sequences can be obtained from the `readlines()` method of file-like objects. The delta generated also consists of newline- te...
third_party/stdlib/difflib.py
def compare(self, a, b): r""" Compare two sequences of lines; generate the resulting delta. Each sequence must contain individual single-line strings ending with newlines. Such sequences can be obtained from the `readlines()` method of file-like objects. The delta generated als...
def compare(self, a, b): r""" Compare two sequences of lines; generate the resulting delta. Each sequence must contain individual single-line strings ending with newlines. Such sequences can be obtained from the `readlines()` method of file-like objects. The delta generated als...
[ "r", "Compare", "two", "sequences", "of", "lines", ";", "generate", "the", "resulting", "delta", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L945-L984
[ "def", "compare", "(", "self", ",", "a", ",", "b", ")", ":", "cruncher", "=", "SequenceMatcher", "(", "self", ".", "linejunk", ",", "a", ",", "b", ")", "for", "tag", ",", "alo", ",", "ahi", ",", "blo", ",", "bhi", "in", "cruncher", ".", "get_opco...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Differ._dump
Generate comparison results for a same-tagged range.
third_party/stdlib/difflib.py
def _dump(self, tag, x, lo, hi): """Generate comparison results for a same-tagged range.""" for i in xrange(lo, hi): yield '%s %s' % (tag, x[i])
def _dump(self, tag, x, lo, hi): """Generate comparison results for a same-tagged range.""" for i in xrange(lo, hi): yield '%s %s' % (tag, x[i])
[ "Generate", "comparison", "results", "for", "a", "same", "-", "tagged", "range", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L986-L989
[ "def", "_dump", "(", "self", ",", "tag", ",", "x", ",", "lo", ",", "hi", ")", ":", "for", "i", "in", "xrange", "(", "lo", ",", "hi", ")", ":", "yield", "'%s %s'", "%", "(", "tag", ",", "x", "[", "i", "]", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Differ._fancy_replace
r""" When replacing one block of lines with another, search the blocks for *similar* lines; the best-matching pair (if any) is used as a synch point, and intraline difference marking is done on the similar pair. Lots of work, but often worth it. Example: >>> d = Differ(...
third_party/stdlib/difflib.py
def _fancy_replace(self, a, alo, ahi, b, blo, bhi): r""" When replacing one block of lines with another, search the blocks for *similar* lines; the best-matching pair (if any) is used as a synch point, and intraline difference marking is done on the similar pair. Lots of work, bu...
def _fancy_replace(self, a, alo, ahi, b, blo, bhi): r""" When replacing one block of lines with another, search the blocks for *similar* lines; the best-matching pair (if any) is used as a synch point, and intraline difference marking is done on the similar pair. Lots of work, bu...
[ "r", "When", "replacing", "one", "block", "of", "lines", "with", "another", "search", "the", "blocks", "for", "*", "similar", "*", "lines", ";", "the", "best", "-", "matching", "pair", "(", "if", "any", ")", "is", "used", "as", "a", "synch", "point", ...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1006-L1102
[ "def", "_fancy_replace", "(", "self", ",", "a", ",", "alo", ",", "ahi", ",", "b", ",", "blo", ",", "bhi", ")", ":", "# don't synch up unless the lines have a similarity score of at", "# least cutoff; best_ratio tracks the best score seen so far", "best_ratio", ",", "cutof...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Differ._qformat
r""" Format "?" output and deal with leading tabs. Example: >>> d = Differ() >>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n', ... ' ^ ^ ^ ', ' ^ ^ ^ ') >>> for line in results: print repr(line) ... '- \t...
third_party/stdlib/difflib.py
def _qformat(self, aline, bline, atags, btags): r""" Format "?" output and deal with leading tabs. Example: >>> d = Differ() >>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n', ... ' ^ ^ ^ ', ' ^ ^ ^ ') >>> for lin...
def _qformat(self, aline, bline, atags, btags): r""" Format "?" output and deal with leading tabs. Example: >>> d = Differ() >>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n', ... ' ^ ^ ^ ', ' ^ ^ ^ ') >>> for lin...
[ "r", "Format", "?", "output", "and", "deal", "with", "leading", "tabs", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1117-L1148
[ "def", "_qformat", "(", "self", ",", "aline", ",", "bline", ",", "atags", ",", "btags", ")", ":", "# Can hurt, but will probably help most of the time.", "common", "=", "min", "(", "_count_leading", "(", "aline", ",", "\"\\t\"", ")", ",", "_count_leading", "(", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
HtmlDiff.make_file
Returns HTML file of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file column header string todesc -- "to" file column header string context -- set to True for contextual diff...
third_party/stdlib/difflib.py
def make_file(self,fromlines,tolines,fromdesc='',todesc='',context=False, numlines=5): """Returns HTML file of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file colu...
def make_file(self,fromlines,tolines,fromdesc='',todesc='',context=False, numlines=5): """Returns HTML file of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file colu...
[ "Returns", "HTML", "file", "of", "side", "by", "side", "comparison", "with", "change", "highlights" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1786-L1808
[ "def", "make_file", "(", "self", ",", "fromlines", ",", "tolines", ",", "fromdesc", "=", "''", ",", "todesc", "=", "''", ",", "context", "=", "False", ",", "numlines", "=", "5", ")", ":", "return", "self", ".", "_file_template", "%", "dict", "(", "st...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
HtmlDiff._tab_newline_replace
Returns from/to line lists with tabs expanded and newlines removed. Instead of tab characters being replaced by the number of spaces needed to fill in to the next tab stop, this function will fill the space with tab characters. This is done so that the difference algorithms can identif...
third_party/stdlib/difflib.py
def _tab_newline_replace(self,fromlines,tolines): """Returns from/to line lists with tabs expanded and newlines removed. Instead of tab characters being replaced by the number of spaces needed to fill in to the next tab stop, this function will fill the space with tab characters. This ...
def _tab_newline_replace(self,fromlines,tolines): """Returns from/to line lists with tabs expanded and newlines removed. Instead of tab characters being replaced by the number of spaces needed to fill in to the next tab stop, this function will fill the space with tab characters. This ...
[ "Returns", "from", "/", "to", "line", "lists", "with", "tabs", "expanded", "and", "newlines", "removed", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1810-L1831
[ "def", "_tab_newline_replace", "(", "self", ",", "fromlines", ",", "tolines", ")", ":", "def", "expand_tabs", "(", "line", ")", ":", "# hide real spaces", "line", "=", "line", ".", "replace", "(", "' '", ",", "'\\0'", ")", "# expand tabs into spaces", "line", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
HtmlDiff._split_line
Builds list of text lines by splitting text lines at wrap point This function will determine if the input text line needs to be wrapped (split) into separate lines. If so, the first wrap point will be determined and the first line appended to the output text line list. This function i...
third_party/stdlib/difflib.py
def _split_line(self,data_list,line_num,text): """Builds list of text lines by splitting text lines at wrap point This function will determine if the input text line needs to be wrapped (split) into separate lines. If so, the first wrap point will be determined and the first line appen...
def _split_line(self,data_list,line_num,text): """Builds list of text lines by splitting text lines at wrap point This function will determine if the input text line needs to be wrapped (split) into separate lines. If so, the first wrap point will be determined and the first line appen...
[ "Builds", "list", "of", "text", "lines", "by", "splitting", "text", "lines", "at", "wrap", "point" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1833-L1886
[ "def", "_split_line", "(", "self", ",", "data_list", ",", "line_num", ",", "text", ")", ":", "# if blank line or context separator, just add it to the output list", "if", "not", "line_num", ":", "data_list", ".", "append", "(", "(", "line_num", ",", "text", ")", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
HtmlDiff._line_wrapper
Returns iterator that splits (wraps) mdiff text lines
third_party/stdlib/difflib.py
def _line_wrapper(self,diffs): """Returns iterator that splits (wraps) mdiff text lines""" # pull from/to data and flags from mdiff iterator for fromdata,todata,flag in diffs: # check for context separators and pass them through if flag is None: yield fro...
def _line_wrapper(self,diffs): """Returns iterator that splits (wraps) mdiff text lines""" # pull from/to data and flags from mdiff iterator for fromdata,todata,flag in diffs: # check for context separators and pass them through if flag is None: yield fro...
[ "Returns", "iterator", "that", "splits", "(", "wraps", ")", "mdiff", "text", "lines" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1888-L1914
[ "def", "_line_wrapper", "(", "self", ",", "diffs", ")", ":", "# pull from/to data and flags from mdiff iterator", "for", "fromdata", ",", "todata", ",", "flag", "in", "diffs", ":", "# check for context separators and pass them through", "if", "flag", "is", "None", ":", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
HtmlDiff._collect_lines
Collects mdiff output into separate lists Before storing the mdiff from/to data into a list, it is converted into a single line of text with HTML markup.
third_party/stdlib/difflib.py
def _collect_lines(self,diffs): """Collects mdiff output into separate lists Before storing the mdiff from/to data into a list, it is converted into a single line of text with HTML markup. """ fromlist,tolist,flaglist = [],[],[] # pull from/to data and flags from mdiff ...
def _collect_lines(self,diffs): """Collects mdiff output into separate lists Before storing the mdiff from/to data into a list, it is converted into a single line of text with HTML markup. """ fromlist,tolist,flaglist = [],[],[] # pull from/to data and flags from mdiff ...
[ "Collects", "mdiff", "output", "into", "separate", "lists" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1916-L1935
[ "def", "_collect_lines", "(", "self", ",", "diffs", ")", ":", "fromlist", ",", "tolist", ",", "flaglist", "=", "[", "]", ",", "[", "]", ",", "[", "]", "# pull from/to data and flags from mdiff style iterator", "for", "fromdata", ",", "todata", ",", "flag", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
HtmlDiff._make_prefix
Create unique anchor prefixes
third_party/stdlib/difflib.py
def _make_prefix(self): """Create unique anchor prefixes""" # Generate a unique anchor prefix so multiple tables # can exist on the same HTML page without conflicts. fromprefix = "from%d_" % HtmlDiff._default_prefix toprefix = "to%d_" % HtmlDiff._default_prefix HtmlDiff....
def _make_prefix(self): """Create unique anchor prefixes""" # Generate a unique anchor prefix so multiple tables # can exist on the same HTML page without conflicts. fromprefix = "from%d_" % HtmlDiff._default_prefix toprefix = "to%d_" % HtmlDiff._default_prefix HtmlDiff....
[ "Create", "unique", "anchor", "prefixes" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1960-L1969
[ "def", "_make_prefix", "(", "self", ")", ":", "# Generate a unique anchor prefix so multiple tables", "# can exist on the same HTML page without conflicts.", "fromprefix", "=", "\"from%d_\"", "%", "HtmlDiff", ".", "_default_prefix", "toprefix", "=", "\"to%d_\"", "%", "HtmlDiff"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
HtmlDiff._convert_flags
Makes list of "next" links
third_party/stdlib/difflib.py
def _convert_flags(self,fromlist,tolist,flaglist,context,numlines): """Makes list of "next" links""" # all anchor names will be generated using the unique "to" prefix toprefix = self._prefix[1] # process change flags, generating middle column of next anchors/links next_id = [''...
def _convert_flags(self,fromlist,tolist,flaglist,context,numlines): """Makes list of "next" links""" # all anchor names will be generated using the unique "to" prefix toprefix = self._prefix[1] # process change flags, generating middle column of next anchors/links next_id = [''...
[ "Makes", "list", "of", "next", "links" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L1971-L2016
[ "def", "_convert_flags", "(", "self", ",", "fromlist", ",", "tolist", ",", "flaglist", ",", "context", ",", "numlines", ")", ":", "# all anchor names will be generated using the unique \"to\" prefix", "toprefix", "=", "self", ".", "_prefix", "[", "1", "]", "# proces...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
HtmlDiff.make_table
Returns HTML table of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file column header string todesc -- "to" file column header string context -- set to True for contextual dif...
third_party/stdlib/difflib.py
def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False, numlines=5): """Returns HTML table of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file c...
def make_table(self,fromlines,tolines,fromdesc='',todesc='',context=False, numlines=5): """Returns HTML table of side by side comparison with change highlights Arguments: fromlines -- list of "from" lines tolines -- list of "to" lines fromdesc -- "from" file c...
[ "Returns", "HTML", "table", "of", "side", "by", "side", "comparison", "with", "change", "highlights" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/difflib.py#L2018-L2093
[ "def", "make_table", "(", "self", ",", "fromlines", ",", "tolines", ",", "fromdesc", "=", "''", ",", "todesc", "=", "''", ",", "context", "=", "False", ",", "numlines", "=", "5", ")", ":", "# make unique anchor prefixes so that multiple tables may exist", "# on ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
_MakeParallelBenchmark
Create and return a benchmark that runs work_func p times in parallel.
benchmarks/concurrent.py
def _MakeParallelBenchmark(p, work_func, *args): """Create and return a benchmark that runs work_func p times in parallel.""" def Benchmark(b): # pylint: disable=missing-docstring e = threading.Event() def Target(): e.wait() for _ in xrange(b.N / p): work_func(*args) threads = [] ...
def _MakeParallelBenchmark(p, work_func, *args): """Create and return a benchmark that runs work_func p times in parallel.""" def Benchmark(b): # pylint: disable=missing-docstring e = threading.Event() def Target(): e.wait() for _ in xrange(b.N / p): work_func(*args) threads = [] ...
[ "Create", "and", "return", "a", "benchmark", "that", "runs", "work_func", "p", "times", "in", "parallel", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/benchmarks/concurrent.py#L38-L55
[ "def", "_MakeParallelBenchmark", "(", "p", ",", "work_func", ",", "*", "args", ")", ":", "def", "Benchmark", "(", "b", ")", ":", "# pylint: disable=missing-docstring", "e", "=", "threading", ".", "Event", "(", ")", "def", "Target", "(", ")", ":", "e", "....
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
StatementVisitor.visit_function_inline
Returns an GeneratedExpr for a function with the given body.
compiler/stmt.py
def visit_function_inline(self, node): """Returns an GeneratedExpr for a function with the given body.""" # First pass collects the names of locals used in this function. Do this in # a separate pass so that we know whether to resolve a name as a local or a # global during the second pass. func_visi...
def visit_function_inline(self, node): """Returns an GeneratedExpr for a function with the given body.""" # First pass collects the names of locals used in this function. Do this in # a separate pass so that we know whether to resolve a name as a local or a # global during the second pass. func_visi...
[ "Returns", "an", "GeneratedExpr", "for", "a", "function", "with", "the", "given", "body", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/compiler/stmt.py#L496-L566
[ "def", "visit_function_inline", "(", "self", ",", "node", ")", ":", "# First pass collects the names of locals used in this function. Do this in", "# a separate pass so that we know whether to resolve a name as a local or a", "# global during the second pass.", "func_visitor", "=", "block"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
StatementVisitor._import_and_bind
Generates code that imports a module and binds it to a variable. Args: imp: Import object representing an import of the form "import x.y.z" or "from x.y import z". Expects only a single binding.
compiler/stmt.py
def _import_and_bind(self, imp): """Generates code that imports a module and binds it to a variable. Args: imp: Import object representing an import of the form "import x.y.z" or "from x.y import z". Expects only a single binding. """ # Acquire handles to the Code objects in each Go pac...
def _import_and_bind(self, imp): """Generates code that imports a module and binds it to a variable. Args: imp: Import object representing an import of the form "import x.y.z" or "from x.y import z". Expects only a single binding. """ # Acquire handles to the Code objects in each Go pac...
[ "Generates", "code", "that", "imports", "a", "module", "and", "binds", "it", "to", "a", "variable", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/compiler/stmt.py#L612-L640
[ "def", "_import_and_bind", "(", "self", ",", "imp", ")", ":", "# Acquire handles to the Code objects in each Go package and call", "# ImportModule to initialize all modules.", "with", "self", ".", "block", ".", "alloc_temp", "(", ")", "as", "mod", ",", "self", ".", "blo...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
StatementVisitor._write_except_dispatcher
Outputs a Go code that jumps to the appropriate except handler. Args: exc: Go variable holding the current exception. tb: Go variable holding the current exception's traceback. handlers: A list of ast.ExceptHandler nodes. Returns: A list of Go labels indexes corresponding to the except...
compiler/stmt.py
def _write_except_dispatcher(self, exc, tb, handlers): """Outputs a Go code that jumps to the appropriate except handler. Args: exc: Go variable holding the current exception. tb: Go variable holding the current exception's traceback. handlers: A list of ast.ExceptHandler nodes. Returns:...
def _write_except_dispatcher(self, exc, tb, handlers): """Outputs a Go code that jumps to the appropriate except handler. Args: exc: Go variable holding the current exception. tb: Go variable holding the current exception's traceback. handlers: A list of ast.ExceptHandler nodes. Returns:...
[ "Outputs", "a", "Go", "code", "that", "jumps", "to", "the", "appropriate", "except", "handler", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/compiler/stmt.py#L706-L743
[ "def", "_write_except_dispatcher", "(", "self", ",", "exc", ",", "tb", ",", "handlers", ")", ":", "handler_labels", "=", "[", "]", "for", "i", ",", "except_node", "in", "enumerate", "(", "handlers", ")", ":", "handler_labels", ".", "append", "(", "self", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
listdir
List directory contents, using cache.
third_party/stdlib/dircache.py
def listdir(path): """List directory contents, using cache.""" try: cached_mtime, list = cache[path] del cache[path] except KeyError: cached_mtime, list = -1, [] mtime = os.stat(path).st_mtime if mtime != cached_mtime: list = os.listdir(path) list.sort() c...
def listdir(path): """List directory contents, using cache.""" try: cached_mtime, list = cache[path] del cache[path] except KeyError: cached_mtime, list = -1, [] mtime = os.stat(path).st_mtime if mtime != cached_mtime: list = os.listdir(path) list.sort() c...
[ "List", "directory", "contents", "using", "cache", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/dircache.py#L21-L33
[ "def", "listdir", "(", "path", ")", ":", "try", ":", "cached_mtime", ",", "list", "=", "cache", "[", "path", "]", "del", "cache", "[", "path", "]", "except", "KeyError", ":", "cached_mtime", ",", "list", "=", "-", "1", ",", "[", "]", "mtime", "=", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
annotate
Add '/' suffixes to directories.
third_party/stdlib/dircache.py
def annotate(head, list): """Add '/' suffixes to directories.""" for i in range(len(list)): if os.path.isdir(os.path.join(head, list[i])): list[i] = list[i] + '/'
def annotate(head, list): """Add '/' suffixes to directories.""" for i in range(len(list)): if os.path.isdir(os.path.join(head, list[i])): list[i] = list[i] + '/'
[ "Add", "/", "suffixes", "to", "directories", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/dircache.py#L37-L41
[ "def", "annotate", "(", "head", ",", "list", ")", ":", "for", "i", "in", "range", "(", "len", "(", "list", ")", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "os", ".", "path", ".", "join", "(", "head", ",", "list", "[", "i", "]", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
pprint
Pretty-print a Python o to a stream [default is sys.stdout].
third_party/stdlib/pprint.py
def pprint(o, stream=None, indent=1, width=80, depth=None): """Pretty-print a Python o to a stream [default is sys.stdout].""" printer = PrettyPrinter( stream=stream, indent=indent, width=width, depth=depth) printer.pprint(o)
def pprint(o, stream=None, indent=1, width=80, depth=None): """Pretty-print a Python o to a stream [default is sys.stdout].""" printer = PrettyPrinter( stream=stream, indent=indent, width=width, depth=depth) printer.pprint(o)
[ "Pretty", "-", "print", "a", "Python", "o", "to", "a", "stream", "[", "default", "is", "sys", ".", "stdout", "]", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/pprint.py#L57-L61
[ "def", "pprint", "(", "o", ",", "stream", "=", "None", ",", "indent", "=", "1", ",", "width", "=", "80", ",", "depth", "=", "None", ")", ":", "printer", "=", "PrettyPrinter", "(", "stream", "=", "stream", ",", "indent", "=", "indent", ",", "width",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
pformat
Format a Python o into a pretty-printed representation.
third_party/stdlib/pprint.py
def pformat(o, indent=1, width=80, depth=None): """Format a Python o into a pretty-printed representation.""" return PrettyPrinter(indent=indent, width=width, depth=depth).pformat(o)
def pformat(o, indent=1, width=80, depth=None): """Format a Python o into a pretty-printed representation.""" return PrettyPrinter(indent=indent, width=width, depth=depth).pformat(o)
[ "Format", "a", "Python", "o", "into", "a", "pretty", "-", "printed", "representation", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/pprint.py#L63-L65
[ "def", "pformat", "(", "o", ",", "indent", "=", "1", ",", "width", "=", "80", ",", "depth", "=", "None", ")", ":", "return", "PrettyPrinter", "(", "indent", "=", "indent", ",", "width", "=", "width", ",", "depth", "=", "depth", ")", ".", "pformat",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
PrettyPrinter.format
Format o for a specific context, returning a string and flags indicating whether the representation is 'readable' and whether the o represents a recursive construct.
third_party/stdlib/pprint.py
def format(self, o, context, maxlevels, level): """Format o for a specific context, returning a string and flags indicating whether the representation is 'readable' and whether the o represents a recursive construct. """ return _safe_repr(o, context, maxlevels, level)
def format(self, o, context, maxlevels, level): """Format o for a specific context, returning a string and flags indicating whether the representation is 'readable' and whether the o represents a recursive construct. """ return _safe_repr(o, context, maxlevels, level)
[ "Format", "o", "for", "a", "specific", "context", "returning", "a", "string", "and", "flags", "indicating", "whether", "the", "representation", "is", "readable", "and", "whether", "the", "o", "represents", "a", "recursive", "construct", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/pprint.py#L239-L244
[ "def", "format", "(", "self", ",", "o", ",", "context", ",", "maxlevels", ",", "level", ")", ":", "return", "_safe_repr", "(", "o", ",", "context", ",", "maxlevels", ",", "level", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
action
A decorator returning a function that first runs ``inner_rule`` and then, if its return value is not None, maps that value using ``mapper``. If the value being mapped is a tuple, it is expanded into multiple arguments. Similar to attaching semantic actions to rules in traditional parser generators.
third_party/pythonparser/parser.py
def action(inner_rule, loc=None): """ A decorator returning a function that first runs ``inner_rule`` and then, if its return value is not None, maps that value using ``mapper``. If the value being mapped is a tuple, it is expanded into multiple arguments. Similar to attaching semantic actions to ...
def action(inner_rule, loc=None): """ A decorator returning a function that first runs ``inner_rule`` and then, if its return value is not None, maps that value using ``mapper``. If the value being mapped is a tuple, it is expanded into multiple arguments. Similar to attaching semantic actions to ...
[ "A", "decorator", "returning", "a", "function", "that", "first", "runs", "inner_rule", "and", "then", "if", "its", "return", "value", "is", "not", "None", "maps", "that", "value", "using", "mapper", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L77-L97
[ "def", "action", "(", "inner_rule", ",", "loc", "=", "None", ")", ":", "def", "decorator", "(", "mapper", ")", ":", "@", "llrule", "(", "loc", ",", "inner_rule", ".", "expected", ")", "def", "outer_rule", "(", "parser", ")", ":", "result", "=", "inne...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Eps
A rule that accepts no tokens (epsilon) and returns ``value``.
third_party/pythonparser/parser.py
def Eps(value=None, loc=None): """A rule that accepts no tokens (epsilon) and returns ``value``.""" @llrule(loc, lambda parser: []) def rule(parser): return value return rule
def Eps(value=None, loc=None): """A rule that accepts no tokens (epsilon) and returns ``value``.""" @llrule(loc, lambda parser: []) def rule(parser): return value return rule
[ "A", "rule", "that", "accepts", "no", "tokens", "(", "epsilon", ")", "and", "returns", "value", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L99-L104
[ "def", "Eps", "(", "value", "=", "None", ",", "loc", "=", "None", ")", ":", "@", "llrule", "(", "loc", ",", "lambda", "parser", ":", "[", "]", ")", "def", "rule", "(", "parser", ")", ":", "return", "value", "return", "rule" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Tok
A rule that accepts a token of kind ``kind`` and returns it, or returns None.
third_party/pythonparser/parser.py
def Tok(kind, loc=None): """A rule that accepts a token of kind ``kind`` and returns it, or returns None.""" @llrule(loc, lambda parser: [kind]) def rule(parser): return parser._accept(kind) return rule
def Tok(kind, loc=None): """A rule that accepts a token of kind ``kind`` and returns it, or returns None.""" @llrule(loc, lambda parser: [kind]) def rule(parser): return parser._accept(kind) return rule
[ "A", "rule", "that", "accepts", "a", "token", "of", "kind", "kind", "and", "returns", "it", "or", "returns", "None", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L106-L111
[ "def", "Tok", "(", "kind", ",", "loc", "=", "None", ")", ":", "@", "llrule", "(", "loc", ",", "lambda", "parser", ":", "[", "kind", "]", ")", "def", "rule", "(", "parser", ")", ":", "return", "parser", ".", "_accept", "(", "kind", ")", "return", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Loc
A rule that accepts a token of kind ``kind`` and returns its location, or returns None.
third_party/pythonparser/parser.py
def Loc(kind, loc=None): """A rule that accepts a token of kind ``kind`` and returns its location, or returns None.""" @llrule(loc, lambda parser: [kind]) def rule(parser): result = parser._accept(kind) if result is unmatched: return result return result.loc return ru...
def Loc(kind, loc=None): """A rule that accepts a token of kind ``kind`` and returns its location, or returns None.""" @llrule(loc, lambda parser: [kind]) def rule(parser): result = parser._accept(kind) if result is unmatched: return result return result.loc return ru...
[ "A", "rule", "that", "accepts", "a", "token", "of", "kind", "kind", "and", "returns", "its", "location", "or", "returns", "None", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L113-L121
[ "def", "Loc", "(", "kind", ",", "loc", "=", "None", ")", ":", "@", "llrule", "(", "loc", ",", "lambda", "parser", ":", "[", "kind", "]", ")", "def", "rule", "(", "parser", ")", ":", "result", "=", "parser", ".", "_accept", "(", "kind", ")", "if...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Rule
A proxy for a rule called ``name`` which may not be yet defined.
third_party/pythonparser/parser.py
def Rule(name, loc=None): """A proxy for a rule called ``name`` which may not be yet defined.""" @llrule(loc, lambda parser: getattr(parser, name).expected(parser)) def rule(parser): return getattr(parser, name)() return rule
def Rule(name, loc=None): """A proxy for a rule called ``name`` which may not be yet defined.""" @llrule(loc, lambda parser: getattr(parser, name).expected(parser)) def rule(parser): return getattr(parser, name)() return rule
[ "A", "proxy", "for", "a", "rule", "called", "name", "which", "may", "not", "be", "yet", "defined", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L123-L128
[ "def", "Rule", "(", "name", ",", "loc", "=", "None", ")", ":", "@", "llrule", "(", "loc", ",", "lambda", "parser", ":", "getattr", "(", "parser", ",", "name", ")", ".", "expected", "(", "parser", ")", ")", "def", "rule", "(", "parser", ")", ":", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Expect
A rule that executes ``inner_rule`` and emits a diagnostic error if it returns None.
third_party/pythonparser/parser.py
def Expect(inner_rule, loc=None): """A rule that executes ``inner_rule`` and emits a diagnostic error if it returns None.""" @llrule(loc, inner_rule.expected) def rule(parser): result = inner_rule(parser) if result is unmatched: expected = reduce(list.__add__, [rule.expected(pars...
def Expect(inner_rule, loc=None): """A rule that executes ``inner_rule`` and emits a diagnostic error if it returns None.""" @llrule(loc, inner_rule.expected) def rule(parser): result = inner_rule(parser) if result is unmatched: expected = reduce(list.__add__, [rule.expected(pars...
[ "A", "rule", "that", "executes", "inner_rule", "and", "emits", "a", "diagnostic", "error", "if", "it", "returns", "None", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L130-L153
[ "def", "Expect", "(", "inner_rule", ",", "loc", "=", "None", ")", ":", "@", "llrule", "(", "loc", ",", "inner_rule", ".", "expected", ")", "def", "rule", "(", "parser", ")", ":", "result", "=", "inner_rule", "(", "parser", ")", "if", "result", "is", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Seq
A rule that accepts a sequence of tokens satisfying ``rules`` and returns a tuple containing their return values, or None if the first rule was not satisfied.
third_party/pythonparser/parser.py
def Seq(first_rule, *rest_of_rules, **kwargs): """ A rule that accepts a sequence of tokens satisfying ``rules`` and returns a tuple containing their return values, or None if the first rule was not satisfied. """ @llrule(kwargs.get("loc", None), first_rule.expected) def rule(parser): re...
def Seq(first_rule, *rest_of_rules, **kwargs): """ A rule that accepts a sequence of tokens satisfying ``rules`` and returns a tuple containing their return values, or None if the first rule was not satisfied. """ @llrule(kwargs.get("loc", None), first_rule.expected) def rule(parser): re...
[ "A", "rule", "that", "accepts", "a", "sequence", "of", "tokens", "satisfying", "rules", "and", "returns", "a", "tuple", "containing", "their", "return", "values", "or", "None", "if", "the", "first", "rule", "was", "not", "satisfied", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L155-L173
[ "def", "Seq", "(", "first_rule", ",", "*", "rest_of_rules", ",", "*", "*", "kwargs", ")", ":", "@", "llrule", "(", "kwargs", ".", "get", "(", "\"loc\"", ",", "None", ")", ",", "first_rule", ".", "expected", ")", "def", "rule", "(", "parser", ")", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
SeqN
A rule that accepts a sequence of tokens satisfying ``rules`` and returns the value returned by rule number ``n``, or None if the first rule was not satisfied.
third_party/pythonparser/parser.py
def SeqN(n, *inner_rules, **kwargs): """ A rule that accepts a sequence of tokens satisfying ``rules`` and returns the value returned by rule number ``n``, or None if the first rule was not satisfied. """ @action(Seq(*inner_rules), loc=kwargs.get("loc", None)) def rule(parser, *values): ...
def SeqN(n, *inner_rules, **kwargs): """ A rule that accepts a sequence of tokens satisfying ``rules`` and returns the value returned by rule number ``n``, or None if the first rule was not satisfied. """ @action(Seq(*inner_rules), loc=kwargs.get("loc", None)) def rule(parser, *values): ...
[ "A", "rule", "that", "accepts", "a", "sequence", "of", "tokens", "satisfying", "rules", "and", "returns", "the", "value", "returned", "by", "rule", "number", "n", "or", "None", "if", "the", "first", "rule", "was", "not", "satisfied", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L175-L183
[ "def", "SeqN", "(", "n", ",", "*", "inner_rules", ",", "*", "*", "kwargs", ")", ":", "@", "action", "(", "Seq", "(", "*", "inner_rules", ")", ",", "loc", "=", "kwargs", ".", "get", "(", "\"loc\"", ",", "None", ")", ")", "def", "rule", "(", "par...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Alt
A rule that expects a sequence of tokens satisfying one of ``rules`` in sequence (a rule is satisfied when it returns anything but None) and returns the return value of that rule, or None if no rules were satisfied.
third_party/pythonparser/parser.py
def Alt(*inner_rules, **kwargs): """ A rule that expects a sequence of tokens satisfying one of ``rules`` in sequence (a rule is satisfied when it returns anything but None) and returns the return value of that rule, or None if no rules were satisfied. """ loc = kwargs.get("loc", None) expec...
def Alt(*inner_rules, **kwargs): """ A rule that expects a sequence of tokens satisfying one of ``rules`` in sequence (a rule is satisfied when it returns anything but None) and returns the return value of that rule, or None if no rules were satisfied. """ loc = kwargs.get("loc", None) expec...
[ "A", "rule", "that", "expects", "a", "sequence", "of", "tokens", "satisfying", "one", "of", "rules", "in", "sequence", "(", "a", "rule", "is", "satisfied", "when", "it", "returns", "anything", "but", "None", ")", "and", "returns", "the", "return", "value",...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L185-L216
[ "def", "Alt", "(", "*", "inner_rules", ",", "*", "*", "kwargs", ")", ":", "loc", "=", "kwargs", ".", "get", "(", "\"loc\"", ",", "None", ")", "expected", "=", "lambda", "parser", ":", "reduce", "(", "list", ".", "__add__", ",", "map", "(", "lambda"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Star
A rule that accepts a sequence of tokens satisfying ``inner_rule`` zero or more times, and returns the returned values in a :class:`list`.
third_party/pythonparser/parser.py
def Star(inner_rule, loc=None): """ A rule that accepts a sequence of tokens satisfying ``inner_rule`` zero or more times, and returns the returned values in a :class:`list`. """ @llrule(loc, lambda parser: []) def rule(parser): results = [] while True: data = parser....
def Star(inner_rule, loc=None): """ A rule that accepts a sequence of tokens satisfying ``inner_rule`` zero or more times, and returns the returned values in a :class:`list`. """ @llrule(loc, lambda parser: []) def rule(parser): results = [] while True: data = parser....
[ "A", "rule", "that", "accepts", "a", "sequence", "of", "tokens", "satisfying", "inner_rule", "zero", "or", "more", "times", "and", "returns", "the", "returned", "values", "in", "a", ":", "class", ":", "list", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L222-L237
[ "def", "Star", "(", "inner_rule", ",", "loc", "=", "None", ")", ":", "@", "llrule", "(", "loc", ",", "lambda", "parser", ":", "[", "]", ")", "def", "rule", "(", "parser", ")", ":", "results", "=", "[", "]", "while", "True", ":", "data", "=", "p...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Newline
A rule that accepts token of kind ``newline`` and returns an empty list.
third_party/pythonparser/parser.py
def Newline(loc=None): """A rule that accepts token of kind ``newline`` and returns an empty list.""" @llrule(loc, lambda parser: ["newline"]) def rule(parser): result = parser._accept("newline") if result is unmatched: return result return [] return rule
def Newline(loc=None): """A rule that accepts token of kind ``newline`` and returns an empty list.""" @llrule(loc, lambda parser: ["newline"]) def rule(parser): result = parser._accept("newline") if result is unmatched: return result return [] return rule
[ "A", "rule", "that", "accepts", "token", "of", "kind", "newline", "and", "returns", "an", "empty", "list", "." ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L301-L309
[ "def", "Newline", "(", "loc", "=", "None", ")", ":", "@", "llrule", "(", "loc", ",", "lambda", "parser", ":", "[", "\"newline\"", "]", ")", "def", "rule", "(", "parser", ")", ":", "result", "=", "parser", ".", "_accept", "(", "\"newline\"", ")", "i...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Oper
A rule that accepts a sequence of tokens of kinds ``kinds`` and returns an instance of ``klass`` with ``loc`` encompassing the entire sequence or None if the first token is not of ``kinds[0]``.
third_party/pythonparser/parser.py
def Oper(klass, *kinds, **kwargs): """ A rule that accepts a sequence of tokens of kinds ``kinds`` and returns an instance of ``klass`` with ``loc`` encompassing the entire sequence or None if the first token is not of ``kinds[0]``. """ @action(Seq(*map(Loc, kinds)), loc=kwargs.get("loc", None))...
def Oper(klass, *kinds, **kwargs): """ A rule that accepts a sequence of tokens of kinds ``kinds`` and returns an instance of ``klass`` with ``loc`` encompassing the entire sequence or None if the first token is not of ``kinds[0]``. """ @action(Seq(*map(Loc, kinds)), loc=kwargs.get("loc", None))...
[ "A", "rule", "that", "accepts", "a", "sequence", "of", "tokens", "of", "kinds", "kinds", "and", "returns", "an", "instance", "of", "klass", "with", "loc", "encompassing", "the", "entire", "sequence", "or", "None", "if", "the", "first", "token", "is", "not"...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L311-L320
[ "def", "Oper", "(", "klass", ",", "*", "kinds", ",", "*", "*", "kwargs", ")", ":", "@", "action", "(", "Seq", "(", "*", "map", "(", "Loc", ",", "kinds", ")", ")", ",", "loc", "=", "kwargs", ".", "get", "(", "\"loc\"", ",", "None", ")", ")", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.single_input
single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
third_party/pythonparser/parser.py
def single_input(self, body): """single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE""" loc = None if body != []: loc = body[0].loc return ast.Interactive(body=body, loc=loc)
def single_input(self, body): """single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE""" loc = None if body != []: loc = body[0].loc return ast.Interactive(body=body, loc=loc)
[ "single_input", ":", "NEWLINE", "|", "simple_stmt", "|", "compound_stmt", "NEWLINE" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L530-L535
[ "def", "single_input", "(", "self", ",", "body", ")", ":", "loc", "=", "None", "if", "body", "!=", "[", "]", ":", "loc", "=", "body", "[", "0", "]", ".", "loc", "return", "ast", ".", "Interactive", "(", "body", "=", "body", ",", "loc", "=", "lo...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.file_input
file_input: (NEWLINE | stmt)* ENDMARKER
third_party/pythonparser/parser.py
def file_input(parser, body): """file_input: (NEWLINE | stmt)* ENDMARKER""" body = reduce(list.__add__, body, []) loc = None if body != []: loc = body[0].loc return ast.Module(body=body, loc=loc)
def file_input(parser, body): """file_input: (NEWLINE | stmt)* ENDMARKER""" body = reduce(list.__add__, body, []) loc = None if body != []: loc = body[0].loc return ast.Module(body=body, loc=loc)
[ "file_input", ":", "(", "NEWLINE", "|", "stmt", ")", "*", "ENDMARKER" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L538-L544
[ "def", "file_input", "(", "parser", ",", "body", ")", ":", "body", "=", "reduce", "(", "list", ".", "__add__", ",", "body", ",", "[", "]", ")", "loc", "=", "None", "if", "body", "!=", "[", "]", ":", "loc", "=", "body", "[", "0", "]", ".", "lo...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.eval_input
eval_input: testlist NEWLINE* ENDMARKER
third_party/pythonparser/parser.py
def eval_input(self, expr): """eval_input: testlist NEWLINE* ENDMARKER""" return ast.Expression(body=[expr], loc=expr.loc)
def eval_input(self, expr): """eval_input: testlist NEWLINE* ENDMARKER""" return ast.Expression(body=[expr], loc=expr.loc)
[ "eval_input", ":", "testlist", "NEWLINE", "*", "ENDMARKER" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L547-L549
[ "def", "eval_input", "(", "self", ",", "expr", ")", ":", "return", "ast", ".", "Expression", "(", "body", "=", "[", "expr", "]", ",", "loc", "=", "expr", ".", "loc", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.decorator
decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
third_party/pythonparser/parser.py
def decorator(self, at_loc, idents, call_opt, newline_loc): """decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE""" root = idents[0] dec_loc = root.loc expr = ast.Name(id=root.value, ctx=None, loc=root.loc) for ident in idents[1:]: dot_loc = ident.loc.begin() ...
def decorator(self, at_loc, idents, call_opt, newline_loc): """decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE""" root = idents[0] dec_loc = root.loc expr = ast.Name(id=root.value, ctx=None, loc=root.loc) for ident in idents[1:]: dot_loc = ident.loc.begin() ...
[ "decorator", ":" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L555-L572
[ "def", "decorator", "(", "self", ",", "at_loc", ",", "idents", ",", "call_opt", ",", "newline_loc", ")", ":", "root", "=", "idents", "[", "0", "]", "dec_loc", "=", "root", ".", "loc", "expr", "=", "ast", ".", "Name", "(", "id", "=", "root", ".", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.decorated
decorated: decorators (classdef | funcdef)
third_party/pythonparser/parser.py
def decorated(self, decorators, classfuncdef): """decorated: decorators (classdef | funcdef)""" classfuncdef.at_locs = list(map(lambda x: x[0], decorators)) classfuncdef.decorator_list = list(map(lambda x: x[1], decorators)) classfuncdef.loc = classfuncdef.loc.join(decorators[0][0]) ...
def decorated(self, decorators, classfuncdef): """decorated: decorators (classdef | funcdef)""" classfuncdef.at_locs = list(map(lambda x: x[0], decorators)) classfuncdef.decorator_list = list(map(lambda x: x[1], decorators)) classfuncdef.loc = classfuncdef.loc.join(decorators[0][0]) ...
[ "decorated", ":", "decorators", "(", "classdef", "|", "funcdef", ")" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L578-L583
[ "def", "decorated", "(", "self", ",", "decorators", ",", "classfuncdef", ")", ":", "classfuncdef", ".", "at_locs", "=", "list", "(", "map", "(", "lambda", "x", ":", "x", "[", "0", "]", ",", "decorators", ")", ")", "classfuncdef", ".", "decorator_list", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.funcdef__26
(2.6, 2.7) funcdef: 'def' NAME parameters ':' suite
third_party/pythonparser/parser.py
def funcdef__26(self, def_loc, ident_tok, args, colon_loc, suite): """(2.6, 2.7) funcdef: 'def' NAME parameters ':' suite""" return ast.FunctionDef(name=ident_tok.value, args=args, returns=None, body=suite, decorator_list=[], at_locs=[], keyw...
def funcdef__26(self, def_loc, ident_tok, args, colon_loc, suite): """(2.6, 2.7) funcdef: 'def' NAME parameters ':' suite""" return ast.FunctionDef(name=ident_tok.value, args=args, returns=None, body=suite, decorator_list=[], at_locs=[], keyw...
[ "(", "2", ".", "6", "2", ".", "7", ")", "funcdef", ":", "def", "NAME", "parameters", ":", "suite" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L586-L592
[ "def", "funcdef__26", "(", "self", ",", "def_loc", ",", "ident_tok", ",", "args", ",", "colon_loc", ",", "suite", ")", ":", "return", "ast", ".", "FunctionDef", "(", "name", "=", "ident_tok", ".", "value", ",", "args", "=", "args", ",", "returns", "=",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.varargslist__26
(2.6, 2.7) varargslist: ((fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [','])
third_party/pythonparser/parser.py
def varargslist__26(self, fparams, args): """ (2.6, 2.7) varargslist: ((fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']) """ for fparam, default_opt in fparams: ...
def varargslist__26(self, fparams, args): """ (2.6, 2.7) varargslist: ((fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']) """ for fparam, default_opt in fparams: ...
[ "(", "2", ".", "6", "2", ".", "7", ")", "varargslist", ":", "((", "fpdef", "[", "=", "test", "]", ")", "*", "(", "*", "NAME", "[", "**", "NAME", "]", "|", "**", "NAME", ")", "|", "fpdef", "[", "=", "test", "]", "(", "fpdef", "[", "=", "te...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L642-L674
[ "def", "varargslist__26", "(", "self", ",", "fparams", ",", "args", ")", ":", "for", "fparam", ",", "default_opt", "in", "fparams", ":", "if", "default_opt", ":", "equals_loc", ",", "default", "=", "default_opt", "args", ".", "equals_locs", ".", "append", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.tfpdef
(3.0-) tfpdef: NAME [':' test]
third_party/pythonparser/parser.py
def tfpdef(self, ident_tok, annotation_opt): """(3.0-) tfpdef: NAME [':' test]""" if annotation_opt: colon_loc, annotation = annotation_opt return self._arg(ident_tok, colon_loc, annotation) return self._arg(ident_tok)
def tfpdef(self, ident_tok, annotation_opt): """(3.0-) tfpdef: NAME [':' test]""" if annotation_opt: colon_loc, annotation = annotation_opt return self._arg(ident_tok, colon_loc, annotation) return self._arg(ident_tok)
[ "(", "3", ".", "0", "-", ")", "tfpdef", ":", "NAME", "[", ":", "test", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L803-L808
[ "def", "tfpdef", "(", "self", ",", "ident_tok", ",", "annotation_opt", ")", ":", "if", "annotation_opt", ":", "colon_loc", ",", "annotation", "=", "annotation_opt", "return", "self", ".", "_arg", "(", "ident_tok", ",", "colon_loc", ",", "annotation", ")", "r...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.expr_stmt
(2.6, 2.7, 3.0, 3.1) expr_stmt: testlist (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist))*) (3.2-) expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist_star_expr))*)
third_party/pythonparser/parser.py
def expr_stmt(self, lhs, rhs): """ (2.6, 2.7, 3.0, 3.1) expr_stmt: testlist (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist))*) (3.2-) expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yie...
def expr_stmt(self, lhs, rhs): """ (2.6, 2.7, 3.0, 3.1) expr_stmt: testlist (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist))*) (3.2-) expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) | ('=' (yie...
[ "(", "2", ".", "6", "2", ".", "7", "3", ".", "0", "3", ".", "1", ")", "expr_stmt", ":", "testlist", "(", "augassign", "(", "yield_expr|testlist", ")", "|", "(", "=", "(", "yield_expr|testlist", "))", "*", ")", "(", "3", ".", "2", "-", ")", "exp...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L853-L877
[ "def", "expr_stmt", "(", "self", ",", "lhs", ",", "rhs", ")", ":", "if", "isinstance", "(", "rhs", ",", "ast", ".", "AugAssign", ")", ":", "if", "isinstance", "(", "lhs", ",", "ast", ".", "Tuple", ")", "or", "isinstance", "(", "lhs", ",", "ast", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.print_stmt
(2.6-2.7) print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] )
third_party/pythonparser/parser.py
def print_stmt(self, print_loc, stmt): """ (2.6-2.7) print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] ) """ stmt.keyword_loc = print_loc if stmt.loc is None: stmt.loc = print_loc else: ...
def print_stmt(self, print_loc, stmt): """ (2.6-2.7) print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] ) """ stmt.keyword_loc = print_loc if stmt.loc is None: stmt.loc = print_loc else: ...
[ "(", "2", ".", "6", "-", "2", ".", "7", ")", "print_stmt", ":", "print", "(", "[", "test", "(", "test", ")", "*", "[", "]", "]", "|", ">>", "test", "[", "(", "test", ")", "+", "[", "]", "]", ")" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L914-L925
[ "def", "print_stmt", "(", "self", ",", "print_loc", ",", "stmt", ")", ":", "stmt", ".", "keyword_loc", "=", "print_loc", "if", "stmt", ".", "loc", "is", "None", ":", "stmt", ".", "loc", "=", "print_loc", "else", ":", "stmt", ".", "loc", "=", "print_l...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.del_stmt
del_stmt: 'del' exprlist
third_party/pythonparser/parser.py
def del_stmt(self, stmt_loc, exprs): # Python uses exprlist here, but does *not* obey the usual # tuple-wrapping semantics, so we embed the rule directly. """del_stmt: 'del' exprlist""" return ast.Delete(targets=[self._assignable(expr, is_delete=True) for expr in exprs], ...
def del_stmt(self, stmt_loc, exprs): # Python uses exprlist here, but does *not* obey the usual # tuple-wrapping semantics, so we embed the rule directly. """del_stmt: 'del' exprlist""" return ast.Delete(targets=[self._assignable(expr, is_delete=True) for expr in exprs], ...
[ "del_stmt", ":", "del", "exprlist" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L928-L933
[ "def", "del_stmt", "(", "self", ",", "stmt_loc", ",", "exprs", ")", ":", "# Python uses exprlist here, but does *not* obey the usual", "# tuple-wrapping semantics, so we embed the rule directly.", "return", "ast", ".", "Delete", "(", "targets", "=", "[", "self", ".", "_as...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.return_stmt
return_stmt: 'return' [testlist]
third_party/pythonparser/parser.py
def return_stmt(self, stmt_loc, values): """return_stmt: 'return' [testlist]""" loc = stmt_loc if values: loc = loc.join(values.loc) return ast.Return(value=values, loc=loc, keyword_loc=stmt_loc)
def return_stmt(self, stmt_loc, values): """return_stmt: 'return' [testlist]""" loc = stmt_loc if values: loc = loc.join(values.loc) return ast.Return(value=values, loc=loc, keyword_loc=stmt_loc)
[ "return_stmt", ":", "return", "[", "testlist", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L955-L961
[ "def", "return_stmt", "(", "self", ",", "stmt_loc", ",", "values", ")", ":", "loc", "=", "stmt_loc", "if", "values", ":", "loc", "=", "loc", ".", "join", "(", "values", ".", "loc", ")", "return", "ast", ".", "Return", "(", "value", "=", "values", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.yield_stmt
yield_stmt: yield_expr
third_party/pythonparser/parser.py
def yield_stmt(self, expr): """yield_stmt: yield_expr""" return ast.Expr(value=expr, loc=expr.loc)
def yield_stmt(self, expr): """yield_stmt: yield_expr""" return ast.Expr(value=expr, loc=expr.loc)
[ "yield_stmt", ":", "yield_expr" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L964-L966
[ "def", "yield_stmt", "(", "self", ",", "expr", ")", ":", "return", "ast", ".", "Expr", "(", "value", "=", "expr", ",", "loc", "=", "expr", ".", "loc", ")" ]
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.raise_stmt__26
(2.6, 2.7) raise_stmt: 'raise' [test [',' test [',' test]]]
third_party/pythonparser/parser.py
def raise_stmt__26(self, raise_loc, type_opt): """(2.6, 2.7) raise_stmt: 'raise' [test [',' test [',' test]]]""" type_ = inst = tback = None loc = raise_loc if type_opt: type_, inst_opt = type_opt loc = loc.join(type_.loc) if inst_opt: ...
def raise_stmt__26(self, raise_loc, type_opt): """(2.6, 2.7) raise_stmt: 'raise' [test [',' test [',' test]]]""" type_ = inst = tback = None loc = raise_loc if type_opt: type_, inst_opt = type_opt loc = loc.join(type_.loc) if inst_opt: ...
[ "(", "2", ".", "6", "2", ".", "7", ")", "raise_stmt", ":", "raise", "[", "test", "[", "test", "[", "test", "]]]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L971-L984
[ "def", "raise_stmt__26", "(", "self", ",", "raise_loc", ",", "type_opt", ")", ":", "type_", "=", "inst", "=", "tback", "=", "None", "loc", "=", "raise_loc", "if", "type_opt", ":", "type_", ",", "inst_opt", "=", "type_opt", "loc", "=", "loc", ".", "join...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.raise_stmt__30
(3.0-) raise_stmt: 'raise' [test ['from' test]]
third_party/pythonparser/parser.py
def raise_stmt__30(self, raise_loc, exc_opt): """(3.0-) raise_stmt: 'raise' [test ['from' test]]""" exc = from_loc = cause = None loc = raise_loc if exc_opt: exc, cause_opt = exc_opt loc = loc.join(exc.loc) if cause_opt: from_loc, cause...
def raise_stmt__30(self, raise_loc, exc_opt): """(3.0-) raise_stmt: 'raise' [test ['from' test]]""" exc = from_loc = cause = None loc = raise_loc if exc_opt: exc, cause_opt = exc_opt loc = loc.join(exc.loc) if cause_opt: from_loc, cause...
[ "(", "3", ".", "0", "-", ")", "raise_stmt", ":", "raise", "[", "test", "[", "from", "test", "]]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L987-L998
[ "def", "raise_stmt__30", "(", "self", ",", "raise_loc", ",", "exc_opt", ")", ":", "exc", "=", "from_loc", "=", "cause", "=", "None", "loc", "=", "raise_loc", "if", "exc_opt", ":", "exc", ",", "cause_opt", "=", "exc_opt", "loc", "=", "loc", ".", "join",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.import_name
import_name: 'import' dotted_as_names
third_party/pythonparser/parser.py
def import_name(self, import_loc, names): """import_name: 'import' dotted_as_names""" return ast.Import(names=names, keyword_loc=import_loc, loc=import_loc.join(names[-1].loc))
def import_name(self, import_loc, names): """import_name: 'import' dotted_as_names""" return ast.Import(names=names, keyword_loc=import_loc, loc=import_loc.join(names[-1].loc))
[ "import_name", ":", "import", "dotted_as_names" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1004-L1007
[ "def", "import_name", "(", "self", ",", "import_loc", ",", "names", ")", ":", "return", "ast", ".", "Import", "(", "names", "=", "names", ",", "keyword_loc", "=", "import_loc", ",", "loc", "=", "import_loc", ".", "join", "(", "names", "[", "-", "1", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.import_from
(2.6, 2.7) import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) (3.0-) # note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS import_from: ('from' (('.' | '...')* dotted_name | ('.' |...
third_party/pythonparser/parser.py
def import_from(self, from_loc, module_name, import_loc, names): """ (2.6, 2.7) import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) (3.0-) # note below: the ('.' | '...') is necessary because '...' is to...
def import_from(self, from_loc, module_name, import_loc, names): """ (2.6, 2.7) import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) (3.0-) # note below: the ('.' | '...') is necessary because '...' is to...
[ "(", "2", ".", "6", "2", ".", "7", ")", "import_from", ":", "(", "from", "(", ".", "*", "dotted_name", "|", ".", "+", ")", "import", "(", "*", "|", "(", "import_as_names", ")", "|", "import_as_names", "))", "(", "3", ".", "0", "-", ")", "#", ...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1050-L1075
[ "def", "import_from", "(", "self", ",", "from_loc", ",", "module_name", ",", "import_loc", ",", "names", ")", ":", "(", "dots_loc", ",", "dots_count", ")", ",", "dotted_name_opt", "=", "module_name", "module_loc", "=", "module", "=", "None", "if", "dotted_na...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.import_as_name
import_as_name: NAME ['as' NAME]
third_party/pythonparser/parser.py
def import_as_name(self, name_tok, as_name_opt): """import_as_name: NAME ['as' NAME]""" asname_name = asname_loc = as_loc = None loc = name_tok.loc if as_name_opt: as_loc, asname = as_name_opt asname_name = asname.value asname_loc = asname.loc ...
def import_as_name(self, name_tok, as_name_opt): """import_as_name: NAME ['as' NAME]""" asname_name = asname_loc = as_loc = None loc = name_tok.loc if as_name_opt: as_loc, asname = as_name_opt asname_name = asname.value asname_loc = asname.loc ...
[ "import_as_name", ":", "NAME", "[", "as", "NAME", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1078-L1088
[ "def", "import_as_name", "(", "self", ",", "name_tok", ",", "as_name_opt", ")", ":", "asname_name", "=", "asname_loc", "=", "as_loc", "=", "None", "loc", "=", "name_tok", ".", "loc", "if", "as_name_opt", ":", "as_loc", ",", "asname", "=", "as_name_opt", "a...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.dotted_as_name
dotted_as_name: dotted_name ['as' NAME]
third_party/pythonparser/parser.py
def dotted_as_name(self, dotted_name, as_name_opt): """dotted_as_name: dotted_name ['as' NAME]""" asname_name = asname_loc = as_loc = None dotted_name_loc, dotted_name_name = dotted_name loc = dotted_name_loc if as_name_opt: as_loc, asname = as_name_opt as...
def dotted_as_name(self, dotted_name, as_name_opt): """dotted_as_name: dotted_name ['as' NAME]""" asname_name = asname_loc = as_loc = None dotted_name_loc, dotted_name_name = dotted_name loc = dotted_name_loc if as_name_opt: as_loc, asname = as_name_opt as...
[ "dotted_as_name", ":", "dotted_name", "[", "as", "NAME", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1091-L1102
[ "def", "dotted_as_name", "(", "self", ",", "dotted_name", ",", "as_name_opt", ")", ":", "asname_name", "=", "asname_loc", "=", "as_loc", "=", "None", "dotted_name_loc", ",", "dotted_name_name", "=", "dotted_name", "loc", "=", "dotted_name_loc", "if", "as_name_opt"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.dotted_name
dotted_name: NAME ('.' NAME)*
third_party/pythonparser/parser.py
def dotted_name(self, idents): """dotted_name: NAME ('.' NAME)*""" return idents[0].loc.join(idents[-1].loc), \ ".".join(list(map(lambda x: x.value, idents)))
def dotted_name(self, idents): """dotted_name: NAME ('.' NAME)*""" return idents[0].loc.join(idents[-1].loc), \ ".".join(list(map(lambda x: x.value, idents)))
[ "dotted_name", ":", "NAME", "(", ".", "NAME", ")", "*" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1123-L1126
[ "def", "dotted_name", "(", "self", ",", "idents", ")", ":", "return", "idents", "[", "0", "]", ".", "loc", ".", "join", "(", "idents", "[", "-", "1", "]", ".", "loc", ")", ",", "\".\"", ".", "join", "(", "list", "(", "map", "(", "lambda", "x", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.global_stmt
global_stmt: 'global' NAME (',' NAME)*
third_party/pythonparser/parser.py
def global_stmt(self, global_loc, names): """global_stmt: 'global' NAME (',' NAME)*""" return ast.Global(names=list(map(lambda x: x.value, names)), name_locs=list(map(lambda x: x.loc, names)), keyword_loc=global_loc, loc=global_loc.join(names[-1].loc))
def global_stmt(self, global_loc, names): """global_stmt: 'global' NAME (',' NAME)*""" return ast.Global(names=list(map(lambda x: x.value, names)), name_locs=list(map(lambda x: x.loc, names)), keyword_loc=global_loc, loc=global_loc.join(names[-1].loc))
[ "global_stmt", ":", "global", "NAME", "(", "NAME", ")", "*" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1129-L1133
[ "def", "global_stmt", "(", "self", ",", "global_loc", ",", "names", ")", ":", "return", "ast", ".", "Global", "(", "names", "=", "list", "(", "map", "(", "lambda", "x", ":", "x", ".", "value", ",", "names", ")", ")", ",", "name_locs", "=", "list", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.exec_stmt
(2.6, 2.7) exec_stmt: 'exec' expr ['in' test [',' test]]
third_party/pythonparser/parser.py
def exec_stmt(self, exec_loc, body, in_opt): """(2.6, 2.7) exec_stmt: 'exec' expr ['in' test [',' test]]""" in_loc, globals, locals = None, None, None loc = exec_loc.join(body.loc) if in_opt: in_loc, globals, locals = in_opt if locals: loc = loc.jo...
def exec_stmt(self, exec_loc, body, in_opt): """(2.6, 2.7) exec_stmt: 'exec' expr ['in' test [',' test]]""" in_loc, globals, locals = None, None, None loc = exec_loc.join(body.loc) if in_opt: in_loc, globals, locals = in_opt if locals: loc = loc.jo...
[ "(", "2", ".", "6", "2", ".", "7", ")", "exec_stmt", ":", "exec", "expr", "[", "in", "test", "[", "test", "]]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1138-L1149
[ "def", "exec_stmt", "(", "self", ",", "exec_loc", ",", "body", ",", "in_opt", ")", ":", "in_loc", ",", "globals", ",", "locals", "=", "None", ",", "None", ",", "None", "loc", "=", "exec_loc", ".", "join", "(", "body", ".", "loc", ")", "if", "in_opt...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.nonlocal_stmt
(3.0-) nonlocal_stmt: 'nonlocal' NAME (',' NAME)*
third_party/pythonparser/parser.py
def nonlocal_stmt(self, nonlocal_loc, names): """(3.0-) nonlocal_stmt: 'nonlocal' NAME (',' NAME)*""" return ast.Nonlocal(names=list(map(lambda x: x.value, names)), name_locs=list(map(lambda x: x.loc, names)), keyword_loc=nonlocal_loc, loc=nonlocal...
def nonlocal_stmt(self, nonlocal_loc, names): """(3.0-) nonlocal_stmt: 'nonlocal' NAME (',' NAME)*""" return ast.Nonlocal(names=list(map(lambda x: x.value, names)), name_locs=list(map(lambda x: x.loc, names)), keyword_loc=nonlocal_loc, loc=nonlocal...
[ "(", "3", ".", "0", "-", ")", "nonlocal_stmt", ":", "nonlocal", "NAME", "(", "NAME", ")", "*" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1152-L1156
[ "def", "nonlocal_stmt", "(", "self", ",", "nonlocal_loc", ",", "names", ")", ":", "return", "ast", ".", "Nonlocal", "(", "names", "=", "list", "(", "map", "(", "lambda", "x", ":", "x", ".", "value", ",", "names", ")", ")", ",", "name_locs", "=", "l...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.assert_stmt
assert_stmt: 'assert' test [',' test]
third_party/pythonparser/parser.py
def assert_stmt(self, assert_loc, test, msg): """assert_stmt: 'assert' test [',' test]""" loc = assert_loc.join(test.loc) if msg: loc = loc.join(msg.loc) return ast.Assert(test=test, msg=msg, loc=loc, keyword_loc=assert_loc)
def assert_stmt(self, assert_loc, test, msg): """assert_stmt: 'assert' test [',' test]""" loc = assert_loc.join(test.loc) if msg: loc = loc.join(msg.loc) return ast.Assert(test=test, msg=msg, loc=loc, keyword_loc=assert_loc)
[ "assert_stmt", ":", "assert", "test", "[", "test", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1159-L1165
[ "def", "assert_stmt", "(", "self", ",", "assert_loc", ",", "test", ",", "msg", ")", ":", "loc", "=", "assert_loc", ".", "join", "(", "test", ".", "loc", ")", "if", "msg", ":", "loc", "=", "loc", ".", "join", "(", "msg", ".", "loc", ")", "return",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.if_stmt
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
third_party/pythonparser/parser.py
def if_stmt(self, if_loc, test, if_colon_loc, body, elifs, else_opt): """if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]""" stmt = ast.If(orelse=[], else_loc=None, else_colon_loc=None) if else_opt: stmt.else_loc, stmt.else_colon_loc, st...
def if_stmt(self, if_loc, test, if_colon_loc, body, elifs, else_opt): """if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]""" stmt = ast.If(orelse=[], else_loc=None, else_colon_loc=None) if else_opt: stmt.else_loc, stmt.else_colon_loc, st...
[ "if_stmt", ":", "if", "test", ":", "suite", "(", "elif", "test", ":", "suite", ")", "*", "[", "else", ":", "suite", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1178-L1199
[ "def", "if_stmt", "(", "self", ",", "if_loc", ",", "test", ",", "if_colon_loc", ",", "body", ",", "elifs", ",", "else_opt", ")", ":", "stmt", "=", "ast", ".", "If", "(", "orelse", "=", "[", "]", ",", "else_loc", "=", "None", ",", "else_colon_loc", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.while_stmt
while_stmt: 'while' test ':' suite ['else' ':' suite]
third_party/pythonparser/parser.py
def while_stmt(self, while_loc, test, while_colon_loc, body, else_opt): """while_stmt: 'while' test ':' suite ['else' ':' suite]""" stmt = ast.While(test=test, body=body, orelse=[], keyword_loc=while_loc, while_colon_loc=while_colon_loc, else_loc=None, e...
def while_stmt(self, while_loc, test, while_colon_loc, body, else_opt): """while_stmt: 'while' test ':' suite ['else' ':' suite]""" stmt = ast.While(test=test, body=body, orelse=[], keyword_loc=while_loc, while_colon_loc=while_colon_loc, else_loc=None, e...
[ "while_stmt", ":", "while", "test", ":", "suite", "[", "else", ":", "suite", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1203-L1213
[ "def", "while_stmt", "(", "self", ",", "while_loc", ",", "test", ",", "while_colon_loc", ",", "body", ",", "else_opt", ")", ":", "stmt", "=", "ast", ".", "While", "(", "test", "=", "test", ",", "body", "=", "body", ",", "orelse", "=", "[", "]", ","...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.for_stmt
for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
third_party/pythonparser/parser.py
def for_stmt(self, for_loc, target, in_loc, iter, for_colon_loc, body, else_opt): """for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]""" stmt = ast.For(target=self._assignable(target), iter=iter, body=body, orelse=[], keyword_loc=for_loc, in_loc=in_loc, for_colo...
def for_stmt(self, for_loc, target, in_loc, iter, for_colon_loc, body, else_opt): """for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]""" stmt = ast.For(target=self._assignable(target), iter=iter, body=body, orelse=[], keyword_loc=for_loc, in_loc=in_loc, for_colo...
[ "for_stmt", ":", "for", "exprlist", "in", "testlist", ":", "suite", "[", "else", ":", "suite", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1218-L1228
[ "def", "for_stmt", "(", "self", ",", "for_loc", ",", "target", ",", "in_loc", ",", "iter", ",", "for_colon_loc", ",", "body", ",", "else_opt", ")", ":", "stmt", "=", "ast", ".", "For", "(", "target", "=", "self", ".", "_assignable", "(", "target", ")...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.try_stmt
try_stmt: ('try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite))
third_party/pythonparser/parser.py
def try_stmt(self, try_loc, try_colon_loc, body, stmt): """ try_stmt: ('try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite)) """ stmt.keyword_loc, stmt.tr...
def try_stmt(self, try_loc, try_colon_loc, body, stmt): """ try_stmt: ('try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite)) """ stmt.keyword_loc, stmt.tr...
[ "try_stmt", ":", "(", "try", ":", "suite", "((", "except_clause", ":", "suite", ")", "+", "[", "else", ":", "suite", "]", "[", "finally", ":", "suite", "]", "|", "finally", ":", "suite", "))" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1264-L1275
[ "def", "try_stmt", "(", "self", ",", "try_loc", ",", "try_colon_loc", ",", "body", ",", "stmt", ")", ":", "stmt", ".", "keyword_loc", ",", "stmt", ".", "try_colon_loc", ",", "stmt", ".", "body", "=", "try_loc", ",", "try_colon_loc", ",", "body", "stmt", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.with_stmt__26
(2.6, 3.0) with_stmt: 'with' test [ with_var ] ':' suite
third_party/pythonparser/parser.py
def with_stmt__26(self, with_loc, context, with_var, colon_loc, body): """(2.6, 3.0) with_stmt: 'with' test [ with_var ] ':' suite""" if with_var: as_loc, optional_vars = with_var item = ast.withitem(context_expr=context, optional_vars=optional_vars, ...
def with_stmt__26(self, with_loc, context, with_var, colon_loc, body): """(2.6, 3.0) with_stmt: 'with' test [ with_var ] ':' suite""" if with_var: as_loc, optional_vars = with_var item = ast.withitem(context_expr=context, optional_vars=optional_vars, ...
[ "(", "2", ".", "6", "3", ".", "0", ")", "with_stmt", ":", "with", "test", "[", "with_var", "]", ":", "suite" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1278-L1289
[ "def", "with_stmt__26", "(", "self", ",", "with_loc", ",", "context", ",", "with_var", ",", "colon_loc", ",", "body", ")", ":", "if", "with_var", ":", "as_loc", ",", "optional_vars", "=", "with_var", "item", "=", "ast", ".", "withitem", "(", "context_expr"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.with_stmt__27
(2.7, 3.1-) with_stmt: 'with' with_item (',' with_item)* ':' suite
third_party/pythonparser/parser.py
def with_stmt__27(self, with_loc, items, colon_loc, body): """(2.7, 3.1-) with_stmt: 'with' with_item (',' with_item)* ':' suite""" return ast.With(items=items, body=body, keyword_loc=with_loc, colon_loc=colon_loc, loc=with_loc.join(body[-1].loc))
def with_stmt__27(self, with_loc, items, colon_loc, body): """(2.7, 3.1-) with_stmt: 'with' with_item (',' with_item)* ':' suite""" return ast.With(items=items, body=body, keyword_loc=with_loc, colon_loc=colon_loc, loc=with_loc.join(body[-1].loc))
[ "(", "2", ".", "7", "3", ".", "1", "-", ")", "with_stmt", ":", "with", "with_item", "(", "with_item", ")", "*", ":", "suite" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1296-L1300
[ "def", "with_stmt__27", "(", "self", ",", "with_loc", ",", "items", ",", "colon_loc", ",", "body", ")", ":", "return", "ast", ".", "With", "(", "items", "=", "items", ",", "body", "=", "body", ",", "keyword_loc", "=", "with_loc", ",", "colon_loc", "=",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.with_item
(2.7, 3.1-) with_item: test ['as' expr]
third_party/pythonparser/parser.py
def with_item(self, context, as_opt): """(2.7, 3.1-) with_item: test ['as' expr]""" if as_opt: as_loc, optional_vars = as_opt return ast.withitem(context_expr=context, optional_vars=optional_vars, as_loc=as_loc, loc=context.loc.join(optional_vars.l...
def with_item(self, context, as_opt): """(2.7, 3.1-) with_item: test ['as' expr]""" if as_opt: as_loc, optional_vars = as_opt return ast.withitem(context_expr=context, optional_vars=optional_vars, as_loc=as_loc, loc=context.loc.join(optional_vars.l...
[ "(", "2", ".", "7", "3", ".", "1", "-", ")", "with_item", ":", "test", "[", "as", "expr", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1303-L1311
[ "def", "with_item", "(", "self", ",", "context", ",", "as_opt", ")", ":", "if", "as_opt", ":", "as_loc", ",", "optional_vars", "=", "as_opt", "return", "ast", ".", "withitem", "(", "context_expr", "=", "context", ",", "optional_vars", "=", "optional_vars", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.except_clause
(2.6, 2.7) except_clause: 'except' [test [('as' | ',') test]] (3.0-) except_clause: 'except' [test ['as' NAME]]
third_party/pythonparser/parser.py
def except_clause(self, except_loc, exc_opt): """ (2.6, 2.7) except_clause: 'except' [test [('as' | ',') test]] (3.0-) except_clause: 'except' [test ['as' NAME]] """ type_ = name = as_loc = name_loc = None loc = except_loc if exc_opt: type_, name_opt =...
def except_clause(self, except_loc, exc_opt): """ (2.6, 2.7) except_clause: 'except' [test [('as' | ',') test]] (3.0-) except_clause: 'except' [test ['as' NAME]] """ type_ = name = as_loc = name_loc = None loc = except_loc if exc_opt: type_, name_opt =...
[ "(", "2", ".", "6", "2", ".", "7", ")", "except_clause", ":", "except", "[", "test", "[", "(", "as", "|", ")", "test", "]]", "(", "3", ".", "0", "-", ")", "except_clause", ":", "except", "[", "test", "[", "as", "NAME", "]]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1324-L1345
[ "def", "except_clause", "(", "self", ",", "except_loc", ",", "exc_opt", ")", ":", "type_", "=", "name", "=", "as_loc", "=", "name_loc", "=", "None", "loc", "=", "except_loc", "if", "exc_opt", ":", "type_", ",", "name_opt", "=", "exc_opt", "loc", "=", "...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.old_lambdef
(2.6, 2.7) old_lambdef: 'lambda' [varargslist] ':' old_test
third_party/pythonparser/parser.py
def old_lambdef(self, lambda_loc, args_opt, colon_loc, body): """(2.6, 2.7) old_lambdef: 'lambda' [varargslist] ':' old_test""" if args_opt is None: args_opt = self._arguments() args_opt.loc = colon_loc.begin() return ast.Lambda(args=args_opt, body=body, ...
def old_lambdef(self, lambda_loc, args_opt, colon_loc, body): """(2.6, 2.7) old_lambdef: 'lambda' [varargslist] ':' old_test""" if args_opt is None: args_opt = self._arguments() args_opt.loc = colon_loc.begin() return ast.Lambda(args=args_opt, body=body, ...
[ "(", "2", ".", "6", "2", ".", "7", ")", "old_lambdef", ":", "lambda", "[", "varargslist", "]", ":", "old_test" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1363-L1370
[ "def", "old_lambdef", "(", "self", ",", "lambda_loc", ",", "args_opt", ",", "colon_loc", ",", "body", ")", ":", "if", "args_opt", "is", "None", ":", "args_opt", "=", "self", ".", "_arguments", "(", ")", "args_opt", ".", "loc", "=", "colon_loc", ".", "b...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.comparison
(2.6, 2.7) comparison: expr (comp_op expr)* (3.0, 3.1) comparison: star_expr (comp_op star_expr)* (3.2-) comparison: expr (comp_op expr)*
third_party/pythonparser/parser.py
def comparison(self, lhs, rhs): """ (2.6, 2.7) comparison: expr (comp_op expr)* (3.0, 3.1) comparison: star_expr (comp_op star_expr)* (3.2-) comparison: expr (comp_op expr)* """ if len(rhs) > 0: return ast.Compare(left=lhs, ops=list(map(lambda x: x[0], rhs)), ...
def comparison(self, lhs, rhs): """ (2.6, 2.7) comparison: expr (comp_op expr)* (3.0, 3.1) comparison: star_expr (comp_op star_expr)* (3.2-) comparison: expr (comp_op expr)* """ if len(rhs) > 0: return ast.Compare(left=lhs, ops=list(map(lambda x: x[0], rhs)), ...
[ "(", "2", ".", "6", "2", ".", "7", ")", "comparison", ":", "expr", "(", "comp_op", "expr", ")", "*", "(", "3", ".", "0", "3", ".", "1", ")", "comparison", ":", "star_expr", "(", "comp_op", "star_expr", ")", "*", "(", "3", ".", "2", "-", ")", ...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1441-L1452
[ "def", "comparison", "(", "self", ",", "lhs", ",", "rhs", ")", ":", "if", "len", "(", "rhs", ")", ">", "0", ":", "return", "ast", ".", "Compare", "(", "left", "=", "lhs", ",", "ops", "=", "list", "(", "map", "(", "lambda", "x", ":", "x", "[",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.star_expr__30
(3.0, 3.1) star_expr: ['*'] expr
third_party/pythonparser/parser.py
def star_expr__30(self, star_opt, expr): """(3.0, 3.1) star_expr: ['*'] expr""" if star_opt: return ast.Starred(value=expr, ctx=None, star_loc=star_opt, loc=expr.loc.join(star_opt)) return expr
def star_expr__30(self, star_opt, expr): """(3.0, 3.1) star_expr: ['*'] expr""" if star_opt: return ast.Starred(value=expr, ctx=None, star_loc=star_opt, loc=expr.loc.join(star_opt)) return expr
[ "(", "3", ".", "0", "3", ".", "1", ")", "star_expr", ":", "[", "*", "]", "expr" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1455-L1460
[ "def", "star_expr__30", "(", "self", ",", "star_opt", ",", "expr", ")", ":", "if", "star_opt", ":", "return", "ast", ".", "Starred", "(", "value", "=", "expr", ",", "ctx", "=", "None", ",", "star_loc", "=", "star_opt", ",", "loc", "=", "expr", ".", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.star_expr__32
(3.0-) star_expr: '*' expr
third_party/pythonparser/parser.py
def star_expr__32(self, star_loc, expr): """(3.0-) star_expr: '*' expr""" return ast.Starred(value=expr, ctx=None, star_loc=star_loc, loc=expr.loc.join(star_loc))
def star_expr__32(self, star_loc, expr): """(3.0-) star_expr: '*' expr""" return ast.Starred(value=expr, ctx=None, star_loc=star_loc, loc=expr.loc.join(star_loc))
[ "(", "3", ".", "0", "-", ")", "star_expr", ":", "*", "expr" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1463-L1466
[ "def", "star_expr__32", "(", "self", ",", "star_loc", ",", "expr", ")", ":", "return", "ast", ".", "Starred", "(", "value", "=", "expr", ",", "ctx", "=", "None", ",", "star_loc", "=", "star_loc", ",", "loc", "=", "expr", ".", "loc", ".", "join", "(...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.power
power: atom trailer* ['**' factor]
third_party/pythonparser/parser.py
def power(self, atom, trailers, factor_opt): """power: atom trailer* ['**' factor]""" for trailer in trailers: if isinstance(trailer, ast.Attribute) or isinstance(trailer, ast.Subscript): trailer.value = atom elif isinstance(trailer, ast.Call): tra...
def power(self, atom, trailers, factor_opt): """power: atom trailer* ['**' factor]""" for trailer in trailers: if isinstance(trailer, ast.Attribute) or isinstance(trailer, ast.Subscript): trailer.value = atom elif isinstance(trailer, ast.Call): tra...
[ "power", ":", "atom", "trailer", "*", "[", "**", "factor", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1508-L1521
[ "def", "power", "(", "self", ",", "atom", ",", "trailers", ",", "factor_opt", ")", ":", "for", "trailer", "in", "trailers", ":", "if", "isinstance", "(", "trailer", ",", "ast", ".", "Attribute", ")", "or", "isinstance", "(", "trailer", ",", "ast", ".",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.subscriptlist
subscriptlist: subscript (',' subscript)* [',']
third_party/pythonparser/parser.py
def subscriptlist(self, subscripts): """subscriptlist: subscript (',' subscript)* [',']""" if len(subscripts) == 1: return ast.Subscript(slice=subscripts[0], ctx=None, loc=None) elif all([isinstance(x, ast.Index) for x in subscripts]): elts = [x.value for x in subscripts...
def subscriptlist(self, subscripts): """subscriptlist: subscript (',' subscript)* [',']""" if len(subscripts) == 1: return ast.Subscript(slice=subscripts[0], ctx=None, loc=None) elif all([isinstance(x, ast.Index) for x in subscripts]): elts = [x.value for x in subscripts...
[ "subscriptlist", ":", "subscript", "(", "subscript", ")", "*", "[", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1680-L1694
[ "def", "subscriptlist", "(", "self", ",", "subscripts", ")", ":", "if", "len", "(", "subscripts", ")", "==", "1", ":", "return", "ast", ".", "Subscript", "(", "slice", "=", "subscripts", "[", "0", "]", ",", "ctx", "=", "None", ",", "loc", "=", "Non...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.dictmaker
(2.6) dictmaker: test ':' test (',' test ':' test)* [',']
third_party/pythonparser/parser.py
def dictmaker(self, elts): """(2.6) dictmaker: test ':' test (',' test ':' test)* [',']""" return ast.Dict(keys=list(map(lambda x: x[0], elts)), values=list(map(lambda x: x[2], elts)), colon_locs=list(map(lambda x: x[1], elts)), loc...
def dictmaker(self, elts): """(2.6) dictmaker: test ':' test (',' test ':' test)* [',']""" return ast.Dict(keys=list(map(lambda x: x[0], elts)), values=list(map(lambda x: x[2], elts)), colon_locs=list(map(lambda x: x[1], elts)), loc...
[ "(", "2", ".", "6", ")", "dictmaker", ":", "test", ":", "test", "(", "test", ":", "test", ")", "*", "[", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1748-L1753
[ "def", "dictmaker", "(", "self", ",", "elts", ")", ":", "return", "ast", ".", "Dict", "(", "keys", "=", "list", "(", "map", "(", "lambda", "x", ":", "x", "[", "0", "]", ",", "elts", ")", ")", ",", "values", "=", "list", "(", "map", "(", "lamb...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.classdef__26
(2.6, 2.7) classdef: 'class' NAME ['(' [testlist] ')'] ':' suite
third_party/pythonparser/parser.py
def classdef__26(self, class_loc, name_tok, bases_opt, colon_loc, body): """(2.6, 2.7) classdef: 'class' NAME ['(' [testlist] ')'] ':' suite""" bases, lparen_loc, rparen_loc = [], None, None if bases_opt: lparen_loc, bases, rparen_loc = bases_opt return ast.ClassDef(name=nam...
def classdef__26(self, class_loc, name_tok, bases_opt, colon_loc, body): """(2.6, 2.7) classdef: 'class' NAME ['(' [testlist] ')'] ':' suite""" bases, lparen_loc, rparen_loc = [], None, None if bases_opt: lparen_loc, bases, rparen_loc = bases_opt return ast.ClassDef(name=nam...
[ "(", "2", ".", "6", "2", ".", "7", ")", "classdef", ":", "class", "NAME", "[", "(", "[", "testlist", "]", ")", "]", ":", "suite" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1793-L1805
[ "def", "classdef__26", "(", "self", ",", "class_loc", ",", "name_tok", ",", "bases_opt", ",", "colon_loc", ",", "body", ")", ":", "bases", ",", "lparen_loc", ",", "rparen_loc", "=", "[", "]", ",", "None", ",", "None", "if", "bases_opt", ":", "lparen_loc"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.classdef__30
(3.0) classdef: 'class' NAME ['(' [testlist] ')'] ':' suite
third_party/pythonparser/parser.py
def classdef__30(self, class_loc, name_tok, arglist_opt, colon_loc, body): """(3.0) classdef: 'class' NAME ['(' [testlist] ')'] ':' suite""" arglist, lparen_loc, rparen_loc = [], None, None bases, keywords, starargs, kwargs = [], [], None, None star_loc, dstar_loc = None, None if...
def classdef__30(self, class_loc, name_tok, arglist_opt, colon_loc, body): """(3.0) classdef: 'class' NAME ['(' [testlist] ')'] ':' suite""" arglist, lparen_loc, rparen_loc = [], None, None bases, keywords, starargs, kwargs = [], [], None, None star_loc, dstar_loc = None, None if...
[ "(", "3", ".", "0", ")", "classdef", ":", "class", "NAME", "[", "(", "[", "testlist", "]", ")", "]", ":", "suite" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1810-L1827
[ "def", "classdef__30", "(", "self", ",", "class_loc", ",", "name_tok", ",", "arglist_opt", ",", "colon_loc", ",", "body", ")", ":", "arglist", ",", "lparen_loc", ",", "rparen_loc", "=", "[", "]", ",", "None", ",", "None", "bases", ",", "keywords", ",", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.arglist
arglist: (argument ',')* (argument [','] | '*' test (',' argument)* [',' '**' test] | '**' test)
third_party/pythonparser/parser.py
def arglist(self, args, call): """arglist: (argument ',')* (argument [','] | '*' test (',' argument)* [',' '**' test] | '**' test)""" for arg in args: if isinstance(arg, ast.keyword): call.keywords.appe...
def arglist(self, args, call): """arglist: (argument ',')* (argument [','] | '*' test (',' argument)* [',' '**' test] | '**' test)""" for arg in args: if isinstance(arg, ast.keyword): call.keywords.appe...
[ "arglist", ":", "(", "argument", ")", "*", "(", "argument", "[", "]", "|", "*", "test", "(", "argument", ")", "*", "[", "**", "test", "]", "|", "**", "test", ")" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1869-L1883
[ "def", "arglist", "(", "self", ",", "args", ",", "call", ")", ":", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "ast", ".", "keyword", ")", ":", "call", ".", "keywords", ".", "append", "(", "arg", ")", "elif", "len", "(",...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.yield_expr__26
(2.6, 2.7, 3.0, 3.1, 3.2) yield_expr: 'yield' [testlist]
third_party/pythonparser/parser.py
def yield_expr__26(self, yield_loc, exprs): """(2.6, 2.7, 3.0, 3.1, 3.2) yield_expr: 'yield' [testlist]""" if exprs is not None: return ast.Yield(value=exprs, yield_loc=yield_loc, loc=yield_loc.join(exprs.loc)) else: return ast.Yield(value=Non...
def yield_expr__26(self, yield_loc, exprs): """(2.6, 2.7, 3.0, 3.1, 3.2) yield_expr: 'yield' [testlist]""" if exprs is not None: return ast.Yield(value=exprs, yield_loc=yield_loc, loc=yield_loc.join(exprs.loc)) else: return ast.Yield(value=Non...
[ "(", "2", ".", "6", "2", ".", "7", "3", ".", "0", "3", ".", "1", "3", ".", "2", ")", "yield_expr", ":", "yield", "[", "testlist", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1988-L1995
[ "def", "yield_expr__26", "(", "self", ",", "yield_loc", ",", "exprs", ")", ":", "if", "exprs", "is", "not", "None", ":", "return", "ast", ".", "Yield", "(", "value", "=", "exprs", ",", "yield_loc", "=", "yield_loc", ",", "loc", "=", "yield_loc", ".", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
Parser.yield_expr__33
(3.3-) yield_expr: 'yield' [yield_arg]
third_party/pythonparser/parser.py
def yield_expr__33(self, yield_loc, arg): """(3.3-) yield_expr: 'yield' [yield_arg]""" if isinstance(arg, ast.YieldFrom): arg.yield_loc = yield_loc arg.loc = arg.loc.join(arg.yield_loc) return arg elif arg is not None: return ast.Yield(value=arg, ...
def yield_expr__33(self, yield_loc, arg): """(3.3-) yield_expr: 'yield' [yield_arg]""" if isinstance(arg, ast.YieldFrom): arg.yield_loc = yield_loc arg.loc = arg.loc.join(arg.yield_loc) return arg elif arg is not None: return ast.Yield(value=arg, ...
[ "(", "3", ".", "3", "-", ")", "yield_expr", ":", "yield", "[", "yield_arg", "]" ]
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/pythonparser/parser.py#L1998-L2009
[ "def", "yield_expr__33", "(", "self", ",", "yield_loc", ",", "arg", ")", ":", "if", "isinstance", "(", "arg", ",", "ast", ".", "YieldFrom", ")", ":", "arg", ".", "yield_loc", "=", "yield_loc", "arg", ".", "loc", "=", "arg", ".", "loc", ".", "join", ...
3ec87959189cfcdeae82eb68a47648ac25ceb10b
valid
urlparse
Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.
third_party/stdlib/urlparse.py
def urlparse(url, scheme='', allow_fragments=True): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) ...
def urlparse(url, scheme='', allow_fragments=True): """Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) ...
[ "Parse", "a", "URL", "into", "6", "components", ":", "<scheme", ">", ":", "//", "<netloc", ">", "/", "<path", ">", ";", "<params", ">", "?<query", ">", "#<fragment", ">", "Return", "a", "6", "-", "tuple", ":", "(", "scheme", "netloc", "path", "params...
google/grumpy
python
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/urlparse.py#L259-L271
[ "def", "urlparse", "(", "url", ",", "scheme", "=", "''", ",", "allow_fragments", "=", "True", ")", ":", "tuple", "=", "urlsplit", "(", "url", ",", "scheme", ",", "allow_fragments", ")", "scheme", ",", "netloc", ",", "url", ",", "query", ",", "fragment"...
3ec87959189cfcdeae82eb68a47648ac25ceb10b