diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2013-11-14 00:55:19 -0500 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2013-11-14 00:55:19 -0500 |
commit | 2a01c3a440d02f20693b7508f3a780d1275fab1f (patch) | |
tree | e393622bcacb26d890df49afcf6ebbc0d32c2e9f | |
parent | b06c4dfedfe50cf8857ddb9f5de0e4f0885dc517 (diff) | |
parent | ed5074ebcafb60d9b46a6765d74ab32e3120e9f8 (diff) | |
download | pies-2a01c3a440d02f20693b7508f3a780d1275fab1f.tar.gz |
Merge2.0.0
58 files changed, 750 insertions, 121 deletions
@@ -0,0 +1,56 @@ +#!/bin/bash +OPEN_PROJECT_NAME="pies" + +if [ "$PROJECT_NAME" = "$OPEN_PROJECT_NAME" ]; then + return +fi + +export PROJECT_NAME=$OPEN_PROJECT_NAME +export PROJECT_DIR="$PWD" + +# Let's make sure this is a hubflow enabled repo +yes | git hf init >/dev/null 2>/dev/null + +# Quick directory switching +alias root="cd $PROJECT_DIR" +alias overrides="root; cd pies2overrides" + +# Commands +alias test="root; py.test -s" +alias install="_install_project" +alias distribute="_distribute_project" +alias leave="_leave_project" + +function _install_project() +{ + CURRENT_DIRECTORY="$PWD" + root + sudo python setup.py install + overrides + sudo python setup.py install + cd $CURRENT_DIRECTORY +} + +function _distribute_project() +{ + CURRENT_DIRECTORY="$PWD" + root + sudo rm -rf dist + python setup.py sdist upload + overrides + sudo rm -rf dist + python setup.py sdist upload +} + +function _leave_project() +{ + export PROJECT_NAME="" + export PROJECT_DIR="" + + unalias root + unalias overrides + unalias test + unalias install + unalias distribute + unalias leave +} @@ -1,4 +1,57 @@ -*.pyc -~* -*.swp* +*.py[cod] +.DS_Store +# C extensions +*.so + +# Packages +*.egg +*.egg-info build +eggs +parts +var +sdist +develop-eggs +.installed.cfg +lib +lib64 +MANIFEST + +# Installer logs +pip-log.txt +npm-debug.log + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +htmlcov +.cache + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# SQLite +test_exp_framework + +# npm +node_modules/ + +# dolphin +.directory +libpeerconnection.log + +# setuptools +dist + +# IDE Files +atlassian-ide-plugin.xml +.idea/ +*.swp +*.kate-swp +.ropeproject/ diff --git a/.pies.py.kate-swp b/.pies.py.kate-swp Binary files differnew file mode 100644 index 0000000..1bfbaf4 --- /dev/null +++ b/.pies.py.kate-swp diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..1e66aee --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" +script: python setup.py test
\ No newline at end of file @@ -1,3 +1,12 @@ # file GENERATED by distutils, do NOT edit -pies.py setup.py +pies/StringIO.py +pies/__init__.py +pies/collections.py +pies/functools.py +pies/imp.py +pies/itertools.py +pies/overrides.py +pies/pickle.py +pies/sys.py +pies/version_info.py @@ -1,8 +1,30 @@ -pies! +![Pies](https://raw.github.com/timothycrosley/pies/develop/logo.png) ==================== +[![PyPi version](https://pypip.in/v/pies/badge.png)](https://crate.io/packages/pies/) +[![PyPi downloads](https://pypip.in/d/pies/badge.png)](https://crate.io/packages/pies/) The simplest (and tastiest) way to write one program that runs on both Python 2.6+ and Python 3. +Let's eat some pies! +====================== + +Installing pies + + pip install pies + +or if you prefer: + + easy_install pies + +Overview +==================== + +Pies is a Python2 & 3 Compatibility layer with the philosophy that all code should be Python3 code. +Starting from this viewpoint means that when running on Python3 pies adds virtually no overhead. + +Instead of providing a bunch of custom methods (leading to Python code that looks out of place on any version) +pies aims to back port as many of the Python3 api calls, imports, and objects to Python2 - Relying on special syntax +only when absolutely necessary. How does pies differ from six? ==================== @@ -11,48 +33,102 @@ Pies is significantly smaller and simpler then six because it assumes for everything possible the developer is using the Python 3 compatible versions included with Python 2.6+, whereas six tries to maintain compatibility with Python 2.4 - leading to many more overrides and further into different language territory. -Additionally where possible pies tries to enable you to not have to change syntax at all - -pass including the import. +Additionally, as stated above, where possible pies tries to enable you to not have to change syntax at all. - -Let's eat some pies! +Integrating pies into your diet ====================== -Installing pies +Using and integrating pies into an existing Python 3+ code base (to achieve Python 2 & 3 dual support) couldn't be simpler: - pip install pies + from __future__ import absolute_import, division, print_function, unicode_literals -or if you prefer: + from pies.overrides import * - easy_install pies +Then simply write standard Python3 code, and enjoy Python2 Support. +Works Unchanged (The Good) +====================== -Integrating pies into your diet +The best part of Pies is how much Python3 code works unchanged in Python2 + +Functions: + +- round +- next +- filter +- map +- zip +- input +- range + +Types: + +- chr (creates a unichr object in Python2) +- str (creates a unicode object in Python2) +- dict (creating a dict using dict() will give you all the special Python3 itemview results, but using {} will not) + +Imports: + +- html +- http +- xmlrpc +- _thread +- builtins +- configparser +- copyreg +- queue +- reprlib +- socketserver +- ipaddress +- argparse +- enum (also adds this library to Python 3.0-3.3) + +Different Imports (The Bad) ====================== -Using and integrating pies into an existing Python 2.6 code base (to achieve Python 3 dual support) couldn't be simpler: +Some Python3 Modules have moved around so much compared to their Python2 counterpart, that I found it necessary to create special +versions of them to obtain the Python3 naming on both environments. Since these modules exist already in Python2 +allowing them to be imported by the Python3 module name directly is not possible. Instead, you must import these +modules from pies. - from __future__ import absolute_import, division, print_function, unicode_literals +Example: + + form pies import pickle + +Full List: + +- dbm +- urllib +- collections +- functools +- imp +- itertools +- pickle +- StringIO +- sys - from pies import * +Special Syntax (The Ugly) +====================== + +Sadly, there is still special syntax that is present for corner cases. -You will then simply have to make some simple changes to your Python code: +- PY2 - True if running on Python2 +- PY3 - True if running on Python3 +- u('text') - should replace u'text' made available for ease of porting code from Python2 +- itemsview(collection) - should replace collection.iteritems() where you do not control the collection passed in +- valuesview(collection) - should replace collection.values() where you do not control the collection passed in +- keysview(collection) - should replace collection.keys() where you do not control the collection passed in +- execute() - enables Python 3 style exec statements on both environments. +- integer_types - may want to use isinstance(variable, integer_types) instead of type(variable, int) as long values will not match int in Python2. + +What Could be Improved? +====================== -- u'string' -> u('string') -- my_iterable.iteritems -> iteritems(my_iterable) -- my_iterable.itervalues -> itervalues(my_iterable) -- my_iterable.iterkeys -> iterkeys(my_iterable) +I'm pretty sure a bunch. If you run into any problems or have any ideas please don't hesitate to file a bug, submit a pull request, +or email me at timothy.crosley@gmail.com. -The following will work unchanged in Python 3 after import (using the Python 2 syntax): +-------------------------------------------- -- xrange -- long -- unicode -- urllib.quote -- urllib.quote_plus -- urllib.unquote -- urllib.unquote_plus -- urllib.urlencode +Thanks and I hope you enjoy pies! -pies will also automatically install and include the most optimal version of OrderedDict for the Python environment -in use, so you should remove any other explicit imports of OrderedDict. +~Timothy diff --git a/dist/pies-1.0.0.tar.gz b/dist/pies-1.0.0.tar.gz Binary files differdeleted file mode 100644 index 4ddab47..0000000 --- a/dist/pies-1.0.0.tar.gz +++ /dev/null diff --git a/dist/pies-1.0.1.tar.gz b/dist/pies-1.0.1.tar.gz Binary files differdeleted file mode 100644 index a91826a..0000000 --- a/dist/pies-1.0.1.tar.gz +++ /dev/null diff --git a/dist/pies-1.0.2.tar.gz b/dist/pies-1.0.2.tar.gz Binary files differdeleted file mode 100644 index 53f07e9..0000000 --- a/dist/pies-1.0.2.tar.gz +++ /dev/null diff --git a/dist/pies-1.0.3.tar.gz b/dist/pies-1.0.3.tar.gz Binary files differdeleted file mode 100644 index 6ac5bd0..0000000 --- a/dist/pies-1.0.3.tar.gz +++ /dev/null diff --git a/logo.png b/logo.png Binary files differnew file mode 100644 index 0000000..0aeddc2 --- /dev/null +++ b/logo.png diff --git a/logo.xcf b/logo.xcf Binary files differnew file mode 100644 index 0000000..d9e29bc --- /dev/null +++ b/logo.xcf diff --git a/pies.py b/pies.py deleted file mode 100644 index a0f8461..0000000 --- a/pies.py +++ /dev/null @@ -1,77 +0,0 @@ -""" - pies.py - - Adds necessary hooks to allow Python code to run on multiple major versions of Python at once - (currently 2.6 - 3.x) - - Usage: - Anywhere you want to gain support for multiple versions of Python simply add the following line - from pies import * - - Copyright (C) 2013 Timothy Edmund Crosley - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -""" - -import sys - -if sys.version > '3': - import urllib - from urllib import parse - - from collections import OrderedDict - - long = int - unicode = str - - def u(string): - return string - - def iteritems(collection): - return collection.items() - - def itervalues(collection): - return collection.values() - - def iterkeys(collection): - return collection.keys() - - def xrange(*args): - return range(*args) - - urllib.quote = parse.quote - urllib.quote_plus = parse.quote_plus - urllib.unquote = parse.unquote - urllib.unquote_plus = parse.unquote_plus - urllib.urlencode = parse.urlencode -else: - try: - from collections import OrderedDict - except ImportError: - from ordereddict import OrderedDict - - import codecs - - def u(string): - return codecs.unicode_escape_decode(string)[0] - - def iteritems(collection): - return collection.iteritems() - - def itervalues(collection): - return collection.itervalues() - - def iterkeys(collection): - return collection.iterkeys() diff --git a/pies/StringIO.py b/pies/StringIO.py new file mode 100644 index 0000000..fd5ce5e --- /dev/null +++ b/pies/StringIO.py @@ -0,0 +1,11 @@ +from __future__ import absolute_import + +from .version_info import PY3 + +if PY3: + from StringIO import * +else: + try: + from cStringIO import * + except ImportError: + from StringIO import * diff --git a/pies/__init__.py b/pies/__init__.py new file mode 100644 index 0000000..d083f27 --- /dev/null +++ b/pies/__init__.py @@ -0,0 +1,33 @@ +""" + pies/__init__.py + + Adds necessary hooks to allow Python code to run on multiple major versions of Python at once + (currently 2.6 - 3.x) + + Usage: + Anywhere you want to gain support for multiple versions of Python simply add the following two lines + from __future__ import absolute_import, division, print_function, unicode_literals + from pies.overrides import * + + And for changed stdlibs: + from pies import [libname] + + Copyright (C) 2013 Timothy Edmund Crosley + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. +""" + + +from __future__ import absolute_import diff --git a/pies/collections.py b/pies/collections.py new file mode 100644 index 0000000..83e4611 --- /dev/null +++ b/pies/collections.py @@ -0,0 +1,10 @@ +from __future__ import absolute_import + +from collections import * + +from .version_info import PY2 + +if PY2: + from UserString import * + from UserList import * + from ordereddict import OrderedDict diff --git a/pies/dbm/__init__.py b/pies/dbm/__init__.py new file mode 100644 index 0000000..3461248 --- /dev/null +++ b/pies/dbm/__init__.py @@ -0,0 +1,10 @@ +from __future__ import absolute_import + +from dbm import * + +from ..version_info import PY2 + +if PY2: + from . import dumb, gnu, ndbm + from whichdb import * + from anydbm import * diff --git a/pies/dbm/dumb.py b/pies/dbm/dumb.py new file mode 100644 index 0000000..94dc12c --- /dev/null +++ b/pies/dbm/dumb.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from dbm.dumb import * +else: + from dumb import * diff --git a/pies/dbm/gnu.py b/pies/dbm/gnu.py new file mode 100644 index 0000000..5f9c37f --- /dev/null +++ b/pies/dbm/gnu.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from dbm.gnu import * +else: + from gdbm import * diff --git a/pies/dbm/ndbm.py b/pies/dbm/ndbm.py new file mode 100644 index 0000000..fef8c9e --- /dev/null +++ b/pies/dbm/ndbm.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from dbm.ndbm import * +else: + from dbm import * diff --git a/pies/functools.py b/pies/functools.py new file mode 100644 index 0000000..29749cf --- /dev/null +++ b/pies/functools.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from functools import * + +from .version_info import PY2 + +if PY2: + reduce = reduce diff --git a/pies/http/__init__.py b/pies/http/__init__.py new file mode 100644 index 0000000..60b2c7a --- /dev/null +++ b/pies/http/__init__.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from http import * + +from ..version_info import PY2 + +if PY2: + from . import client, cookiejar, cookies, server diff --git a/pies/http/client.py b/pies/http/client.py new file mode 100644 index 0000000..426d978 --- /dev/null +++ b/pies/http/client.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from http.client import * +else: + from httplib import * diff --git a/pies/http/cookiejar b/pies/http/cookiejar new file mode 100644 index 0000000..949f59d --- /dev/null +++ b/pies/http/cookiejar @@ -0,0 +1,6 @@ +from ..version_info import PY3 + +if PY3: + from http.cookiejar import * +else: + from cookielib import *
\ No newline at end of file diff --git a/pies/http/cookies.py b/pies/http/cookies.py new file mode 100644 index 0000000..8108b66 --- /dev/null +++ b/pies/http/cookies.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from http.cookies import * +else: + from Cookie import * diff --git a/pies/http/server.py b/pies/http/server.py new file mode 100644 index 0000000..8702c94 --- /dev/null +++ b/pies/http/server.py @@ -0,0 +1,10 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from http.server import * +else: + from BaseHTTPServer import * + from CGIHTTPServer import * + from SimpleHTTPServer import * diff --git a/pies/imp.py b/pies/imp.py new file mode 100644 index 0000000..8a85e73 --- /dev/null +++ b/pies/imp.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from imp import * + +from .version_info import PY2 + +if PY2: + reload = reload diff --git a/pies/itertools.py b/pies/itertools.py new file mode 100644 index 0000000..40636f1 --- /dev/null +++ b/pies/itertools.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from itertools import * + +from .version_info import PY2 + +if PY2: + filterfalse = ifilterfalse diff --git a/pies/overrides.py b/pies/overrides.py new file mode 100644 index 0000000..6c6157c --- /dev/null +++ b/pies/overrides.py @@ -0,0 +1,200 @@ +""" + pies/overrides.py + + Overrides Python syntax to conform to the Python3 version as much as possible using a '*' import + + Copyright (C) 2013 Timothy Edmund Crosley + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. +""" +from __future__ import absolute_import + +import functools +from numbers import Integral + +from .version_info import PY2, PY3, VERSION + +__version__ = "2.0.0" + +native_dict = dict +native_round = round +native_filter = filter +native_map = map +native_zip = zip +native_range = range +native_str = str +native_chr = chr +native_input = input +native_next = next + +common = ['native_dict', 'native_round', 'native_filter', 'native_map', 'native_range', 'native_str', 'native_chr', + 'native_input', 'PY2', 'PY3', 'u', 'itemsview', 'valuesview', 'keysview', 'execute', 'integer_types', + 'native_next'] + +if PY3: + import urllib + import builtins + from urllib import parse + + from collections import OrderedDict + + integer_types = (int, ) + + def u(string): + return string + + def itemsview(collection): + return collection.items() + + def valuesview(collection): + return collection.values() + + def keysview(collection): + return collection.keys() + + urllib.quote = parse.quote + urllib.quote_plus = parse.quote_plus + urllib.unquote = parse.unquote + urllib.unquote_plus = parse.unquote_plus + urllib.urlencode = parse.urlencode + execute = getattr(builtins, 'exec') + if VERSION[1] < 2: + def callable(entity): + return hasattr(entity, '__call__') + common.append('callable') + + __all__ = common + ['OrderedDict', 'urllib'] +else: + from itertools import ifilter as filter + from itertools import imap as map + from itertools import izip as zip + from decimal import Decimal, ROUND_HALF_EVEN + + + try: + from collections import OrderedDict + except ImportError: + from ordereddict import OrderedDict + + import codecs + str = unicode + chr = unichr + input = raw_input + range = xrange + integer_types = (int, long) + + for removed in ('apply', 'cmp', 'coerce', 'execfile', 'raw_input', 'unpacks'): + def _not_allow(*args, **kwargs): + raise NameError("name '{0}' is not defined".format(removed)) + + _not_allow.__name__ = removed + globals()[removed] = _not_allow + + def u(string): + return codecs.unicode_escape_decode(string[0]) + + def execute(_code_, _globs_=None, _locs_=None): + """Execute code in a namespace.""" + if _globs_ is None: + frame = sys._getframe(1) + _globs_ = frame.f_globals + if _locs_ is None: + _locs_ = frame.f_locals + del frame + elif _locs_ is None: + _locs_ = _globs_ + exec("""exec _code_ in _globs_, _locs_""") + + class _dict_view_base(object): + __slots__ = ('_dictionary', ) + + def __init__(self, dictionary): + self._dictionary = dictionary + + def __repr__(self): + return "{0}({1})".format(self.__class__.__name__, str(list(self.__iter__()))) + + def __unicode__(self): + return str(self.__repr__()) + + def __str__(self): + return str(self.__unicode__()) + + class dict_keys(_dict_view_base): + __slots__ = () + + def __iter__(self): + return self._dictionary.iterkeys() + + class dict_values(_dict_view_base): + __slots__ = () + + def __iter__(self): + return self._dictionary.itervalues() + + class dict_items(_dict_view_base): + __slots__ = () + + def __iter__(self): + return self._dictionary.iteritems() + + def itemsview(collection): + return dict_items(collection) + + def valuesview(collection): + return dict_values(collection) + + def keysview(collection): + return dict_keys(collection) + + class dict(native_dict): + def has_key(self, *args, **kwargs): + return AttributeError("'dict' object has no attribute 'has_key'") + + def items(self): + return dict_items(self) + + def keys(self): + return dict_keys(self) + + def values(self): + return dict_values(self) + + def round(number, ndigits=None): + return_int = False + if ndigits is None: + return_int = True + ndigits = 0 + if hasattr(number, '__round__'): + return number.__round__(ndigits) + + if ndigits < 0: + raise NotImplementedError('negative ndigits not supported yet') + exponent = Decimal('10') ** (-ndigits) + d = Decimal.from_float(number).quantize(exponent, + rounding=ROUND_HALF_EVEN) + if return_int: + return int(d) + else: + return float(d) + + def next(iterator): + try: + iterator.__next__() + except Exception: + native_next(iterator) + + __all__ = common + ['round', 'dict', 'apply', 'cmp', 'coerce', 'execfile', 'raw_input', 'unpacks', 'str', 'chr', + 'input', 'range', 'filter', 'map', 'zip'] diff --git a/pies/pickle.py b/pies/pickle.py new file mode 100644 index 0000000..d606ee7 --- /dev/null +++ b/pies/pickle.py @@ -0,0 +1,11 @@ +from __future__ import absolute_import + +from .version_info import PY3 + +if PY3: + from pickle import * +else: + try: + from cPickle import * + except ImportError: + from pickle import * diff --git a/pies/sys.py b/pies/sys.py new file mode 100644 index 0000000..64087b0 --- /dev/null +++ b/pies/sys.py @@ -0,0 +1,6 @@ +from __future__ import absolute_import + +from sys import * + +if version_info[0] == 2: + intern = intern diff --git a/pies/urllib/__init__.py b/pies/urllib/__init__.py new file mode 100644 index 0000000..d6a12ff --- /dev/null +++ b/pies/urllib/__init__.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from urllib import * + +from ..version_info import PY2 + +if PY2: + from . import error, parse, request, robotparser diff --git a/pies/urllib/error.py b/pies/urllib/error.py new file mode 100644 index 0000000..73c85f1 --- /dev/null +++ b/pies/urllib/error.py @@ -0,0 +1,9 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from urllib.error import * +else: + from urllib import ContentTooShortError + from urllib2 import HTTPError, URLError diff --git a/pies/urllib/parse.py b/pies/urllib/parse.py new file mode 100644 index 0000000..9cbbff3 --- /dev/null +++ b/pies/urllib/parse.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from urllib.parse import * +else: + from urllib import quote, unquote, quote_plus, unquote_plus, urlencode diff --git a/pies/urllib/request.py b/pies/urllib/request.py new file mode 100644 index 0000000..a1470f1 --- /dev/null +++ b/pies/urllib/request.py @@ -0,0 +1,16 @@ + + +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from urllib.request import * +else: + from urllib import FancyURLopener, getproxies, pathname2url, url2pathname, urlcleanup, URLopener, urlretrieve + from urllib2 import (AbstractBasicAuthHandler, AbstractDigestAuthHandler, BaseHandler, build_opener, + CacheFTPHandler, FileHandler, FTPHandler, HTTPBasicAuthHandler, HTTPCookieProcessor, + HTTPDefaultErrorHandler, HTTPDigestAuthHandler, HTTPHandler, HTTPPasswordMgr, + HTTPPasswordMgrWithDefaultRealm, HTTPRedirectHandler, HTTPSHandler, install_opener, + OpenerDirector, ProxyBasicAuthHandler, ProxyDigestAuthHandler, ProxyHandler, Request, + UnknownHandler, urlopen) diff --git a/pies/urllib/robotparser.py b/pies/urllib/robotparser.py new file mode 100644 index 0000000..e45b609 --- /dev/null +++ b/pies/urllib/robotparser.py @@ -0,0 +1,8 @@ +from __future__ import absolute_import + +from ..version_info import PY3 + +if PY3: + from urllib.parse import * +else: + from robotparser import * diff --git a/pies/version_info.py b/pies/version_info.py new file mode 100644 index 0000000..d3547bb --- /dev/null +++ b/pies/version_info.py @@ -0,0 +1,7 @@ +from __future__ import absolute_import + +import sys + +PY2 = sys.version_info[0] == 2 +PY3 = sys.version_info[0] == 3 +VERSION = sys.version_info diff --git a/pies2overrides/MANIFEST b/pies2overrides/MANIFEST index 7156ab1..661cd6a 100644 --- a/pies2overrides/MANIFEST +++ b/pies2overrides/MANIFEST @@ -1,3 +1,19 @@ # file GENERATED by distutils, do NOT edit +_thread.py +builtins.py configparser.py +copyreg.py +queue.py +reprlib.py setup.py +socketserver.py +html/__init__.py +html/entities.py +html/parser.py +http/__init__.py +http/client.py +http/cookiejar.py +http/cookies.py +http/server.py +xmlrpc/__init__.py +xmlrpc/client.py diff --git a/pies2overrides/_thread.py b/pies2overrides/_thread.py new file mode 100644 index 0000000..089dd41 --- /dev/null +++ b/pies2overrides/_thread.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from _thread import * diff --git a/pies2overrides/builtins.py b/pies2overrides/builtins.py new file mode 100644 index 0000000..c9cbd8d --- /dev/null +++ b/pies2overrides/builtins.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from __builtin__ import * diff --git a/pies2overrides/configparser.py b/pies2overrides/configparser.py index b2da53a..4ae03e6 100644 --- a/pies2overrides/configparser.py +++ b/pies2overrides/configparser.py @@ -1 +1,3 @@ +from __future__ import absolute_import + from ConfigParser import * diff --git a/pies2overrides/copyreg.py b/pies2overrides/copyreg.py new file mode 100644 index 0000000..71d2753 --- /dev/null +++ b/pies2overrides/copyreg.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from copy_reg import * diff --git a/pies2overrides/dist/pies2overrides-1.0.0.tar.gz b/pies2overrides/dist/pies2overrides-1.0.0.tar.gz Binary files differdeleted file mode 100644 index a3f449b..0000000 --- a/pies2overrides/dist/pies2overrides-1.0.0.tar.gz +++ /dev/null diff --git a/pies2overrides/html/__init__.py b/pies2overrides/html/__init__.py new file mode 100644 index 0000000..60385f5 --- /dev/null +++ b/pies2overrides/html/__init__.py @@ -0,0 +1,2 @@ + +from __future__ import absolute_import diff --git a/pies2overrides/html/entities.py b/pies2overrides/html/entities.py new file mode 100644 index 0000000..3716d78 --- /dev/null +++ b/pies2overrides/html/entities.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from htmlentitydefs import * diff --git a/pies2overrides/html/parser.py b/pies2overrides/html/parser.py new file mode 100644 index 0000000..b05cfe5 --- /dev/null +++ b/pies2overrides/html/parser.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from HTMLParser import * diff --git a/pies2overrides/http/__init__.py b/pies2overrides/http/__init__.py new file mode 100644 index 0000000..60385f5 --- /dev/null +++ b/pies2overrides/http/__init__.py @@ -0,0 +1,2 @@ + +from __future__ import absolute_import diff --git a/pies2overrides/http/client.py b/pies2overrides/http/client.py new file mode 100644 index 0000000..cdae627 --- /dev/null +++ b/pies2overrides/http/client.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from httplib import * diff --git a/pies2overrides/http/cookiejar.py b/pies2overrides/http/cookiejar.py new file mode 100644 index 0000000..84db840 --- /dev/null +++ b/pies2overrides/http/cookiejar.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from cookielib import * diff --git a/pies2overrides/http/cookies.py b/pies2overrides/http/cookies.py new file mode 100644 index 0000000..bfe863d --- /dev/null +++ b/pies2overrides/http/cookies.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from Cookie import * diff --git a/pies2overrides/http/server.py b/pies2overrides/http/server.py new file mode 100644 index 0000000..38a3336 --- /dev/null +++ b/pies2overrides/http/server.py @@ -0,0 +1,5 @@ +from __future__ import absolute_import + +from BaseHTTPServer import * +from CGIHTTPServer import * +from SimpleHTTPServer import * diff --git a/pies2overrides/queue.py b/pies2overrides/queue.py new file mode 100644 index 0000000..8cd58f3 --- /dev/null +++ b/pies2overrides/queue.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from Queue import * diff --git a/pies2overrides/reprlib.py b/pies2overrides/reprlib.py new file mode 100644 index 0000000..784ad6a --- /dev/null +++ b/pies2overrides/reprlib.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from repr import * diff --git a/pies2overrides/setup.py b/pies2overrides/setup.py index d88ca3c..0f11b50 100644 --- a/pies2overrides/setup.py +++ b/pies2overrides/setup.py @@ -1,15 +1,23 @@ #!/usr/bin/env python +from __future__ import absolute_import + +import sys from distutils.core import setup +install_requires = ['ipaddress'] +if sys.version_info[0] == 2 and sys.version_info[1] < 7: + install_requires += ['ordereddict', 'argparse'] + setup(name='pies2overrides', - version='1.0.0', + version='2.0.0', description='Defines override classes that should be included with pies only if running on Python2.', author='Timothy Crosley', author_email='timothy.crosley@gmail.com', url='https://github.com/timothycrosley/pies', - download_url='https://github.com/timothycrosley/pies/blob/master/pies2overrides/dist/pies2overrides-1.0.0.tar.gz?raw=true', - license="GNU GPLv2", - install_requires=['ordereddict', 'argparse'], - requires=['ordereddict', 'argparse'], - py_modules=['configparser']) + download_url='https://github.com/timothycrosley/pies/blob/master/pies2overrides/dist/pies2overrides-2.0.0.tar.gz?raw=true', + license="MIT", + install_requires=install_requires, + requires=install_requires, + py_modules=['configparser', 'builtins', '_thread', 'copyreg', 'queue', 'reprlib', 'socketserver'], + packages=['html', 'http', 'xmlrpc']) diff --git a/pies2overrides/socketserver.py b/pies2overrides/socketserver.py new file mode 100644 index 0000000..358e776 --- /dev/null +++ b/pies2overrides/socketserver.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from SocketServer import * diff --git a/pies2overrides/xmlrpc/__init__.py b/pies2overrides/xmlrpc/__init__.py new file mode 100644 index 0000000..60385f5 --- /dev/null +++ b/pies2overrides/xmlrpc/__init__.py @@ -0,0 +1,2 @@ + +from __future__ import absolute_import diff --git a/pies2overrides/xmlrpc/client.py b/pies2overrides/xmlrpc/client.py new file mode 100644 index 0000000..73432e5 --- /dev/null +++ b/pies2overrides/xmlrpc/client.py @@ -0,0 +1,3 @@ +from __future__ import absolute_import + +from xmlrpclib import * @@ -1,20 +1,27 @@ #!/usr/bin/env python -from distutils.core import setup +from __future__ import absolute_import + import sys +from distutils.core import setup install_requires = [] -if sys.version < '3': +if sys.version_info[0] < 3: install_requires += ['pies2overrides'] +elif sys.version_info[1] < 2: + install_requires += ['argparse'] + +if sys.version_info[0] < 3 or sys.version_info[1] < 4: + install_requires += ['enum34'] setup(name='pies', - version='1.0.3', + version='2.0.0', description='The simplest way to write one program that runs on both Python 2 and Python 3.', author='Timothy Crosley', author_email='timothy.crosley@gmail.com', url='https://github.com/timothycrosley/pies', download_url='https://github.com/timothycrosley/pies/blob/master/dist/pies-1.0.2.tar.gz?raw=true', - license="GNU GPLv2", + license="MIT", install_requires=install_requires, requires=install_requires, - py_modules=['pies']) + packages=['pies']) |