Search is not available for this dataset
text
stringlengths
75
104k
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 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 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 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 _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 _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 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 _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 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 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 _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 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 _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 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_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 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 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_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_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 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 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 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 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 _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 _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 _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 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 _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 _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 _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 _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 _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 _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 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 _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 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 _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 _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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 eval_input(self, expr): """eval_input: testlist NEWLINE* ENDMARKER""" return ast.Expression(body=[expr], loc=expr.loc)
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 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 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 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 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 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 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 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 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 yield_stmt(self, expr): """yield_stmt: yield_expr""" return ast.Expr(value=expr, loc=expr.loc)
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__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 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_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_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 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_name(self, idents): """dotted_name: NAME ('.' NAME)*""" return idents[0].loc.join(idents[-1].loc), \ ".".join(list(map(lambda x: x.value, idents)))
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 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 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 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 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 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 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 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 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__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_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 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 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 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 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__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 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 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 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 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__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 arglist(self, args, call): """arglist: (argument ',')* (argument [','] | '*' test (',' argument)* [',' '**' test] | '**' test)""" for arg in args: if isinstance(arg, ast.keyword): call.keywords.appe...
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__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 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) ...