path
stringlengths
14
112
content
stringlengths
0
6.32M
size
int64
0
6.32M
max_lines
int64
1
100k
repo_name
stringclasses
2 values
autogenerated
bool
1 class
cosmopolitan/third_party/python/Lib/lib2to3/tests/data/fixers/myfixes/fix_preorder.py
from lib2to3.fixer_base import BaseFix class FixPreorder(BaseFix): order = "pre" def match(self, node): return False
127
7
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/tests/data/fixers/myfixes/__init__.py
0
1
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/tests/data/fixers/myfixes/fix_first.py
from lib2to3.fixer_base import BaseFix class FixFirst(BaseFix): run_order = 1 def match(self, node): return False
124
7
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/tokenize.py
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation. # All rights reserved. """Tokenization help for Python programs. generate_tokens(readline) is a generator that breaks a stream of text into Python tokens. It accepts a readline-like method which is called repeatedly to get the next line o...
22,606
591
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/pgen.py
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. # Pgen imports from . import grammar, token, tokenize class PgenGrammar(grammar.Grammar): pass class ParserGenerator(object): def __init__(self, filename, stream=None): close_stream =...
13,812
387
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/grammar.py
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """This module defines the data structures used to represent a grammar. These are a bit arcane because they are derived from the data structures used by Python's 'pgen' parser generator. There's also ...
6,589
212
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/parse.py
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Parser engine for the grammar tables generated by pgen. The grammar table must be loaded first. See Parser/parser.c in the Python distribution for additional info on how this parsing engine works. ...
8,053
202
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/token.py
#! /usr/bin/env python3 """Token constants (from "token.h").""" # Taken from Python (r53757) and modified to include some tokens # originally monkeypatched in by pgen2.tokenize #--start constants-- ENDMARKER = 0 NAME = 1 NUMBER = 2 STRING = 3 NEWLINE = 4 INDENT = 5 DEDENT = 6 LPAR = 7 RPAR = 8 LSQB = 9 RSQB = 10 ...
1,286
86
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/literals.py
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Safely evaluate Python string literals without using eval().""" import re simple_escapes = {"a": "\a", "b": "\b", "f": "\f", "n": "\n", ...
1,615
61
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/conv.py
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Convert graminit.[ch] spit out by pgen to Python code. Pgen is the Python parser generator. It is useful to quickly create a parser from a grammar file in Python's grammar notation. But I don't wa...
9,696
258
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/driver.py
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. # Modifications: # Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Parser driver. This provides a high-level interface to parse a file into a synta...
6,028
182
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/pgen2/__init__.py
# Copyright 2004-2005 Elemental Security, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """The pgen2 package."""
143
5
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_standarderror.py
# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for StandardError -> Exception.""" # Local imports from .. import fixer_base from ..fixer_util import Name class FixStandarderror(fixer_base.BaseFix): BM_compatible = True PATTERN = """ ...
449
19
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_print.py
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for print. Change: 'print' into 'print()' 'print ...' into 'print(...)' 'print ... ,' into 'print(..., end=" ")' 'print >>x, ...' into 'print(..., file=x)' No changes are appl...
2,844
88
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_dict.py
# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for dict methods. d.keys() -> list(d.keys()) d.items() -> list(d.items()) d.values() -> list(d.values()) d.iterkeys() -> iter(d.keys()) d.iteritems() -> iter(d.items()) d.itervalues() -> iter(d.values()) d.v...
3,760
107
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_throw.py
"""Fixer for generator.throw(E, V, T). g.throw(E) -> g.throw(E) g.throw(E, V) -> g.throw(E(V)) g.throw(E, V, T) -> g.throw(E(V).with_traceback(T)) g.throw("foo"[, V[, T]]) will warn about string exceptions.""" # Author: Collin Winter # Local imports from .. import pytree from ..pgen2 import token from .. im...
1,582
57
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_import.py
"""Fixer for import statements. If spam is being imported from the local directory, this import: from spam import eggs Becomes: from .spam import eggs And this import: import spam Becomes: from . import spam """ # Local imports from .. import fixer_base from os.path import dirname, join, exists, sep f...
3,256
100
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_reduce.py
# Copyright 2008 Armin Ronacher. # Licensed to PSF under a Contributor Agreement. """Fixer for reduce(). Makes sure reduce() is imported from the functools module if reduce is used in that module. """ from lib2to3 import fixer_base from lib2to3.fixer_util import touch_import class FixReduce(fixer_base.BaseFix): ...
837
36
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_nonzero.py
"""Fixer for __nonzero__ -> __bool__ methods.""" # Author: Collin Winter # Local imports from .. import fixer_base from ..fixer_util import Name class FixNonzero(fixer_base.BaseFix): BM_compatible = True PATTERN = """ classdef< 'class' any+ ':' suite< any* funcdef< 'def'...
591
22
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_itertools.py
""" Fixer for itertools.(imap|ifilter|izip) --> (map|filter|zip) and itertools.ifilterfalse --> itertools.filterfalse (bugs 2360-2363) imports from itertools are fixed in fix_itertools_import.py If itertools is imported as something else (ie: import itertools as it; it.izip(spam, eggs)) method calls w...
1,548
44
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_buffer.py
# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that changes buffer(...) into memoryview(...).""" # Local imports from .. import fixer_base from ..fixer_util import Name class FixBuffer(fixer_base.BaseFix): BM_compatible = True explicit = True # ...
590
23
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_itertools_imports.py
""" Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """ # Local imports from lib2to3 import fixer_base from lib2to3.fixer_util import BlankLine, syms, token class FixItertoolsImports(fixer_base.BaseFix): BM_compatible = True PATTERN = """ import_from< 'from' 'itertools' 'import'...
2,086
58
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_exitfunc.py
""" Convert use of sys.exitfunc to use the atexit module. """ # Author: Benjamin Peterson from lib2to3 import pytree, fixer_base from lib2to3.fixer_util import Name, Attr, Call, Comma, Newline, syms class FixExitfunc(fixer_base.BaseFix): keep_line_order = True BM_compatible = True PATTERN = """ ...
2,495
73
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_paren.py
"""Fixer that addes parentheses where they are required This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``.""" # By Taek Joo Kim and Benjamin Peterson # Local imports from .. import fixer_base from ..fixer_util import LParen, RParen # XXX This doesn't support nested for loops like [x for x in 1, 2 for x...
1,227
45
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_xreadlines.py
"""Fix "for x in f.xreadlines()" -> "for x in f". This fixer will also convert g(f.xreadlines) into g(f.__iter__).""" # Author: Collin Winter # Local imports from .. import fixer_base from ..fixer_util import Name class FixXreadlines(fixer_base.BaseFix): BM_compatible = True PATTERN = """ power< call=an...
689
26
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_set_literal.py
""" Optional fixer to transform set() calls to set literals. """ # Author: Benjamin Peterson from lib2to3 import fixer_base, pytree from lib2to3.fixer_util import token, syms class FixSetLiteral(fixer_base.BaseFix): BM_compatible = True explicit = True PATTERN = """power< 'set' trailer< '(' ...
1,697
54
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_ws_comma.py
"""Fixer that changes 'a ,b' into 'a, b'. This also changes '{a :b}' into '{a: b}', but does not touch other uses of colons. It does not touch other uses of whitespace. """ from .. import pytree from ..pgen2 import token from .. import fixer_base class FixWsComma(fixer_base.BaseFix): explicit = True # The use...
1,090
40
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_reload.py
"""Fixer for reload(). reload(s) -> imp.reload(s)""" # Local imports from .. import fixer_base from ..fixer_util import ImportAndCall, touch_import class FixReload(fixer_base.BaseFix): BM_compatible = True order = "pre" PATTERN = """ power< 'reload' trailer< lpar='(' ...
1,154
39
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_ne.py
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that turns <> into !=.""" # Local imports from .. import pytree from ..pgen2 import token from .. import fixer_base class FixNe(fixer_base.BaseFix): # This is so simple that we don't need the pattern com...
571
24
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_urllib.py
"""Fix changes imports of urllib which are now incompatible. This is rather similar to fix_imports, but because of the more complex nature of the fixing for urllib, it has its own fixer. """ # Author: Nick Edds # Local imports from lib2to3.fixes.fix_imports import alternates, FixImports from lib2to3.fixer_util i...
8,353
197
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_renames.py
"""Fix incompatible renames Fixes: * sys.maxint -> sys.maxsize """ # Author: Christian Heimes # based on Collin Winter's fix_import # Local imports from .. import fixer_base from ..fixer_util import Name, attr_chain MAPPING = {"sys": {"maxint" : "maxsize"}, } LOOKUP = {} def alternates(members): re...
2,221
71
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_basestring.py
"""Fixer for basestring -> str.""" # Author: Christian Heimes # Local imports from .. import fixer_base from ..fixer_util import Name class FixBasestring(fixer_base.BaseFix): BM_compatible = True PATTERN = "'basestring'" def transform(self, node, results): return Name("str", prefix=node.prefix)
320
15
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_sys_exc.py
"""Fixer for sys.exc_{type, value, traceback} sys.exc_type -> sys.exc_info()[0] sys.exc_value -> sys.exc_info()[1] sys.exc_traceback -> sys.exc_info()[2] """ # By Jeff Balogh and Benjamin Peterson # Local imports from .. import fixer_base from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms clas...
1,034
31
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_future.py
"""Remove __future__ imports from __future__ import foo is replaced with an empty line. """ # Author: Christian Heimes # Local imports from .. import fixer_base from ..fixer_util import BlankLine class FixFuture(fixer_base.BaseFix): BM_compatible = True PATTERN = """import_from< 'from' module_name="__future...
547
23
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_execfile.py
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for execfile. This converts usages of the execfile function into calls to the built-in exec() function. """ from .. import fixer_base from ..fixer_util import (Comma, Name, Call, LParen, RParen, Dot, Node, ...
2,048
54
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_has_key.py
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for has_key(). Calls to .has_key() methods are expressed in terms of the 'in' operator: d.has_key(k) -> k in d CAVEATS: 1) While the primary target of this fixer is dict.has_key(), the fixer will chan...
3,196
110
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_long.py
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that turns 'long' into 'int' everywhere. """ # Local imports from lib2to3 import fixer_base from lib2to3.fixer_util import is_probably_builtin class FixLong(fixer_base.BaseFix): BM_compatible = True ...
476
20
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_exec.py
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for exec. This converts usages of the exec statement into calls to a built-in exec() function. exec code in ns1, ns2 -> exec(code, ns1, ns2) """ # Local imports from .. import fixer_base from ..fixer_util im...
979
40
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_raise.py
"""Fixer for 'raise E, V, T' raise -> raise raise E -> raise E raise E, V -> raise E(V) raise E, V, T -> raise E(V).with_traceback(T) raise E, None, T -> raise E.with_traceback(T) raise (((E, E'), E''), E'''), V -> raise E(V) raise "foo", V, T -> warns about string exceptions CAVEATS:...
2,926
91
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_isinstance.py
# Copyright 2008 Armin Ronacher. # Licensed to PSF under a Contributor Agreement. """Fixer that cleans up a tuple argument to isinstance after the tokens in it were fixed. This is mainly used to remove double occurrences of tokens as a leftover of the long -> int / unicode -> str conversion. eg. isinstance(x, (int,...
1,608
53
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_apply.py
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for apply(). This converts apply(func, v, k) into (func)(*v, **k).""" # Local imports from .. import pytree from ..pgen2 import token from .. import fixer_base from ..fixer_util import Call, Comma, parenthesi...
2,430
71
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_metaclass.py
"""Fixer for __metaclass__ = X -> (metaclass=X) methods. The various forms of classef (inherits nothing, inherits once, inherints many) don't parse the same in the CST so we look at ALL classes for a __metaclass__ and if we find one normalize the inherits to all be an arglist. For one-liner classes ('c...
8,197
229
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_asserts.py
"""Fixer that replaces deprecated unittest method names.""" # Author: Ezio Melotti from ..fixer_base import BaseFix from ..fixer_util import Name NAMES = dict( assert_="assertTrue", assertEquals="assertEqual", assertNotEquals="assertNotEqual", assertAlmostEquals="assertAlmostEqual", assertNotAlmo...
984
35
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_methodattrs.py
"""Fix bound method attributes (method.im_? -> method.__?__). """ # Author: Christian Heimes # Local imports from .. import fixer_base from ..fixer_util import Name MAP = { "im_func" : "__func__", "im_self" : "__self__", "im_class" : "__self__.__class__" } class FixMethodattrs(fixer_base.BaseFix): ...
606
25
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_operator.py
"""Fixer for operator functions. operator.isCallable(obj) -> hasattr(obj, '__call__') operator.sequenceIncludes(obj) -> operator.contains(obj) operator.isSequenceType(obj) -> isinstance(obj, collections.Sequence) operator.isMappingType(obj) -> isinstance(obj, collections.Mapping) operator.isNumberType(obj) ...
3,471
99
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_intern.py
# Copyright 2006 Georg Brandl. # Licensed to PSF under a Contributor Agreement. """Fixer for intern(). intern(s) -> sys.intern(s)""" # Local imports from .. import fixer_base from ..fixer_util import ImportAndCall, touch_import class FixIntern(fixer_base.BaseFix): BM_compatible = True order = "pre" PA...
1,235
42
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_getcwdu.py
""" Fixer that changes os.getcwdu() to os.getcwd(). """ # Author: Victor Stinner # Local imports from .. import fixer_base from ..fixer_util import Name class FixGetcwdu(fixer_base.BaseFix): BM_compatible = True PATTERN = """ power< 'os' trailer< dot='.' name='getcwdu' > any* > ""...
451
20
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_repr.py
# Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that transforms `xyzzy` into repr(xyzzy).""" # Local imports from .. import fixer_base from ..fixer_util import Call, Name, parenthesize class FixRepr(fixer_base.BaseFix): BM_compatible = True PATTE...
613
24
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_raw_input.py
"""Fixer that changes raw_input(...) into input(...).""" # Author: Andre Roberge # Local imports from .. import fixer_base from ..fixer_util import Name class FixRawInput(fixer_base.BaseFix): BM_compatible = True PATTERN = """ power< name='raw_input' trailer< '(' [any] ')' > any* > ...
454
18
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_input.py
"""Fixer that changes input(...) into eval(input(...)).""" # Author: Andre Roberge # Local imports from .. import fixer_base from ..fixer_util import Call, Name from .. import patcomp context = patcomp.compile_pattern("power< 'eval' trailer< '(' any ')' > >") class FixInput(fixer_base.BaseFix): BM_compatible =...
708
27
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_types.py
# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer for removing uses of the types module. These work for only the known names in the types module. The forms above can include types. or not. ie, It is assumed the module is imported either as: import type...
1,774
62
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_next.py
"""Fixer for it.next() -> next(it), per PEP 3114.""" # Author: Collin Winter # Things that currently aren't covered: # - listcomp "next" names aren't warned # - "with" statement targets aren't checked # Local imports from ..pgen2 import token from ..pygram import python_symbols as syms from .. import fixer_base f...
3,174
104
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_imports2.py
"""Fix incompatible imports and module references that must be fixed after fix_imports.""" from . import fix_imports MAPPING = { 'whichdb': 'dbm', 'anydbm': 'dbm', } class FixImports2(fix_imports.FixImports): run_order = 7 mapping = MAPPING
289
17
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_filter.py
# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that changes filter(F, X) into list(filter(F, X)). We avoid the transformation if the filter() call is directly contained in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:. NOTE: This...
2,651
91
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_idioms.py
"""Adjust some old Python 2 idioms to their modern counterparts. * Change some type comparisons to isinstance() calls: type(x) == T -> isinstance(x, T) type(x) is T -> isinstance(x, T) type(x) != T -> not isinstance(x, T) type(x) is not T -> not isinstance(x, T) * Change "while 1:" into "while True:"....
4,876
153
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_zip.py
""" Fixer that changes zip(seq0, seq1, ...) into list(zip(seq0, seq1, ...) unless there exists a 'from future_builtins import zip' statement in the top-level namespace. We avoid the transformation if the zip() call is directly contained in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:. """ #...
1,289
47
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_imports.py
"""Fix incompatible imports and module references.""" # Authors: Collin Winter, Nick Edds # Local imports from .. import fixer_base from ..fixer_util import Name, attr_chain MAPPING = {'StringIO': 'io', 'cStringIO': 'io', 'cPickle': 'pickle', '__builtin__' : 'builtins', 'c...
5,684
146
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_unicode.py
r"""Fixer for unicode. * Changes unicode to str and unichr to chr. * If "...\u..." is not unicode literal change it into "...\\u...". * Change u"..." into "...". """ from ..pgen2 import token from .. import fixer_base _mapping = {"unichr" : "chr", "unicode" : "str"} class FixUnicode(fixer_base.BaseFix): BM_c...
1,256
43
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_except.py
"""Fixer for except statements with named exceptions. The following cases will be converted: - "except E, T:" where T is a name: except E as T: - "except E, T:" where T is not a name, tuple or list: except E as t: T = t This is done because the target of an "except" clause must be a ...
3,344
94
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_funcattrs.py
"""Fix function attribute names (f.func_x -> f.__x__).""" # Author: Collin Winter # Local imports from .. import fixer_base from ..fixer_util import Name class FixFuncattrs(fixer_base.BaseFix): BM_compatible = True PATTERN = """ power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals'...
644
22
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_tuple_params.py
"""Fixer for function definitions with tuple parameters. def func(((a, b), c), d): ... -> def func(x, d): ((a, b), c) = x ... It will also support lambdas: lambda (x, y): x + y -> lambda t: t[0] + t[1] # The parens are a syntax error in Python 3 lambda (x): x + y -> lambda x: x + y """...
5,565
176
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_numliterals.py
"""Fixer that turns 1L into 1, 0755 into 0o755. """ # Copyright 2007 Georg Brandl. # Licensed to PSF under a Contributor Agreement. # Local imports from ..pgen2 import token from .. import fixer_base from ..fixer_util import Number class FixNumliterals(fixer_base.BaseFix): # This is so simple that we don't need ...
768
29
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_map.py
# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that changes map(F, ...) into list(map(F, ...)) unless there exists a 'from future_builtins import map' statement in the top-level namespace. As a special case, map(None, X) is changed into list(X). (This is ...
3,640
111
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/__init__.py
# Dummy file to make this directory a package.
47
2
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/lib2to3/fixes/fix_xrange.py
# Copyright 2007 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. """Fixer that changes xrange(...) into range(...).""" # Local imports from .. import fixer_base from ..fixer_util import Name, Call, consuming_calls from .. import patcomp class FixXrange(fixer_base.BaseFix): BM_...
2,694
74
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/json/scanner.py
"""JSON token scanner """ import re try: from _json import make_scanner as c_make_scanner except ImportError: c_make_scanner = None if __name__ == 'PYOBJ.COM': import _json __all__ = ['make_scanner'] NUMBER_RE = re.compile( r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?', (re.VERBOSE | re.MULTILINE |...
2,460
76
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/json/decoder.py
"""Implementation of JSONDecoder """ import re from json import scanner try: from _json import scanstring as c_scanstring except ImportError: c_scanstring = None if __name__ == 'PYOBJ.COM': import _json __all__ = ['JSONDecoder', 'JSONDecodeError'] FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL NaN = floa...
12,630
361
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/json/encoder.py
"""Implementation of JSONEncoder """ import re try: from _json import encode_basestring_ascii as c_encode_basestring_ascii except ImportError: c_encode_basestring_ascii = None try: from _json import encode_basestring as c_encode_basestring except ImportError: c_encode_basestring = None try: from _j...
16,065
444
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/json/__init__.py
r"""JSON (JavaScript Object Notation) <http://json.org> is a subset of JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data interchange format. :mod:`json` exposes an API familiar to users of the standard library :mod:`marshal` and :mod:`pickle` modules. It is derived from a version of the externally m...
14,396
368
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/json/tool.py
r"""Command-line tool to validate and pretty-print JSON Usage:: $ echo '{"json":"obj"}' | python -m json.tool { "json": "obj" } $ echo '{ 1.2:3.4}' | python -m json.tool Expecting property name enclosed in double quotes: line 1 column 3 (char 2) """ import argparse import collections impo...
1,645
51
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/http/cookiejar.py
r"""HTTP cookie handling for web clients. This module has (now fairly distant) origins in Gisle Aas' Perl module HTTP::Cookies, from the libwww-perl library. Docstrings, comments and debug strings in this code refer to the attributes of the HTTP cookie system as cookie-attributes, to distinguish them clearly from Pyt...
76,869
2,118
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/http/client.py
r"""HTTP/1.1 client library <intro stuff goes here> <other stuff, too> HTTPConnection goes through a number of "states", which define when a client may legally make another request or fetch the response for a particular request. This diagram details these state transitions: (null) │ │ HTTPConnect...
55,660
1,506
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/http/server.py
"""HTTP server classes. Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST, and CGIHTTPRequestHandler for CGI scripts. It does, however, optionally implement HTTP/1.1 persistent connections, as of version 0.3. Notes on CGIHTT...
43,830
1,213
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/http/cookies.py
#### # Copyright 2000 by Timothy O'Malley <timo@alum.mit.edu> # # All Rights Reserved # # Permission to use, copy, modify, and distribute this software # and its documentation for any purpose and without fee is hereby # granted, provided that the above copyright notice appear in all # copies and that bot...
21,390
638
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/http/__init__.py
from enum import IntEnum __all__ = ['HTTPStatus'] class HTTPStatus(IntEnum): """HTTP status codes and reason phrases Status codes from the following RFCs are all observed: * RFC 7231: Hypertext Transfer Protocol (HTTP/1.1), obsoletes 2616 * RFC 6585: Additional HTTP Status Codes * RF...
5,953
135
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/cp273.py
""" Python Character Mapping Codec cp273 generated from 'python-mappings/CP273.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='strict...
14,132
308
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/base64_codec.py
"""Python 'base64_codec' Codec - base64 content transfer encoding. This codec de/encodes from bytes to bytes. Written by Marc-Andre Lemburg (mal@lemburg.com). """ import codecs import base64 ### Codec APIs def base64_encode(input, errors='strict'): assert errors == 'strict' return (base64.encodebytes(input...
1,533
56
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/bz2_codec.py
"""Python 'bz2_codec' Codec - bz2 compression encoding. This codec de/encodes from bytes to bytes and is therefore usable with bytes.transform() and bytes.untransform(). Adapted by Raymond Hettinger from zlib_codec.py which was written by Marc-Andre Lemburg (mal@lemburg.com). """ import codecs import bz2 # this code...
2,249
79
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/ptcp154.py
""" Python Character Mapping Codec generated from 'PTCP154.txt' with gencodec.py. Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. (c) Copyright 2000 Guido van Rossum. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,err...
14,015
313
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/cp1140.py
""" Python Character Mapping Codec cp1140 generated from 'python-mappings/CP1140.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='stri...
13,105
308
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/iso8859_14.py
""" Python Character Mapping Codec iso8859_14 generated from 'MAPPINGS/ISO8859/8859-14.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors...
13,652
308
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/mac_cyrillic.py
""" Python Character Mapping Codec mac_cyrillic generated from 'MAPPINGS/VENDORS/APPLE/CYRILLIC.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,inp...
13,454
308
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/mac_iceland.py
""" Python Character Mapping Codec mac_iceland generated from 'MAPPINGS/VENDORS/APPLE/ICELAND.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input...
13,498
308
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/koi8_u.py
""" Python Character Mapping Codec koi8_u generated from 'python-mappings/KOI8-U.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,input,errors='stri...
13,762
308
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/palmos.py
""" Python Character Mapping Codec for PalmOS 3.5. Written by Sjoerd Mullender (sjoerd@acm.org); based on iso8859_15.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,i...
13,519
309
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/utf_32_le.py
""" Python 'utf-32-le' Codec """ import codecs ### Codec APIs encode = codecs.utf_32_le_encode def decode(input, errors='strict'): return codecs.utf_32_le_decode(input, errors, True) class IncrementalEncoder(codecs.IncrementalEncoder): def encode(self, input, final=False): return codecs.utf_32_le_en...
930
38
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/cp1258.py
""" Python Character Mapping Codec cp1258 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1258.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,in...
13,364
308
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/cp852.py
""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP852.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): ...
35,002
699
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/euc_jp.py
# # euc_jp.py: Python Unicode Codec for EUC_JP # # Written by Hye-Shik Chang <perky@FreeBSD.org> # import _codecs_jp, codecs import _multibytecodec as mbc codec = _codecs_jp.getcodec('euc_jp') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class IncrementalEncoder(mbc.MultibyteIncrem...
1,027
40
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/iso2022_jp_2004.py
# # iso2022_jp_2004.py: Python Unicode Codec for ISO2022_JP_2004 # # Written by Hye-Shik Chang <perky@FreeBSD.org> # import _codecs_iso2022, codecs import _multibytecodec as mbc codec = _codecs_iso2022.getcodec('iso2022_jp_2004') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class I...
1,073
40
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/cp858.py
""" Python Character Mapping Codec for CP858, modified from cp850. """ import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): return codecs.charmap_decod...
34,015
699
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/koi8_t.py
""" Python Character Mapping Codec koi8_t """ # http://ru.wikipedia.org/wiki/КОИ-8 # http://www.opensource.apple.com/source/libiconv/libiconv-4/libiconv/tests/KOI8-T.TXT import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,...
13,193
309
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/big5.py
# # big5.py: Python Unicode Codec for BIG5 # # Written by Hye-Shik Chang <perky@FreeBSD.org> # import _codecs_tw, codecs import _multibytecodec as mbc codec = _codecs_tw.getcodec('big5') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class IncrementalEncoder(mbc.MultibyteIncrementalE...
1,019
40
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/aliases.py
""" Encoding Aliases Support This module is used by the encodings package search function to map encodings names to module names. Note that the search function normalizes the encoding names before doing the lookup, so the mapping will have to map normalized encoding names to module names. Con...
15,577
551
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/cp1252.py
""" Python Character Mapping Codec cp1252 generated from 'MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_table) def decode(self,in...
13,511
308
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/utf_8_sig.py
""" Python 'utf-8-sig' Codec This work similar to UTF-8 with the following changes: * On encoding/writing a UTF-8 encoded BOM will be prepended/written as the first three bytes. * On decoding/reading if the first three bytes are a UTF-8 encoded BOM, these bytes will be skipped. """ import codecs ### Codec APIs ...
4,133
131
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/shift_jisx0213.py
# # shift_jisx0213.py: Python Unicode Codec for SHIFT_JISX0213 # # Written by Hye-Shik Chang <perky@FreeBSD.org> # import _codecs_jp, codecs import _multibytecodec as mbc codec = _codecs_jp.getcodec('shift_jisx0213') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class IncrementalEnc...
1,059
40
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/cp866.py
""" Python Character Mapping Codec generated from 'VENDORS/MICSFT/PC/CP866.TXT' with gencodec.py. """#" import codecs ### Codec APIs class Codec(codecs.Codec): def encode(self,input,errors='strict'): return codecs.charmap_encode(input,errors,encoding_map) def decode(self,input,errors='strict'): ...
34,396
699
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/ascii.py
""" Python 'ascii' Codec Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. """ import codecs ### Codec APIs class Codec(codecs.Codec): # Note: Binding these as C functions will result in the class not # converting them to methods. This is intended. ...
1,248
51
jart/cosmopolitan
false
cosmopolitan/third_party/python/Lib/encodings/euc_kr.py
# # euc_kr.py: Python Unicode Codec for EUC_KR # # Written by Hye-Shik Chang <perky@FreeBSD.org> # import _codecs_kr, codecs import _multibytecodec as mbc codec = _codecs_kr.getcodec('euc_kr') class Codec(codecs.Codec): encode = codec.encode decode = codec.decode class IncrementalEncoder(mbc.MultibyteIncrem...
1,027
40
jart/cosmopolitan
false