diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/PatternGrammar3.10.16.final.0.pickle b/evalkit_cambrian/lib/python3.10/lib2to3/PatternGrammar3.10.16.final.0.pickle new file mode 100644 index 0000000000000000000000000000000000000000..e9de5e3aa351535c40c4d95139afac6eb97e675d --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/PatternGrammar3.10.16.final.0.pickle @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36ee934395b9209737b13893ddaff05fad8e239c2fdfac29d401d3fceeb30768 +size 1225 diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__init__.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b93054b3ecf3a5af96f4772e7208e7a18b5dd4a4 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__init__.py @@ -0,0 +1 @@ +# Dummy file to make this directory a package. diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_apply.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_apply.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ad404cdafd044d9c90e58252d40c074b6465d5cc Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_apply.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_asserts.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_asserts.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..adb7807b3b2cc3deb11d30e0d3cbcf691b83dd0c Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_asserts.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_basestring.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_basestring.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7b0a448960a4a06c1ce2986c146139e5f202042f Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_basestring.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_buffer.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_buffer.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4ebfd3f3c8d45045bf4c1b53e103cc0e4711e8ea Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_buffer.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_dict.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_dict.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4522ec209541d612ef192501984bc33cc6d190e Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_dict.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_except.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_except.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b17edd2f5482a8905851c18eca7b9de219a8cf28 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_except.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_execfile.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_execfile.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d574c28b07d0d9a4845b50650f5e019e22e82e06 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_execfile.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_filter.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_filter.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..46864ba954e7ba2f49bf79e1bd0dc13a917b4db3 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_filter.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_funcattrs.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_funcattrs.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..25ae92ea0c43980e3815e2473b5235c5eb28afbf Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_funcattrs.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_future.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_future.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1efa9076dd93ab7232bec55c7581ae194e517f58 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_future.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_getcwdu.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_getcwdu.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6be9f7a5e40977695fb554552273df89c49dd4be Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_getcwdu.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_idioms.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_idioms.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f06a1eaa1af650c4b2027e7ed64ac38147e7a6b1 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_idioms.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_import.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_import.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3c438b05315c5b2d45668b9e90c584affdb8fbae Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_import.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_imports2.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_imports2.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0271a6be83297eccd962738deadc0e9ef248a726 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_imports2.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_input.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_input.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1604884a58005e47b7c75763157f88fff4f5ce8c Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_input.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_intern.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_intern.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1e6bcb04227a37ffd657b32bad270d50b321585b Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_intern.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_isinstance.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_isinstance.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..410b720a15d6ebaea980d9070a21a40247884412 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_isinstance.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_itertools.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_itertools.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dec9d73822a6bd7b3a40f4f286fa88cf0beedea7 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_itertools.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_itertools_imports.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_itertools_imports.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b3ff11871b8702bcca96055c37e055585cfdd7b1 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_itertools_imports.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_long.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_long.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cc073f08262e27bbdedbcb00b60f37a9aeed02bc Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_long.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_map.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_map.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..06e8e0dfd82d23eee38a7e46b1d2b01b1a4843c0 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_map.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_metaclass.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_metaclass.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0b1849b9d4797eb5d807663ace4f7097322025a2 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_metaclass.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_methodattrs.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_methodattrs.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a0c91efa3e577c70934c616dd9eca7e05afbcd96 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_methodattrs.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_ne.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_ne.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..383892794a3d3032494bfd401663a4f3588700ea Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_ne.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_next.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_next.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ba3fcc04d803cc8f0a5d7bcce25981dae6d186e1 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_next.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_numliterals.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_numliterals.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1e77abd6742cfbf91b1f17b9c778ba8aa416b08f Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_numliterals.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_operator.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_operator.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ddfc507deec7340d04badf262ee7859cfc4a0db3 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_operator.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_paren.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_paren.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e3449436090f3a915ad67465ee69372db2049282 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_paren.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_print.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_print.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..83d257998c804a400b9f056276f6f53a03d419e3 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_print.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_raise.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_raise.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fd43def42816668908941a2e56d267019b538b67 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_raise.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_raw_input.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_raw_input.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..771f3e975defeee0329a43c4e2436426facaac82 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_raw_input.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_reduce.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_reduce.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9e295996a225354fbabea6674adc6f2df5b49f6a Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_reduce.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_renames.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_renames.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0bfd27f50551c108de019faa323dd821a2080a4a Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_renames.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_repr.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_repr.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cb22dbde327150d30df53f4f1744f1767a4fe659 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_repr.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_set_literal.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_set_literal.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..824edd173ec09335adfbb9e013d2f0dce983585f Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_set_literal.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_sys_exc.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_sys_exc.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..687904e423d381b1c4dd54e466d4129edba090ef Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_sys_exc.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_throw.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_throw.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..21a97a8e6b72fa2fd1f502a9745d491bdca2f842 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_throw.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_tuple_params.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_tuple_params.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..391a84700ec0a958b22696de34d3297891e68e0f Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_tuple_params.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_types.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_types.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a2b1f9bc33b2b5361771bc4e96fd7aeff836e33c Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_types.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_unicode.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_unicode.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6264706779e94cb7ab990ccec41b0b9e8b520742 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_unicode.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_urllib.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_urllib.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ae14dcfc37bda26bcc1b07c66dc7bf7ccad29ebb Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_urllib.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_ws_comma.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_ws_comma.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..285aaf58d8ca9ff0fbe904a9af2d84742800cb38 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_ws_comma.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_xrange.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_xrange.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9d6ce033d401cbe3408864205bac3a369eb76d91 Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_xrange.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_xreadlines.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_xreadlines.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2ca3d896840593b4d72ce6adb0a0566b739bd8bf Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_xreadlines.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_zip.cpython-310.pyc b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_zip.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b3da60f11c6f8ea2f1e139a5d7a6a73d9ecada1f Binary files /dev/null and b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/__pycache__/fix_zip.cpython-310.pyc differ diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_apply.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_apply.py new file mode 100644 index 0000000000000000000000000000000000000000..6408582c42647741416968f92c351a5581bc5e3e --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_apply.py @@ -0,0 +1,68 @@ +# 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, parenthesize + +class FixApply(fixer_base.BaseFix): + BM_compatible = True + + PATTERN = """ + power< 'apply' + trailer< + '(' + arglist< + (not argument + ')' + > + > + """ + + def transform(self, node, results): + syms = self.syms + assert results + func = results["func"] + args = results["args"] + kwds = results.get("kwds") + # I feel like we should be able to express this logic in the + # PATTERN above but I don't know how to do it so... + if args: + if (args.type == self.syms.argument and + args.children[0].value in {'**', '*'}): + return # Make no change. + if kwds and (kwds.type == self.syms.argument and + kwds.children[0].value == '**'): + return # Make no change. + prefix = node.prefix + func = func.clone() + if (func.type not in (token.NAME, syms.atom) and + (func.type != syms.power or + func.children[-2].type == token.DOUBLESTAR)): + # Need to parenthesize + func = parenthesize(func) + func.prefix = "" + args = args.clone() + args.prefix = "" + if kwds is not None: + kwds = kwds.clone() + kwds.prefix = "" + l_newargs = [pytree.Leaf(token.STAR, "*"), args] + if kwds is not None: + l_newargs.extend([Comma(), + pytree.Leaf(token.DOUBLESTAR, "**"), + kwds]) + l_newargs[-2].prefix = " " # that's the ** token + # XXX Sometimes we could be cleverer, e.g. apply(f, (x, y) + t) + # can be translated into f(x, y, *t) instead of f(*(x, y) + t) + #new = pytree.Node(syms.power, (func, ArgList(l_newargs))) + return Call(func, l_newargs, prefix=prefix) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_asserts.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_asserts.py new file mode 100644 index 0000000000000000000000000000000000000000..5bcec885f52cbf3a8a4a7bcf3331402a54f76967 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_asserts.py @@ -0,0 +1,34 @@ +"""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", + assertNotAlmostEquals="assertNotAlmostEqual", + assertRegexpMatches="assertRegex", + assertRaisesRegexp="assertRaisesRegex", + failUnlessEqual="assertEqual", + failIfEqual="assertNotEqual", + failUnlessAlmostEqual="assertAlmostEqual", + failIfAlmostEqual="assertNotAlmostEqual", + failUnless="assertTrue", + failUnlessRaises="assertRaises", + failIf="assertFalse", +) + + +class FixAsserts(BaseFix): + + PATTERN = """ + power< any+ trailer< '.' meth=(%s)> any* > + """ % '|'.join(map(repr, NAMES)) + + def transform(self, node, results): + name = results["meth"][0] + name.replace(Name(NAMES[str(name)], prefix=name.prefix)) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_except.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_except.py new file mode 100644 index 0000000000000000000000000000000000000000..49bd3d5ab7d6ccd8a98016a12b4ed54ff0c800de --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_except.py @@ -0,0 +1,93 @@ +"""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 + name. + +- "except E, T:" where T is a tuple or list literal: + + except E as t: + T = t.args +""" +# Author: Collin Winter + +# Local imports +from .. import pytree +from ..pgen2 import token +from .. import fixer_base +from ..fixer_util import Assign, Attr, Name, is_tuple, is_list, syms + +def find_excepts(nodes): + for i, n in enumerate(nodes): + if n.type == syms.except_clause: + if n.children[0].value == 'except': + yield (n, nodes[i+2]) + +class FixExcept(fixer_base.BaseFix): + BM_compatible = True + + PATTERN = """ + try_stmt< 'try' ':' (simple_stmt | suite) + cleanup=(except_clause ':' (simple_stmt | suite))+ + tail=(['except' ':' (simple_stmt | suite)] + ['else' ':' (simple_stmt | suite)] + ['finally' ':' (simple_stmt | suite)]) > + """ + + def transform(self, node, results): + syms = self.syms + + tail = [n.clone() for n in results["tail"]] + + try_cleanup = [ch.clone() for ch in results["cleanup"]] + for except_clause, e_suite in find_excepts(try_cleanup): + if len(except_clause.children) == 4: + (E, comma, N) = except_clause.children[1:4] + comma.replace(Name("as", prefix=" ")) + + if N.type != token.NAME: + # Generate a new N for the except clause + new_N = Name(self.new_name(), prefix=" ") + target = N.clone() + target.prefix = "" + N.replace(new_N) + new_N = new_N.clone() + + # Insert "old_N = new_N" as the first statement in + # the except body. This loop skips leading whitespace + # and indents + #TODO(cwinter) suite-cleanup + suite_stmts = e_suite.children + for i, stmt in enumerate(suite_stmts): + if isinstance(stmt, pytree.Node): + break + + # The assignment is different if old_N is a tuple or list + # In that case, the assignment is old_N = new_N.args + if is_tuple(N) or is_list(N): + assign = Assign(target, Attr(new_N, Name('args'))) + else: + assign = Assign(target, new_N) + + #TODO(cwinter) stopgap until children becomes a smart list + for child in reversed(suite_stmts[:i]): + e_suite.insert_child(0, child) + e_suite.insert_child(i, assign) + elif N.prefix == "": + # No space after a comma is legal; no space after "as", + # not so much. + N.prefix = " " + + #TODO(cwinter) fix this when children becomes a smart list + children = [c.clone() for c in node.children[:3]] + try_cleanup + tail + return pytree.Node(node.type, children) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_exec.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_exec.py new file mode 100644 index 0000000000000000000000000000000000000000..ab921ee80cdf366532f027b2549e5bcba55a4fd5 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_exec.py @@ -0,0 +1,39 @@ +# 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 import Comma, Name, Call + + +class FixExec(fixer_base.BaseFix): + BM_compatible = True + + PATTERN = """ + exec_stmt< 'exec' a=any 'in' b=any [',' c=any] > + | + exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any > + """ + + def transform(self, node, results): + assert results + syms = self.syms + a = results["a"] + b = results.get("b") + c = results.get("c") + args = [a.clone()] + args[0].prefix = "" + if b is not None: + args.extend([Comma(), b.clone()]) + if c is not None: + args.extend([Comma(), c.clone()]) + + return Call(Name("exec"), args, prefix=node.prefix) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_exitfunc.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_exitfunc.py new file mode 100644 index 0000000000000000000000000000000000000000..2e47887afead368518e7930397410335887d60f9 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_exitfunc.py @@ -0,0 +1,72 @@ +""" +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 = """ + ( + sys_import=import_name<'import' + ('sys' + | + dotted_as_names< (any ',')* 'sys' (',' any)* > + ) + > + | + expr_stmt< + power< 'sys' trailer< '.' 'exitfunc' > > + '=' func=any > + ) + """ + + def __init__(self, *args): + super(FixExitfunc, self).__init__(*args) + + def start_tree(self, tree, filename): + super(FixExitfunc, self).start_tree(tree, filename) + self.sys_import = None + + def transform(self, node, results): + # First, find the sys import. We'll just hope it's global scope. + if "sys_import" in results: + if self.sys_import is None: + self.sys_import = results["sys_import"] + return + + func = results["func"].clone() + func.prefix = "" + register = pytree.Node(syms.power, + Attr(Name("atexit"), Name("register")) + ) + call = Call(register, [func], node.prefix) + node.replace(call) + + if self.sys_import is None: + # That's interesting. + self.warning(node, "Can't find sys import; Please add an atexit " + "import at the top of your file.") + return + + # Now add an atexit import after the sys import. + names = self.sys_import.children[1] + if names.type == syms.dotted_as_names: + names.append_child(Comma()) + names.append_child(Name("atexit", " ")) + else: + containing_stmt = self.sys_import.parent + position = containing_stmt.children.index(self.sys_import) + stmt_container = containing_stmt.parent + new_import = pytree.Node(syms.import_name, + [Name("import"), Name("atexit", " ")] + ) + new = pytree.Node(syms.simple_stmt, [new_import]) + containing_stmt.insert_child(position + 1, Newline()) + containing_stmt.insert_child(position + 2, new) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_funcattrs.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_funcattrs.py new file mode 100644 index 0000000000000000000000000000000000000000..67f3e18e061bdb10395bf73e82f440ad6842e2bd --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_funcattrs.py @@ -0,0 +1,21 @@ +"""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' + | 'func_name' | 'func_defaults' | 'func_code' + | 'func_dict') > any* > + """ + + def transform(self, node, results): + attr = results["attr"][0] + attr.replace(Name(("__%s__" % attr.value[5:]), + prefix=attr.prefix)) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_future.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_future.py new file mode 100644 index 0000000000000000000000000000000000000000..fbcb86af0791338e4edebd2f68bd49cd7a9160c2 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_future.py @@ -0,0 +1,22 @@ +"""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__" 'import' any >""" + + # This should be run last -- some things check for the import + run_order = 10 + + def transform(self, node, results): + new = BlankLine() + new.prefix = node.prefix + return new diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_has_key.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_has_key.py new file mode 100644 index 0000000000000000000000000000000000000000..439708c9923404312dfabb964615062ea32c0aea --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_has_key.py @@ -0,0 +1,109 @@ +# 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 change any has_key() method call, regardless of its + class. + +2) Cases like this will not be converted: + + m = d.has_key + if m(k): + ... + + Only *calls* to has_key() are converted. While it is possible to + convert the above to something like + + m = d.__contains__ + if m(k): + ... + + this is currently not done. +""" + +# Local imports +from .. import pytree +from .. import fixer_base +from ..fixer_util import Name, parenthesize + + +class FixHasKey(fixer_base.BaseFix): + BM_compatible = True + + PATTERN = """ + anchor=power< + before=any+ + trailer< '.' 'has_key' > + trailer< + '(' + ( not(arglist | argument) arg=any ','> + ) + ')' + > + after=any* + > + | + negation=not_test< + 'not' + anchor=power< + before=any+ + trailer< '.' 'has_key' > + trailer< + '(' + ( not(arglist | argument) arg=any ','> + ) + ')' + > + > + > + """ + + def transform(self, node, results): + assert results + syms = self.syms + if (node.parent.type == syms.not_test and + self.pattern.match(node.parent)): + # Don't transform a node matching the first alternative of the + # pattern when its parent matches the second alternative + return None + negation = results.get("negation") + anchor = results["anchor"] + prefix = node.prefix + before = [n.clone() for n in results["before"]] + arg = results["arg"].clone() + after = results.get("after") + if after: + after = [n.clone() for n in after] + if arg.type in (syms.comparison, syms.not_test, syms.and_test, + syms.or_test, syms.test, syms.lambdef, syms.argument): + arg = parenthesize(arg) + if len(before) == 1: + before = before[0] + else: + before = pytree.Node(syms.power, before) + before.prefix = " " + n_op = Name("in", prefix=" ") + if negation: + n_not = Name("not", prefix=" ") + n_op = pytree.Node(syms.comp_op, (n_not, n_op)) + new = pytree.Node(syms.comparison, (arg, n_op, before)) + if after: + new = parenthesize(new) + new = pytree.Node(syms.power, (new,) + tuple(after)) + if node.parent.type in (syms.comparison, syms.expr, syms.xor_expr, + syms.and_expr, syms.shift_expr, + syms.arith_expr, syms.term, + syms.factor, syms.power): + new = parenthesize(new) + new.prefix = prefix + return new diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_import.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_import.py new file mode 100644 index 0000000000000000000000000000000000000000..734ca294699c36400b2c1d59c1badfb9c296ec14 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_import.py @@ -0,0 +1,99 @@ +"""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 +from ..fixer_util import FromImport, syms, token + + +def traverse_imports(names): + """ + Walks over all the names imported in a dotted_as_names node. + """ + pending = [names] + while pending: + node = pending.pop() + if node.type == token.NAME: + yield node.value + elif node.type == syms.dotted_name: + yield "".join([ch.value for ch in node.children]) + elif node.type == syms.dotted_as_name: + pending.append(node.children[0]) + elif node.type == syms.dotted_as_names: + pending.extend(node.children[::-2]) + else: + raise AssertionError("unknown node type") + + +class FixImport(fixer_base.BaseFix): + BM_compatible = True + + PATTERN = """ + import_from< 'from' imp=any 'import' ['('] any [')'] > + | + import_name< 'import' imp=any > + """ + + def start_tree(self, tree, name): + super(FixImport, self).start_tree(tree, name) + self.skip = "absolute_import" in tree.future_features + + def transform(self, node, results): + if self.skip: + return + imp = results['imp'] + + if node.type == syms.import_from: + # Some imps are top-level (eg: 'import ham') + # some are first level (eg: 'import ham.eggs') + # some are third level (eg: 'import ham.eggs as spam') + # Hence, the loop + while not hasattr(imp, 'value'): + imp = imp.children[0] + if self.probably_a_local_import(imp.value): + imp.value = "." + imp.value + imp.changed() + else: + have_local = False + have_absolute = False + for mod_name in traverse_imports(imp): + if self.probably_a_local_import(mod_name): + have_local = True + else: + have_absolute = True + if have_absolute: + if have_local: + # We won't handle both sibling and absolute imports in the + # same statement at the moment. + self.warning(node, "absolute and local imports together") + return + + new = FromImport(".", [imp]) + new.prefix = node.prefix + return new + + def probably_a_local_import(self, imp_name): + if imp_name.startswith("."): + # Relative imports are certainly not local imports. + return False + imp_name = imp_name.split(".", 1)[0] + base_path = dirname(self.filename) + base_path = join(base_path, imp_name) + # If there is no __init__.py next to the file its not in a package + # so can't be a relative import. + if not exists(join(dirname(base_path), "__init__.py")): + return False + for ext in [".py", sep, ".pyc", ".so", ".sl", ".pyd"]: + if exists(base_path + ext): + return True + return False diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_imports2.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_imports2.py new file mode 100644 index 0000000000000000000000000000000000000000..9a33c67b1dc1940b2e271fad30b73f8e06b24e33 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_imports2.py @@ -0,0 +1,16 @@ +"""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 diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_input.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_input.py new file mode 100644 index 0000000000000000000000000000000000000000..9cf9a48c471f35e39fa0e99a40a1cc75fae6fe6d --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_input.py @@ -0,0 +1,26 @@ +"""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 = True + PATTERN = """ + power< 'input' args=trailer< '(' [any] ')' > > + """ + + def transform(self, node, results): + # If we're already wrapped in an eval() call, we're done. + if context.match(node.parent.parent): + return + + new = node.clone() + new.prefix = "" + return Call(Name("eval"), [new], prefix=node.prefix) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_isinstance.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_isinstance.py new file mode 100644 index 0000000000000000000000000000000000000000..bebb1de120424b6b568ae3243eab55ad12305194 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_isinstance.py @@ -0,0 +1,52 @@ +# 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, long)) -> isinstance(x, (int, int)) + -> isinstance(x, int) +""" + +from .. import fixer_base +from ..fixer_util import token + + +class FixIsinstance(fixer_base.BaseFix): + BM_compatible = True + PATTERN = """ + power< + 'isinstance' + trailer< '(' arglist< any ',' atom< '(' + args=testlist_gexp< any+ > + ')' > > ')' > + > + """ + + run_order = 6 + + def transform(self, node, results): + names_inserted = set() + testlist = results["args"] + args = testlist.children + new_args = [] + iterator = enumerate(args) + for idx, arg in iterator: + if arg.type == token.NAME and arg.value in names_inserted: + if idx < len(args) - 1 and args[idx + 1].type == token.COMMA: + next(iterator) + continue + else: + new_args.append(arg) + if arg.type == token.NAME: + names_inserted.add(arg.value) + if new_args and new_args[-1].type == token.COMMA: + del new_args[-1] + if len(new_args) == 1: + atom = testlist.parent + new_args[0].prefix = atom.prefix + atom.replace(new_args[0]) + else: + args[:] = new_args + node.changed() diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_long.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_long.py new file mode 100644 index 0000000000000000000000000000000000000000..f227c9f49815388ed58a79e773c8114bced1e58f --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_long.py @@ -0,0 +1,19 @@ +# 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 + PATTERN = "'long'" + + def transform(self, node, results): + if is_probably_builtin(node): + node.value = "int" + node.changed() diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_metaclass.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_metaclass.py new file mode 100644 index 0000000000000000000000000000000000000000..fe547b2228072a3cf436733f40154004e98c215c --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_metaclass.py @@ -0,0 +1,228 @@ +"""Fixer for __metaclass__ = X -> (metaclass=X) methods. + + The various forms of classef (inherits nothing, inherits once, inherits + 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 ('class X: pass') there is no indent/dedent so + we normalize those into having a suite. + + Moving the __metaclass__ into the classdef can also cause the class + body to be empty so there is some special casing for that as well. + + This fixer also tries very hard to keep original indenting and spacing + in all those corner cases. + +""" +# Author: Jack Diederich + +# Local imports +from .. import fixer_base +from ..pygram import token +from ..fixer_util import syms, Node, Leaf + + +def has_metaclass(parent): + """ we have to check the cls_node without changing it. + There are two possibilities: + 1) clsdef => suite => simple_stmt => expr_stmt => Leaf('__meta') + 2) clsdef => simple_stmt => expr_stmt => Leaf('__meta') + """ + for node in parent.children: + if node.type == syms.suite: + return has_metaclass(node) + elif node.type == syms.simple_stmt and node.children: + expr_node = node.children[0] + if expr_node.type == syms.expr_stmt and expr_node.children: + left_side = expr_node.children[0] + if isinstance(left_side, Leaf) and \ + left_side.value == '__metaclass__': + return True + return False + + +def fixup_parse_tree(cls_node): + """ one-line classes don't get a suite in the parse tree so we add + one to normalize the tree + """ + for node in cls_node.children: + if node.type == syms.suite: + # already in the preferred format, do nothing + return + + # !%@#! one-liners have no suite node, we have to fake one up + for i, node in enumerate(cls_node.children): + if node.type == token.COLON: + break + else: + raise ValueError("No class suite and no ':'!") + + # move everything into a suite node + suite = Node(syms.suite, []) + while cls_node.children[i+1:]: + move_node = cls_node.children[i+1] + suite.append_child(move_node.clone()) + move_node.remove() + cls_node.append_child(suite) + node = suite + + +def fixup_simple_stmt(parent, i, stmt_node): + """ if there is a semi-colon all the parts count as part of the same + simple_stmt. We just want the __metaclass__ part so we move + everything after the semi-colon into its own simple_stmt node + """ + for semi_ind, node in enumerate(stmt_node.children): + if node.type == token.SEMI: # *sigh* + break + else: + return + + node.remove() # kill the semicolon + new_expr = Node(syms.expr_stmt, []) + new_stmt = Node(syms.simple_stmt, [new_expr]) + while stmt_node.children[semi_ind:]: + move_node = stmt_node.children[semi_ind] + new_expr.append_child(move_node.clone()) + move_node.remove() + parent.insert_child(i, new_stmt) + new_leaf1 = new_stmt.children[0].children[0] + old_leaf1 = stmt_node.children[0].children[0] + new_leaf1.prefix = old_leaf1.prefix + + +def remove_trailing_newline(node): + if node.children and node.children[-1].type == token.NEWLINE: + node.children[-1].remove() + + +def find_metas(cls_node): + # find the suite node (Mmm, sweet nodes) + for node in cls_node.children: + if node.type == syms.suite: + break + else: + raise ValueError("No class suite!") + + # look for simple_stmt[ expr_stmt[ Leaf('__metaclass__') ] ] + for i, simple_node in list(enumerate(node.children)): + if simple_node.type == syms.simple_stmt and simple_node.children: + expr_node = simple_node.children[0] + if expr_node.type == syms.expr_stmt and expr_node.children: + # Check if the expr_node is a simple assignment. + left_node = expr_node.children[0] + if isinstance(left_node, Leaf) and \ + left_node.value == '__metaclass__': + # We found an assignment to __metaclass__. + fixup_simple_stmt(node, i, simple_node) + remove_trailing_newline(simple_node) + yield (node, i, simple_node) + + +def fixup_indent(suite): + """ If an INDENT is followed by a thing with a prefix then nuke the prefix + Otherwise we get in trouble when removing __metaclass__ at suite start + """ + kids = suite.children[::-1] + # find the first indent + while kids: + node = kids.pop() + if node.type == token.INDENT: + break + + # find the first Leaf + while kids: + node = kids.pop() + if isinstance(node, Leaf) and node.type != token.DEDENT: + if node.prefix: + node.prefix = '' + return + else: + kids.extend(node.children[::-1]) + + +class FixMetaclass(fixer_base.BaseFix): + BM_compatible = True + + PATTERN = """ + classdef + """ + + def transform(self, node, results): + if not has_metaclass(node): + return + + fixup_parse_tree(node) + + # find metaclasses, keep the last one + last_metaclass = None + for suite, i, stmt in find_metas(node): + last_metaclass = stmt + stmt.remove() + + text_type = node.children[0].type # always Leaf(nnn, 'class') + + # figure out what kind of classdef we have + if len(node.children) == 7: + # Node(classdef, ['class', 'name', '(', arglist, ')', ':', suite]) + # 0 1 2 3 4 5 6 + if node.children[3].type == syms.arglist: + arglist = node.children[3] + # Node(classdef, ['class', 'name', '(', 'Parent', ')', ':', suite]) + else: + parent = node.children[3].clone() + arglist = Node(syms.arglist, [parent]) + node.set_child(3, arglist) + elif len(node.children) == 6: + # Node(classdef, ['class', 'name', '(', ')', ':', suite]) + # 0 1 2 3 4 5 + arglist = Node(syms.arglist, []) + node.insert_child(3, arglist) + elif len(node.children) == 4: + # Node(classdef, ['class', 'name', ':', suite]) + # 0 1 2 3 + arglist = Node(syms.arglist, []) + node.insert_child(2, Leaf(token.RPAR, ')')) + node.insert_child(2, arglist) + node.insert_child(2, Leaf(token.LPAR, '(')) + else: + raise ValueError("Unexpected class definition") + + # now stick the metaclass in the arglist + meta_txt = last_metaclass.children[0].children[0] + meta_txt.value = 'metaclass' + orig_meta_prefix = meta_txt.prefix + + if arglist.children: + arglist.append_child(Leaf(token.COMMA, ',')) + meta_txt.prefix = ' ' + else: + meta_txt.prefix = '' + + # compact the expression "metaclass = Meta" -> "metaclass=Meta" + expr_stmt = last_metaclass.children[0] + assert expr_stmt.type == syms.expr_stmt + expr_stmt.children[1].prefix = '' + expr_stmt.children[2].prefix = '' + + arglist.append_child(last_metaclass) + + fixup_indent(suite) + + # check for empty suite + if not suite.children: + # one-liner that was just __metaclass_ + suite.remove() + pass_leaf = Leaf(text_type, 'pass') + pass_leaf.prefix = orig_meta_prefix + node.append_child(pass_leaf) + node.append_child(Leaf(token.NEWLINE, '\n')) + + elif len(suite.children) > 1 and \ + (suite.children[-2].type == token.INDENT and + suite.children[-1].type == token.DEDENT): + # there was only one line in the class body and it was __metaclass__ + pass_leaf = Leaf(text_type, 'pass') + suite.insert_child(-1, pass_leaf) + suite.insert_child(-1, Leaf(token.NEWLINE, '\n')) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_methodattrs.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_methodattrs.py new file mode 100644 index 0000000000000000000000000000000000000000..7f9004f00e6e8f2a7d4f72d90b6af3a2674d0fa0 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_methodattrs.py @@ -0,0 +1,24 @@ +"""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): + BM_compatible = True + PATTERN = """ + power< any+ trailer< '.' attr=('im_func' | 'im_self' | 'im_class') > any* > + """ + + def transform(self, node, results): + attr = results["attr"][0] + new = MAP[attr.value] + attr.replace(Name(new, prefix=attr.prefix)) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_operator.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_operator.py new file mode 100644 index 0000000000000000000000000000000000000000..d303cd2018befb0745f2868068becf9f350b9b3d --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_operator.py @@ -0,0 +1,97 @@ +"""Fixer for operator functions. + +operator.isCallable(obj) -> callable(obj) +operator.sequenceIncludes(obj) -> operator.contains(obj) +operator.isSequenceType(obj) -> isinstance(obj, collections.abc.Sequence) +operator.isMappingType(obj) -> isinstance(obj, collections.abc.Mapping) +operator.isNumberType(obj) -> isinstance(obj, numbers.Number) +operator.repeat(obj, n) -> operator.mul(obj, n) +operator.irepeat(obj, n) -> operator.imul(obj, n) +""" + +import collections.abc + +# Local imports +from lib2to3 import fixer_base +from lib2to3.fixer_util import Call, Name, String, touch_import + + +def invocation(s): + def dec(f): + f.invocation = s + return f + return dec + + +class FixOperator(fixer_base.BaseFix): + BM_compatible = True + order = "pre" + + methods = """ + method=('isCallable'|'sequenceIncludes' + |'isSequenceType'|'isMappingType'|'isNumberType' + |'repeat'|'irepeat') + """ + obj = "'(' obj=any ')'" + PATTERN = """ + power< module='operator' + trailer< '.' %(methods)s > trailer< %(obj)s > > + | + power< %(methods)s trailer< %(obj)s > > + """ % dict(methods=methods, obj=obj) + + def transform(self, node, results): + method = self._check_method(node, results) + if method is not None: + return method(node, results) + + @invocation("operator.contains(%s)") + def _sequenceIncludes(self, node, results): + return self._handle_rename(node, results, "contains") + + @invocation("callable(%s)") + def _isCallable(self, node, results): + obj = results["obj"] + return Call(Name("callable"), [obj.clone()], prefix=node.prefix) + + @invocation("operator.mul(%s)") + def _repeat(self, node, results): + return self._handle_rename(node, results, "mul") + + @invocation("operator.imul(%s)") + def _irepeat(self, node, results): + return self._handle_rename(node, results, "imul") + + @invocation("isinstance(%s, collections.abc.Sequence)") + def _isSequenceType(self, node, results): + return self._handle_type2abc(node, results, "collections.abc", "Sequence") + + @invocation("isinstance(%s, collections.abc.Mapping)") + def _isMappingType(self, node, results): + return self._handle_type2abc(node, results, "collections.abc", "Mapping") + + @invocation("isinstance(%s, numbers.Number)") + def _isNumberType(self, node, results): + return self._handle_type2abc(node, results, "numbers", "Number") + + def _handle_rename(self, node, results, name): + method = results["method"][0] + method.value = name + method.changed() + + def _handle_type2abc(self, node, results, module, abc): + touch_import(None, module, node) + obj = results["obj"] + args = [obj.clone(), String(", " + ".".join([module, abc]))] + return Call(Name("isinstance"), args, prefix=node.prefix) + + def _check_method(self, node, results): + method = getattr(self, "_" + results["method"][0].value) + if isinstance(method, collections.abc.Callable): + if "module" in results: + return method + else: + sub = (str(results["obj"]),) + invocation_str = method.invocation % sub + self.warning(node, "You should use '%s' here." % invocation_str) + return None diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_paren.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_paren.py new file mode 100644 index 0000000000000000000000000000000000000000..df3da5f5232c9c42fc53c904f8c0b886b4dd4a51 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_paren.py @@ -0,0 +1,44 @@ +"""Fixer that adds 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 in 1, 2] +class FixParen(fixer_base.BaseFix): + BM_compatible = True + + PATTERN = """ + atom< ('[' | '(') + (listmaker< any + comp_for< + 'for' NAME 'in' + target=testlist_safe< any (',' any)+ [','] + > + [any] + > + > + | + testlist_gexp< any + comp_for< + 'for' NAME 'in' + target=testlist_safe< any (',' any)+ [','] + > + [any] + > + >) + (']' | ')') > + """ + + def transform(self, node, results): + target = results["target"] + + lparen = LParen() + lparen.prefix = target.prefix + target.prefix = "" # Make it hug the parentheses + target.insert_child(0, lparen) + target.append_child(RParen()) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_print.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_print.py new file mode 100644 index 0000000000000000000000000000000000000000..8780322265f6fe526cb35e7961f3cfb5aaa8e052 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_print.py @@ -0,0 +1,87 @@ +# 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 applied if print_function is imported from __future__ + +""" + +# Local imports +from .. import patcomp +from .. import pytree +from ..pgen2 import token +from .. import fixer_base +from ..fixer_util import Name, Call, Comma, String + + +parend_expr = patcomp.compile_pattern( + """atom< '(' [atom|STRING|NAME] ')' >""" + ) + + +class FixPrint(fixer_base.BaseFix): + + BM_compatible = True + + PATTERN = """ + simple_stmt< any* bare='print' any* > | print_stmt + """ + + def transform(self, node, results): + assert results + + bare_print = results.get("bare") + + if bare_print: + # Special-case print all by itself + bare_print.replace(Call(Name("print"), [], + prefix=bare_print.prefix)) + return + assert node.children[0] == Name("print") + args = node.children[1:] + if len(args) == 1 and parend_expr.match(args[0]): + # We don't want to keep sticking parens around an + # already-parenthesised expression. + return + + sep = end = file = None + if args and args[-1] == Comma(): + args = args[:-1] + end = " " + if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, ">>"): + assert len(args) >= 2 + file = args[1].clone() + args = args[3:] # Strip a possible comma after the file expression + # Now synthesize a print(args, sep=..., end=..., file=...) node. + l_args = [arg.clone() for arg in args] + if l_args: + l_args[0].prefix = "" + if sep is not None or end is not None or file is not None: + if sep is not None: + self.add_kwarg(l_args, "sep", String(repr(sep))) + if end is not None: + self.add_kwarg(l_args, "end", String(repr(end))) + if file is not None: + self.add_kwarg(l_args, "file", file) + n_stmt = Call(Name("print"), l_args) + n_stmt.prefix = node.prefix + return n_stmt + + def add_kwarg(self, l_nodes, s_kwd, n_expr): + # XXX All this prefix-setting may lose comments (though rarely) + n_expr.prefix = "" + n_argument = pytree.Node(self.syms.argument, + (Name(s_kwd), + pytree.Leaf(token.EQUAL, "="), + n_expr)) + if l_nodes: + l_nodes.append(Comma()) + n_argument.prefix = " " + l_nodes.append(n_argument) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_raise.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_raise.py new file mode 100644 index 0000000000000000000000000000000000000000..05aa21e74a30ff101c593dc03514efc26f10cecf --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_raise.py @@ -0,0 +1,90 @@ +"""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: +1) "raise E, V" will be incorrectly translated if V is an exception + instance. The correct Python 3 idiom is + + raise E from V + + but since we can't detect instance-hood by syntax alone and since + any client code would have to be changed as well, we don't automate + this. +""" +# Author: Collin Winter + +# Local imports +from .. import pytree +from ..pgen2 import token +from .. import fixer_base +from ..fixer_util import Name, Call, Attr, ArgList, is_tuple + +class FixRaise(fixer_base.BaseFix): + + BM_compatible = True + PATTERN = """ + raise_stmt< 'raise' exc=any [',' val=any [',' tb=any]] > + """ + + def transform(self, node, results): + syms = self.syms + + exc = results["exc"].clone() + if exc.type == token.STRING: + msg = "Python 3 does not support string exceptions" + self.cannot_convert(node, msg) + return + + # Python 2 supports + # raise ((((E1, E2), E3), E4), E5), V + # as a synonym for + # raise E1, V + # Since Python 3 will not support this, we recurse down any tuple + # literals, always taking the first element. + if is_tuple(exc): + while is_tuple(exc): + # exc.children[1:-1] is the unparenthesized tuple + # exc.children[1].children[0] is the first element of the tuple + exc = exc.children[1].children[0].clone() + exc.prefix = " " + + if "val" not in results: + # One-argument raise + new = pytree.Node(syms.raise_stmt, [Name("raise"), exc]) + new.prefix = node.prefix + return new + + val = results["val"].clone() + if is_tuple(val): + args = [c.clone() for c in val.children[1:-1]] + else: + val.prefix = "" + args = [val] + + if "tb" in results: + tb = results["tb"].clone() + tb.prefix = "" + + e = exc + # If there's a traceback and None is passed as the value, then don't + # add a call, since the user probably just wants to add a + # traceback. See issue #9661. + if val.type != token.NAME or val.value != "None": + e = Call(exc, args) + with_tb = Attr(e, Name('with_traceback')) + [ArgList([tb])] + new = pytree.Node(syms.simple_stmt, [Name("raise")] + with_tb) + new.prefix = node.prefix + return new + else: + return pytree.Node(syms.raise_stmt, + [Name("raise"), Call(exc, args)], + prefix=node.prefix) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_raw_input.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_raw_input.py new file mode 100644 index 0000000000000000000000000000000000000000..a51bb694b9e01e8d6f382f359118df1d74135924 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_raw_input.py @@ -0,0 +1,17 @@ +"""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* > + """ + + def transform(self, node, results): + name = results["name"] + name.replace(Name("input", prefix=name.prefix)) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_repr.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_repr.py new file mode 100644 index 0000000000000000000000000000000000000000..1150bb8b9db2afba11a18f2661fdfd4d9bd4b633 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_repr.py @@ -0,0 +1,23 @@ +# 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 + PATTERN = """ + atom < '`' expr=any '`' > + """ + + def transform(self, node, results): + expr = results["expr"].clone() + + if expr.type == self.syms.testlist1: + expr = parenthesize(expr) + return Call(Name("repr"), [expr], prefix=node.prefix) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_set_literal.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_set_literal.py new file mode 100644 index 0000000000000000000000000000000000000000..762550cf73dc0b627612465e63f0368d06847ae1 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_set_literal.py @@ -0,0 +1,53 @@ +""" +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< '(' + (atom=atom< '[' (items=listmaker< any ((',' any)* [',']) > + | + single=any) ']' > + | + atom< '(' items=testlist_gexp< any ((',' any)* [',']) > ')' > + ) + ')' > > + """ + + def transform(self, node, results): + single = results.get("single") + if single: + # Make a fake listmaker + fake = pytree.Node(syms.listmaker, [single.clone()]) + single.replace(fake) + items = fake + else: + items = results["items"] + + # Build the contents of the literal + literal = [pytree.Leaf(token.LBRACE, "{")] + literal.extend(n.clone() for n in items.children) + literal.append(pytree.Leaf(token.RBRACE, "}")) + # Set the prefix of the right brace to that of the ')' or ']' + literal[-1].prefix = items.next_sibling.prefix + maker = pytree.Node(syms.dictsetmaker, literal) + maker.prefix = node.prefix + + # If the original was a one tuple, we need to remove the extra comma. + if len(maker.children) == 4: + n = maker.children[2] + n.remove() + maker.children[-1].prefix = n.prefix + + # Finally, replace the set call with our shiny new literal. + return maker diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_sys_exc.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_sys_exc.py new file mode 100644 index 0000000000000000000000000000000000000000..f6039690374ab26d383bc8e0309438c051d0d405 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_sys_exc.py @@ -0,0 +1,30 @@ +"""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 + +class FixSysExc(fixer_base.BaseFix): + # This order matches the ordering of sys.exc_info(). + exc_info = ["exc_type", "exc_value", "exc_traceback"] + BM_compatible = True + PATTERN = """ + power< 'sys' trailer< dot='.' attribute=(%s) > > + """ % '|'.join("'%s'" % e for e in exc_info) + + def transform(self, node, results): + sys_attr = results["attribute"][0] + index = Number(self.exc_info.index(sys_attr.value)) + + call = Call(Name("exc_info"), prefix=sys_attr.prefix) + attr = Attr(Name("sys"), call) + attr[1].children[0].prefix = results["dot"].prefix + attr.append(Subscript(index)) + return Node(syms.power, attr, prefix=node.prefix) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_throw.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_throw.py new file mode 100644 index 0000000000000000000000000000000000000000..aac29169b4e98e26d0aa78c3fbce641742b04952 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_throw.py @@ -0,0 +1,56 @@ +"""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 .. import fixer_base +from ..fixer_util import Name, Call, ArgList, Attr, is_tuple + +class FixThrow(fixer_base.BaseFix): + BM_compatible = True + PATTERN = """ + power< any trailer< '.' 'throw' > + trailer< '(' args=arglist< exc=any ',' val=any [',' tb=any] > ')' > + > + | + power< any trailer< '.' 'throw' > trailer< '(' exc=any ')' > > + """ + + def transform(self, node, results): + syms = self.syms + + exc = results["exc"].clone() + if exc.type is token.STRING: + self.cannot_convert(node, "Python 3 does not support string exceptions") + return + + # Leave "g.throw(E)" alone + val = results.get("val") + if val is None: + return + + val = val.clone() + if is_tuple(val): + args = [c.clone() for c in val.children[1:-1]] + else: + val.prefix = "" + args = [val] + + throw_args = results["args"] + + if "tb" in results: + tb = results["tb"].clone() + tb.prefix = "" + + e = Call(exc, args) + with_tb = Attr(e, Name('with_traceback')) + [ArgList([tb])] + throw_args.replace(pytree.Node(syms.power, with_tb)) + else: + throw_args.replace(Call(exc, args)) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_tuple_params.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_tuple_params.py new file mode 100644 index 0000000000000000000000000000000000000000..cad755ffdbefb39431b2ffa4f5c8cf3c7a920c06 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_tuple_params.py @@ -0,0 +1,175 @@ +"""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 +""" +# Author: Collin Winter + +# Local imports +from .. import pytree +from ..pgen2 import token +from .. import fixer_base +from ..fixer_util import Assign, Name, Newline, Number, Subscript, syms + +def is_docstring(stmt): + return isinstance(stmt, pytree.Node) and \ + stmt.children[0].type == token.STRING + +class FixTupleParams(fixer_base.BaseFix): + run_order = 4 #use a lower order since lambda is part of other + #patterns + BM_compatible = True + + PATTERN = """ + funcdef< 'def' any parameters< '(' args=any ')' > + ['->' any] ':' suite=any+ > + | + lambda= + lambdef< 'lambda' args=vfpdef< '(' inner=any ')' > + ':' body=any + > + """ + + def transform(self, node, results): + if "lambda" in results: + return self.transform_lambda(node, results) + + new_lines = [] + suite = results["suite"] + args = results["args"] + # This crap is so "def foo(...): x = 5; y = 7" is handled correctly. + # TODO(cwinter): suite-cleanup + if suite[0].children[1].type == token.INDENT: + start = 2 + indent = suite[0].children[1].value + end = Newline() + else: + start = 0 + indent = "; " + end = pytree.Leaf(token.INDENT, "") + + # We need access to self for new_name(), and making this a method + # doesn't feel right. Closing over self and new_lines makes the + # code below cleaner. + def handle_tuple(tuple_arg, add_prefix=False): + n = Name(self.new_name()) + arg = tuple_arg.clone() + arg.prefix = "" + stmt = Assign(arg, n.clone()) + if add_prefix: + n.prefix = " " + tuple_arg.replace(n) + new_lines.append(pytree.Node(syms.simple_stmt, + [stmt, end.clone()])) + + if args.type == syms.tfpdef: + handle_tuple(args) + elif args.type == syms.typedargslist: + for i, arg in enumerate(args.children): + if arg.type == syms.tfpdef: + # Without add_prefix, the emitted code is correct, + # just ugly. + handle_tuple(arg, add_prefix=(i > 0)) + + if not new_lines: + return + + # This isn't strictly necessary, but it plays nicely with other fixers. + # TODO(cwinter) get rid of this when children becomes a smart list + for line in new_lines: + line.parent = suite[0] + + # TODO(cwinter) suite-cleanup + after = start + if start == 0: + new_lines[0].prefix = " " + elif is_docstring(suite[0].children[start]): + new_lines[0].prefix = indent + after = start + 1 + + for line in new_lines: + line.parent = suite[0] + suite[0].children[after:after] = new_lines + for i in range(after+1, after+len(new_lines)+1): + suite[0].children[i].prefix = indent + suite[0].changed() + + def transform_lambda(self, node, results): + args = results["args"] + body = results["body"] + inner = simplify_args(results["inner"]) + + # Replace lambda ((((x)))): x with lambda x: x + if inner.type == token.NAME: + inner = inner.clone() + inner.prefix = " " + args.replace(inner) + return + + params = find_params(args) + to_index = map_to_index(params) + tup_name = self.new_name(tuple_name(params)) + + new_param = Name(tup_name, prefix=" ") + args.replace(new_param.clone()) + for n in body.post_order(): + if n.type == token.NAME and n.value in to_index: + subscripts = [c.clone() for c in to_index[n.value]] + new = pytree.Node(syms.power, + [new_param.clone()] + subscripts) + new.prefix = n.prefix + n.replace(new) + + +### Helper functions for transform_lambda() + +def simplify_args(node): + if node.type in (syms.vfplist, token.NAME): + return node + elif node.type == syms.vfpdef: + # These look like vfpdef< '(' x ')' > where x is NAME + # or another vfpdef instance (leading to recursion). + while node.type == syms.vfpdef: + node = node.children[1] + return node + raise RuntimeError("Received unexpected node %s" % node) + +def find_params(node): + if node.type == syms.vfpdef: + return find_params(node.children[1]) + elif node.type == token.NAME: + return node.value + return [find_params(c) for c in node.children if c.type != token.COMMA] + +def map_to_index(param_list, prefix=[], d=None): + if d is None: + d = {} + for i, obj in enumerate(param_list): + trailer = [Subscript(Number(str(i)))] + if isinstance(obj, list): + map_to_index(obj, trailer, d=d) + else: + d[obj] = prefix + trailer + return d + +def tuple_name(param_list): + l = [] + for obj in param_list: + if isinstance(obj, list): + l.append(tuple_name(obj)) + else: + l.append(obj) + return "_".join(l) diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_urllib.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_urllib.py new file mode 100644 index 0000000000000000000000000000000000000000..ab892bc52494c25bf5b46f92ca862965b4d99e5c --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_urllib.py @@ -0,0 +1,196 @@ +"""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 import (Name, Comma, FromImport, Newline, + find_indentation, Node, syms) + +MAPPING = {"urllib": [ + ("urllib.request", + ["URLopener", "FancyURLopener", "urlretrieve", + "_urlopener", "urlopen", "urlcleanup", + "pathname2url", "url2pathname", "getproxies"]), + ("urllib.parse", + ["quote", "quote_plus", "unquote", "unquote_plus", + "urlencode", "splitattr", "splithost", "splitnport", + "splitpasswd", "splitport", "splitquery", "splittag", + "splittype", "splituser", "splitvalue", ]), + ("urllib.error", + ["ContentTooShortError"])], + "urllib2" : [ + ("urllib.request", + ["urlopen", "install_opener", "build_opener", + "Request", "OpenerDirector", "BaseHandler", + "HTTPDefaultErrorHandler", "HTTPRedirectHandler", + "HTTPCookieProcessor", "ProxyHandler", + "HTTPPasswordMgr", + "HTTPPasswordMgrWithDefaultRealm", + "AbstractBasicAuthHandler", + "HTTPBasicAuthHandler", "ProxyBasicAuthHandler", + "AbstractDigestAuthHandler", + "HTTPDigestAuthHandler", "ProxyDigestAuthHandler", + "HTTPHandler", "HTTPSHandler", "FileHandler", + "FTPHandler", "CacheFTPHandler", + "UnknownHandler"]), + ("urllib.error", + ["URLError", "HTTPError"]), + ] +} + +# Duplicate the url parsing functions for urllib2. +MAPPING["urllib2"].append(MAPPING["urllib"][1]) + + +def build_pattern(): + bare = set() + for old_module, changes in MAPPING.items(): + for change in changes: + new_module, members = change + members = alternates(members) + yield """import_name< 'import' (module=%r + | dotted_as_names< any* module=%r any* >) > + """ % (old_module, old_module) + yield """import_from< 'from' mod_member=%r 'import' + ( member=%s | import_as_name< member=%s 'as' any > | + import_as_names< members=any* >) > + """ % (old_module, members, members) + yield """import_from< 'from' module_star=%r 'import' star='*' > + """ % old_module + yield """import_name< 'import' + dotted_as_name< module_as=%r 'as' any > > + """ % old_module + # bare_with_attr has a special significance for FixImports.match(). + yield """power< bare_with_attr=%r trailer< '.' member=%s > any* > + """ % (old_module, members) + + +class FixUrllib(FixImports): + + def build_pattern(self): + return "|".join(build_pattern()) + + def transform_import(self, node, results): + """Transform for the basic import case. Replaces the old + import name with a comma separated list of its + replacements. + """ + import_mod = results.get("module") + pref = import_mod.prefix + + names = [] + + # create a Node list of the replacement modules + for name in MAPPING[import_mod.value][:-1]: + names.extend([Name(name[0], prefix=pref), Comma()]) + names.append(Name(MAPPING[import_mod.value][-1][0], prefix=pref)) + import_mod.replace(names) + + def transform_member(self, node, results): + """Transform for imports of specific module elements. Replaces + the module to be imported from with the appropriate new + module. + """ + mod_member = results.get("mod_member") + pref = mod_member.prefix + member = results.get("member") + + # Simple case with only a single member being imported + if member: + # this may be a list of length one, or just a node + if isinstance(member, list): + member = member[0] + new_name = None + for change in MAPPING[mod_member.value]: + if member.value in change[1]: + new_name = change[0] + break + if new_name: + mod_member.replace(Name(new_name, prefix=pref)) + else: + self.cannot_convert(node, "This is an invalid module element") + + # Multiple members being imported + else: + # a dictionary for replacements, order matters + modules = [] + mod_dict = {} + members = results["members"] + for member in members: + # we only care about the actual members + if member.type == syms.import_as_name: + as_name = member.children[2].value + member_name = member.children[0].value + else: + member_name = member.value + as_name = None + if member_name != ",": + for change in MAPPING[mod_member.value]: + if member_name in change[1]: + if change[0] not in mod_dict: + modules.append(change[0]) + mod_dict.setdefault(change[0], []).append(member) + + new_nodes = [] + indentation = find_indentation(node) + first = True + def handle_name(name, prefix): + if name.type == syms.import_as_name: + kids = [Name(name.children[0].value, prefix=prefix), + name.children[1].clone(), + name.children[2].clone()] + return [Node(syms.import_as_name, kids)] + return [Name(name.value, prefix=prefix)] + for module in modules: + elts = mod_dict[module] + names = [] + for elt in elts[:-1]: + names.extend(handle_name(elt, pref)) + names.append(Comma()) + names.extend(handle_name(elts[-1], pref)) + new = FromImport(module, names) + if not first or node.parent.prefix.endswith(indentation): + new.prefix = indentation + new_nodes.append(new) + first = False + if new_nodes: + nodes = [] + for new_node in new_nodes[:-1]: + nodes.extend([new_node, Newline()]) + nodes.append(new_nodes[-1]) + node.replace(nodes) + else: + self.cannot_convert(node, "All module elements are invalid") + + def transform_dot(self, node, results): + """Transform for calls to module members in code.""" + module_dot = results.get("bare_with_attr") + member = results.get("member") + new_name = None + if isinstance(member, list): + member = member[0] + for change in MAPPING[module_dot.value]: + if member.value in change[1]: + new_name = change[0] + break + if new_name: + module_dot.replace(Name(new_name, + prefix=module_dot.prefix)) + else: + self.cannot_convert(node, "This is an invalid module element") + + def transform(self, node, results): + if results.get("module"): + self.transform_import(node, results) + elif results.get("mod_member"): + self.transform_member(node, results) + elif results.get("bare_with_attr"): + self.transform_dot(node, results) + # Renaming and star imports are not supported for these modules. + elif results.get("module_star"): + self.cannot_convert(node, "Cannot handle star imports.") + elif results.get("module_as"): + self.cannot_convert(node, "This module is now multiple modules") diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_ws_comma.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_ws_comma.py new file mode 100644 index 0000000000000000000000000000000000000000..a54a376c472afbff3f23f011d329af24813e5760 --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_ws_comma.py @@ -0,0 +1,39 @@ +"""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 user must ask for this fixers + + PATTERN = """ + any<(not(',') any)+ ',' ((not(',') any)+ ',')* [not(',') any]> + """ + + COMMA = pytree.Leaf(token.COMMA, ",") + COLON = pytree.Leaf(token.COLON, ":") + SEPS = (COMMA, COLON) + + def transform(self, node, results): + new = node.clone() + comma = False + for child in new.children: + if child in self.SEPS: + prefix = child.prefix + if prefix.isspace() and "\n" not in prefix: + child.prefix = "" + comma = True + else: + if comma: + prefix = child.prefix + if not prefix: + child.prefix = " " + comma = False + return new diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_xrange.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_xrange.py new file mode 100644 index 0000000000000000000000000000000000000000..1e491e166a3f1c4223d306b9ad5817bc31fab2ee --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_xrange.py @@ -0,0 +1,73 @@ +# 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_compatible = True + PATTERN = """ + power< + (name='range'|name='xrange') trailer< '(' args=any ')' > + rest=any* > + """ + + def start_tree(self, tree, filename): + super(FixXrange, self).start_tree(tree, filename) + self.transformed_xranges = set() + + def finish_tree(self, tree, filename): + self.transformed_xranges = None + + def transform(self, node, results): + name = results["name"] + if name.value == "xrange": + return self.transform_xrange(node, results) + elif name.value == "range": + return self.transform_range(node, results) + else: + raise ValueError(repr(name)) + + def transform_xrange(self, node, results): + name = results["name"] + name.replace(Name("range", prefix=name.prefix)) + # This prevents the new range call from being wrapped in a list later. + self.transformed_xranges.add(id(node)) + + def transform_range(self, node, results): + if (id(node) not in self.transformed_xranges and + not self.in_special_context(node)): + range_call = Call(Name("range"), [results["args"].clone()]) + # Encase the range call in list(). + list_call = Call(Name("list"), [range_call], + prefix=node.prefix) + # Put things that were after the range() call after the list call. + for n in results["rest"]: + list_call.append_child(n) + return list_call + + P1 = "power< func=NAME trailer< '(' node=any ')' > any* >" + p1 = patcomp.compile_pattern(P1) + + P2 = """for_stmt< 'for' any 'in' node=any ':' any* > + | comp_for< 'for' any 'in' node=any any* > + | comparison< any 'in' node=any any*> + """ + p2 = patcomp.compile_pattern(P2) + + def in_special_context(self, node): + if node.parent is None: + return False + results = {} + if (node.parent.parent is not None and + self.p1.match(node.parent.parent, results) and + results["node"] is node): + # list(d.keys()) -> list(d.keys()), etc. + return results["func"].value in consuming_calls + # for ... in d.iterkeys() -> for ... in d.keys(), etc. + return self.p2.match(node.parent, results) and results["node"] is node diff --git a/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_zip.py b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_zip.py new file mode 100644 index 0000000000000000000000000000000000000000..52c28df6aab411ad1ea64af74b14edf35e80b5bb --- /dev/null +++ b/evalkit_cambrian/lib/python3.10/lib2to3/fixes/fix_zip.py @@ -0,0 +1,46 @@ +""" +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 <>:. +""" + +# Local imports +from .. import fixer_base +from ..pytree import Node +from ..pygram import python_symbols as syms +from ..fixer_util import Name, ArgList, in_special_context + + +class FixZip(fixer_base.ConditionalFix): + + BM_compatible = True + PATTERN = """ + power< 'zip' args=trailer< '(' [any] ')' > [trailers=trailer*] + > + """ + + skip_on = "future_builtins.zip" + + def transform(self, node, results): + if self.should_skip(node): + return + + if in_special_context(node): + return None + + args = results['args'].clone() + args.prefix = "" + + trailers = [] + if 'trailers' in results: + trailers = [n.clone() for n in results['trailers']] + for n in trailers: + n.prefix = "" + + new = Node(syms.power, [Name("zip"), args], prefix="") + new = Node(syms.power, [Name("list"), ArgList([new])] + trailers) + new.prefix = node.prefix + return new