summaryrefslogtreecommitdiffstats
path: root/FOSS/Python/Dependencies/future-0.18.2/docs/other
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-01-01 21:05:27 -0800
committeryum <yum.food.vr@gmail.com>2023-01-01 21:44:45 -0800
commite25bdba3a3a53b09be5269d8b065c13b73ab55c3 (patch)
tree1d1dc1d94cde92c2f4f8ce86017395054787515d /FOSS/Python/Dependencies/future-0.18.2/docs/other
parent0d408cc812a094a708edbe4baf536e928731cfc3 (diff)
Embed git in package
package.ps1 fetches PortableGit and embeds it in the package. This eliminates all but one runtime dependency (MSVC++ Redistributable). * Move Python into a new FOSS folder.
Diffstat (limited to 'FOSS/Python/Dependencies/future-0.18.2/docs/other')
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/docs/other/auto2to3.py122
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/docs/other/find_pattern.py98
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/docs/other/fix_notebook_html_colour.py36
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/docs/other/lessons.txt49
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/docs/other/todo.txt1
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/docs/other/upload_future_docs.sh23
-rw-r--r--FOSS/Python/Dependencies/future-0.18.2/docs/other/useful_links.txt110
7 files changed, 439 insertions, 0 deletions
diff --git a/FOSS/Python/Dependencies/future-0.18.2/docs/other/auto2to3.py b/FOSS/Python/Dependencies/future-0.18.2/docs/other/auto2to3.py
new file mode 100644
index 0000000..3abd370
--- /dev/null
+++ b/FOSS/Python/Dependencies/future-0.18.2/docs/other/auto2to3.py
@@ -0,0 +1,122 @@
+#!/usr/bin/env python3
+"""Wrapper to run 2to3 automatically at import time.
+
+Usage:
+ auto2to3 -m mypackage.main_module
+ auto2to3 mypackage/script.py
+
+By default, all modules imported from a subdirectory of the current
+directory will be run through `2to3`. To change this behavior, use the
+`--package` or `--dir` flags to `auto2to3` to specify which packages or
+directories contain Python 2 code that should be converted.
+
+2to3 output is cached on disk between runs for speed.
+
+Based on auto2to3.py by Georg Brandl:
+http://dev.pocoo.org/hg/sandbox/file/tip/auto2to3.py
+"""
+
+import argparse
+import os
+import sys
+import imp
+import runpy
+from io import StringIO
+from pkgutil import ImpImporter, ImpLoader
+import runpy
+import sys
+import tempfile
+
+import lib2to3
+from lib2to3.refactor import RefactoringTool, get_fixers_from_package
+
+fixes = get_fixers_from_package('lib2to3.fixes')
+rt = RefactoringTool(fixes)
+
+PACKAGES = []
+DIRS = []
+
+def maybe_2to3(filename, modname=None):
+ """Returns a python3 version of filename."""
+ need_2to3 = False
+ filename = os.path.abspath(filename)
+ if any(filename.startswith(d) for d in DIRS):
+ need_2to3 = True
+ elif modname is not None and any(modname.startswith(p) for p in PACKAGES):
+ need_2to3 = True
+ if not need_2to3:
+ return filename
+ outfilename = '/_auto2to3_'.join(os.path.split(filename))
+ if (not os.path.exists(outfilename) or
+ os.stat(filename).st_mtime > os.stat(outfilename).st_mtime):
+ try:
+ with open(filename) as file:
+ contents = file.read()
+ contents = rt.refactor_docstring(contents, filename)
+ tree = rt.refactor_string(contents, filename)
+ except Exception as err:
+ raise ImportError("2to3 couldn't convert %r" % filename)
+ outfile = open(outfilename, 'wb')
+ outfile.write(str(tree).encode('utf8'))
+ outfile.close()
+ return outfilename
+
+
+
+class ToThreeImporter(ImpImporter):
+ def find_module(self, fullname, path=None):
+ # this duplicates most of ImpImporter.find_module
+ subname = fullname.split(".")[-1]
+ if subname != fullname and self.path is None:
+ return None
+ if self.path is None:
+ path = None
+ else:
+ path = [os.path.realpath(self.path)]
+ try:
+ file, filename, etc = imp.find_module(subname, path)
+ except ImportError:
+ return None
+ if file and etc[2] == imp.PY_SOURCE:
+ outfilename = maybe_2to3(filename, modname=fullname)
+ if outfilename != filename:
+ file.close()
+ filename = outfilename
+ file = open(filename, 'rb')
+ return ImpLoader(fullname, file, filename, etc)
+
+
+# setup the hook
+sys.path_hooks.append(ToThreeImporter)
+for key in sys.path_importer_cache:
+ if sys.path_importer_cache[key] is None:
+ sys.path_importer_cache[key] = ToThreeImporter(key)
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--package', action='append')
+ parser.add_argument('--dir', action='append')
+ parser.add_argument('-m', action='store', metavar='MODULE')
+ args, rest = parser.parse_known_args()
+ if args.package:
+ PACKAGES.extend(args.package)
+ if args.dir:
+ DIRS.extend(os.path.abspath(d) for d in args.dir)
+ if not PACKAGES and not DIRS:
+ DIRS.append(os.getcwd())
+ if args.m:
+ sys.argv[1:] = rest
+ runpy.run_module(args.m, run_name='__main__', alter_sys=True)
+ elif rest:
+ sys.argv = rest
+ converted = maybe_2to3(rest[0])
+ with open(converted) as f:
+ new_globals = dict(__name__='__main__',
+ __file__=rest[0])
+ exec(f.read(), new_globals)
+ else:
+ import code
+ code.interact()
+
+if __name__ == '__main__':
+ main()
diff --git a/FOSS/Python/Dependencies/future-0.18.2/docs/other/find_pattern.py b/FOSS/Python/Dependencies/future-0.18.2/docs/other/find_pattern.py
new file mode 100644
index 0000000..1a5da35
--- /dev/null
+++ b/FOSS/Python/Dependencies/future-0.18.2/docs/other/find_pattern.py
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+
+"""Script that makes determining PATTERN for a new [2to3] fix much easier.
+
+Figuring out exactly what PATTERN I want for a given fixer class is
+getting tedious. This script will step through each possible subtree
+for a given string, allowing you to select which one you want. It will
+then try to figure out an appropriate pattern to match that tree. This
+pattern will require some editing (it will be overly restrictive) but
+should provide a solid base to work with and handle the tricky parts.
+
+Usage:
+
+ python find_pattern.py "g.throw(E, V, T)"
+
+This will step through each subtree in the parse. To reject a
+candidate subtree, hit enter; to accept a candidate, hit "y" and
+enter. The pattern will be spit out to stdout.
+
+For example, the above will yield a succession of possible snippets,
+skipping all leaf-only trees. I accept
+
+'g.throw(E, V, T)'
+
+This causes find_pattern to spit out
+
+power< 'g' trailer< '.' 'throw' >
+ trailer< '(' arglist< 'E' ',' 'V' ',' 'T' > ')' > >
+
+
+Some minor tweaks later, I'm left with
+
+power< any trailer< '.' 'throw' >
+ trailer< '(' args=arglist< exc=any ',' val=any [',' tb=any] > ')' > >
+
+which is exactly what I was after.
+
+Larger snippets can be placed in a file (as opposed to a command-line
+arg) and processed with the -f option.
+"""
+from __future__ import print_function
+
+__author__ = "Collin Winter <collinw@gmail.com>"
+
+# Python imports
+import optparse
+import sys
+from StringIO import StringIO
+
+# Local imports
+from lib2to3 import pytree
+from lib2to3.pgen2 import driver
+from lib2to3.pygram import python_symbols, python_grammar
+
+driver = driver.Driver(python_grammar, convert=pytree.convert)
+
+def main(args):
+ parser = optparse.OptionParser(usage="find_pattern.py [options] [string]")
+ parser.add_option("-f", "--file", action="store",
+ help="Read a code snippet from the specified file")
+
+ # Parse command line arguments
+ options, args = parser.parse_args(args)
+ if options.file:
+ tree = driver.parse_file(options.file)
+ elif len(args) > 1:
+ tree = driver.parse_stream(StringIO(args[1] + "\n"))
+ else:
+ print("You must specify an input file or an input string", file=sys.stderr)
+ return 1
+
+ examine_tree(tree)
+ return 0
+
+def examine_tree(tree):
+ for node in tree.post_order():
+ if isinstance(node, pytree.Leaf):
+ continue
+ print(repr(str(node)))
+ verdict = raw_input()
+ if verdict.strip():
+ print(find_pattern(node))
+ return
+
+def find_pattern(node):
+ if isinstance(node, pytree.Leaf):
+ return repr(node.value)
+
+ return find_symbol(node.type) + \
+ "< " + " ".join(find_pattern(n) for n in node.children) + " >"
+
+def find_symbol(sym):
+ for n, v in python_symbols.__dict__.items():
+ if v == sym:
+ return n
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
diff --git a/FOSS/Python/Dependencies/future-0.18.2/docs/other/fix_notebook_html_colour.py b/FOSS/Python/Dependencies/future-0.18.2/docs/other/fix_notebook_html_colour.py
new file mode 100644
index 0000000..36c2205
--- /dev/null
+++ b/FOSS/Python/Dependencies/future-0.18.2/docs/other/fix_notebook_html_colour.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+"""
+A script to re-enable colour in .html files produced from IPython notebooks.
+
+Based on a script in a GitHub gist with this copyright notice:
+
+#----------------------------------------------------------------------------
+# Copyright (c) 2013 - Damián Avila
+#
+# Distributed under the terms of the Modified BSD License.
+#
+# A little snippet to fix @media print issue printing slides from IPython
+#-----------------------------------------------------------------------------
+"""
+
+import io
+import sys
+
+notebook = sys.argv[1]
+assert notebook.endswith('.html')
+# notebook = 'jevans.ipynb'
+path = notebook[:-5] + '.html'
+flag = u'@media print{*{text-shadow:none !important;color:#000 !important'
+
+with io.open(path, 'r') as in_file:
+ data = in_file.readlines()
+ for i, line in enumerate(data):
+ if line[:64] == flag:
+ data[i] = data[i].replace('color:#000 !important;', '')
+
+with io.open(path, 'w') as out_file:
+ out_file.writelines(data)
+
+print("You can now print your slides")
diff --git a/FOSS/Python/Dependencies/future-0.18.2/docs/other/lessons.txt b/FOSS/Python/Dependencies/future-0.18.2/docs/other/lessons.txt
new file mode 100644
index 0000000..ede523c
--- /dev/null
+++ b/FOSS/Python/Dependencies/future-0.18.2/docs/other/lessons.txt
@@ -0,0 +1,49 @@
+The escape() function in this file in Django 1.4:
+
+ /home/user/VirtualEnvs/mezzanine/local/lib/python2.7/site-packages/django/utils/html.py
+
+atttempts to use the unicode replace method with byte strings. This
+causes this exception when running the Mezzanine tests using the newstr
+object:
+
+ File "/home/user/VirtualEnvs/mezzanine/local/lib/python2.7/site-packages/django/utils/html.py", line 36, in escape
+ return mark_safe(force_unicode(html).replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;').replace("'", '&#39;'))
+ File "/home/user/VirtualEnvs/mezzanine/local/lib/python2.7/site-packages/future-0.9.0_dev-py2.7.egg/future/builtins/backports/__init__.py", line 145, in wrapper
+ raise TypeError(errmsg.format(mytype))
+ TypeError: argument can't be <type 'str'>
+
+
+Comment to add to prevent Pylint from issuing warnings on ``from
+future.builtins import *``:
+
+ # pylint: disable=W0622,W0401
+
+INCOMPATIBLE: array.array()
+
+Python 2:
+ >>> array.array(b'b')
+ array.array(b'b')
+
+ >>> array.array(u'u')
+ TypeError: must be char, not unicode
+
+Python 3:
+ >>> array.array(b'b')
+ TypeError: must be a unicode character, not bytes
+
+ >>> array.array(u'b')
+ array('b')
+
+Maybe use on Py2:
+ >>> array.array(u'b'.encode('ascii')) ??
+
+Long int syntax (e.g. 1000000L) is incompatible with Py3.
+We probably shouldn't shadow int with long on Py2 because then isinstance(1, int) is False
+
+Python 2's bytes object is nothing like Python 3's bytes object!
+Running test_bytes.py from Py3 on Py2 (after fixing imports) gives this:
+
+--------------------------------------------------------------
+Ran 203 tests in 0.209s
+
+FAILED (failures=31, errors=55, skipped=1)
diff --git a/FOSS/Python/Dependencies/future-0.18.2/docs/other/todo.txt b/FOSS/Python/Dependencies/future-0.18.2/docs/other/todo.txt
new file mode 100644
index 0000000..def7b04
--- /dev/null
+++ b/FOSS/Python/Dependencies/future-0.18.2/docs/other/todo.txt
@@ -0,0 +1 @@
+Import open() from codecs to shadow the Py2 open()?
diff --git a/FOSS/Python/Dependencies/future-0.18.2/docs/other/upload_future_docs.sh b/FOSS/Python/Dependencies/future-0.18.2/docs/other/upload_future_docs.sh
new file mode 100644
index 0000000..d5c272d
--- /dev/null
+++ b/FOSS/Python/Dependencies/future-0.18.2/docs/other/upload_future_docs.sh
@@ -0,0 +1,23 @@
+# On the local machine
+
+git checkout v0.16.0 # or whatever
+rm -Rf docs/build/
+cd docs; make html
+cp cheatsheet.pdf /shared/
+cd build
+touch /shared/python-future-html-docs.zip
+rm /shared/python-future-html-docs.zip
+zip -r /shared/python-future-html-docs.zip *
+
+scp /shared/python-future-html-docs.zip python-future.org:
+scp /shared/cheatsheet.pdf python-future.org:
+ssh python-future.org
+
+
+# On the remote machine:
+
+cd /var/www/python-future.org/
+unzip -o ~/python-future-html-docs.zip
+chmod a+r * html/* html/_static/*
+cp ~/cheatsheet.pdf ./html/compatible_idioms.pdf
+cp ~/cheatsheet.pdf ./html/cheatsheet.pdf
diff --git a/FOSS/Python/Dependencies/future-0.18.2/docs/other/useful_links.txt b/FOSS/Python/Dependencies/future-0.18.2/docs/other/useful_links.txt
new file mode 100644
index 0000000..abb9684
--- /dev/null
+++ b/FOSS/Python/Dependencies/future-0.18.2/docs/other/useful_links.txt
@@ -0,0 +1,110 @@
+Official words on porting:
+--------------------------
+http://docs.python.org/2/howto/pyporting.html
+http://wiki.python.org/moin/Python2orPython3
+
+Other docs to read about porting to Py3:
+----------------------------------------
+
+https://github.com/nltk/nltk/blob/2and3/web/dev/python3porting.rst (particularly about doctests)
+https://ep2013.europython.eu/media/conference/slides/python-3-the-next-generation-is-here-already.pdf
+http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/
+Supporting both 2 and 3 without 2to3 conversion: http://python3porting.com/noconv.html
+http://python3porting.com/strategies.html
+http://techspot.zzzeek.org/2011/01/24/zzzeek-s-guide-to-python-3-porting/
+http://dabeaz.blogspot.com.au/2011/01/porting-py65-and-my-superboard-to.html
+http://wolfprojects.altervista.org/talks/unicode-and-python-3/
+
+Porting Django apps: https://docs.djangoproject.com/en/dev/topics/python3/
+http://www.wefearchange.org/2012/01/python-3-porting-fun-redux.html
+
+http://lucumr.pocoo.org/2011/12/7/thoughts-on-python3/
+
+http://python3porting.com/fixers.html
+http://washort.twistedmatrix.com/2010/11/unicode-in-python-and-how-to-prevent-it.html
+http://docs.python.org/release/3.0.1/whatsnew/3.0.html
+https://pypi.org/project/unicode-nazi/
+http://www.rmi.net/~lutz/strings30.html
+
+"Porting your code to Python 3": Alexandre Vassalotti: peadrop.com/slides/mp5.pdf
+
+Migration problems:
+-------------------
+http://python3porting.com/problems.html
+http://www.wefearchange.org/2012/01/python-3-porting-fun-redux.html
+
+Six module: http://pythonhosted.org/six/
+
+Dive Into Python: Appendix A: Porting Code to Python 3 with 2to3: http://getpython3.com/diveintopython3/porting-code-to-python-3-with-2to3.html
+
+Stdlib reorganization: http://python3porting.com/stdlib.html
+
+python-modernize: https://github.com/mitsuhiko/python-modernize
+
+2to3 docs describing the different fixers: http://docs.python.org/2/library/2to3.html
+
+Injecting code into running Python processes (hopefully not needed): https://pypi.org/project/pyrasite/2.0/
+
+Withdrawn PEP to help with the Py3k standard library transition: http://www.peps.io/364/
+
+Import hooks
+------------
+http://www.peps.io/302/
+"Hacking Python imports ... for fun and profit": blog post from 2012-05: http://xion.org.pl/2012/05/06/hacking-python-imports/
+
+Full importlib backport to Py2: https://pypi.org/project/backport_importlib/0...1/
+
+Python 2.7 importlib subset: http://docs.python.org/2/whatsnew/2.7.html#importlib-section
+
+Post-import hooks (rendered obsolete by importlib): http://blog.cdleary.com/2009/04/monstrous-polymorphism-and-a-python-post-import-hook-decorator/
+
+'An import hook for Python 3 that removes u prefixes '
+ 'from Python source code before compiling it.': https://bitbucket.org/vinay.sajip/uprefix/
+
+
+__future__ imports
+------------------
+http://simeonvisser.com/posts/how-does-from-future-import-work-in-python.html
+http://docs.python.org/2/library/__future__.html
+
+lib3to2
+-------
+https://bitbucket.org/amentajo/lib3to2
+http://www.startcodon.com/wordpress/category/3to2/
+
+Unicode and bytes
+-----------------
+PEPs: 358, 3112, 3137, 3138
+http://python3porting.com/noconv.html#unicode-section
+Unicode literals u'...' back in Python 3.3: http://www.python.org/dev/peps/pep-0414/
+https://github.com/django/django/blob/master/django/utils/encoding.py
+https://pypi.org/project/unicode-nazi/
+http://docs.python.org/3/library/stdtypes.html#bytes-methods
+http://wolfprojects.altervista.org/talks/unicode-and-python-3/
+Buffer protocol (which bytes and bytes-like objects obey): http://docs.python.org/3.3/c-api/buffer.html#bufferobjects
+
+
+Python's future
+----------------
+https://ncoghlan-devs-python-notes.readthedocs.io/en/latest/python3/questions_and_answers.html
+
+http://www.ironfroggy.com/software/i-am-worried-about-the-future-of-python
+
+Backporting
+-----------
+http://stackoverflow.com/questions/7507492/is-backporting-python-3s-range-to-python-2-a-bad-idea
+
+
+Other
+-----
+Type-checking decorators (maybe useful for implementing a Py3-like bytes
+object in Py2): http://wiki.python.org/moin/PythonDecoratorLibrary#Type_Enforcement_.28accepts.2Freturns.29
+Also: typecheck module on PyPI
+
+To categorize
+-------------
+
+https://pypi.org/project/awkwardduet/1.1a4/
+https://github.com/campadrenalin/persei/blob/master/persei.py
+http://slideshare.net/dabeaz/mastering-python-3-io
+http://rmi.net/~lutz/strings30.html