[Python-modules-commits] [python-nine] 01/06: New upstream version 1.0.0
Takaki Taniguchi
takaki at moszumanska.debian.org
Tue Oct 11 04:34:15 UTC 2016
This is an automated email from the git hooks/post-receive script.
takaki pushed a commit to branch master
in repository python-nine.
commit 5e90826c6df5a296b53c1740659a3ae04c5f6679
Author: TANIGUCHI Takaki <takaki at asis.media-as.org>
Date: Tue Oct 11 13:23:38 2016 +0900
New upstream version 1.0.0
---
LICENSE.rst | 2 +-
PKG-INFO | 133 +++++++++++++++++++++++++++++++++++++++++-----
README.rst | 129 +++++++++++++++++++++++++++++++++++++++-----
nine.egg-info/PKG-INFO | 133 +++++++++++++++++++++++++++++++++++++++++-----
nine.egg-info/SOURCES.txt | 2 +-
nine/__init__.py | 37 +++++++------
nine/test_nine.py | 1 +
porting.rst | 21 --------
setup.cfg | 3 ++
setup.py | 9 ++--
10 files changed, 391 insertions(+), 79 deletions(-)
diff --git a/LICENSE.rst b/LICENSE.rst
index ec2f376..0358714 100644
--- a/LICENSE.rst
+++ b/LICENSE.rst
@@ -1,3 +1,3 @@
I, the copyright holder of this work, hereby release it into the public domain. This applies worldwide.
-In case this is not legally possible, I grant any entity the right to use, modify and redistribute this work for any purpose, without any conditions, unless such conditions are required by law.
+In case this is not legally possible, I grant any entity the right to use, modify and redistribute this work for any purpose, without any conditions.
diff --git a/PKG-INFO b/PKG-INFO
index 2ad6228..0a4c6ba 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: nine
-Version: 0.3.4
+Version: 1.0.0
Summary: Python 2 / 3 compatibility, like six, but favouring Python 3
Home-page: https://github.com/nandoflorestan/nine
Author: Nando Florestan
@@ -14,19 +14,27 @@ Description: Let's write Python 3 right now!
-- were created, they were written from the point of view of a Python 2
programmer starting to grok Python 3.
- It is 2013.
+ But it is 2016. Python 3.5 is here. 3.5!!!
- Python 3.3 is here.
+ If you use *six*, your code is compatible, but stuck in Python 2 idioms.
- When thou writeth Python, thou shalt write Python 3 and, just for a while,
- ensure that the thing worketh on Python 2.7 and, possibly, even 2.6.
+ **nine** turns **six** upside down. You write your code using Python 3 idioms
+ -- as much as possible --, and it is the Python 2 "version" that is patched.
+ Needless to say, this approach is more future-proof.
- Just before Python 2 is finally phased out, thine codebase shall
- look more like 3 than like 2.
+ When thou writeth Python, thou shalt write Python 3 and,
+ just for a little longer, ensure that the thing worketh on Python 2.7.
- *nine* facilitates this new point of view. You can write code
+ Honestly you should not spend one thought on Python 2.6 anymore, it is
+ `no longer supported <https://mail.python.org/pipermail/python-dev/2013-September/128287.html>`_
+ since its final release (2.6.9) in October 2013. Nobody uses 3.0 or 3.1 either.
+
+ Python 2.7 will finally meet its demise in the year 2020. So, starting now,
+ thine codebase shall look more like 3 than 2.
+
+ *nine* facilitates this point of view. You can write code
that is as 3ish as possible while still supporting 2.6.
- Very comfortable for writing new projects.
+ Very comfortable for new projects.
For instance, you don't type ``unicode`` anymore, you type ``str``, and *nine*
makes ``str`` point to ``unicode`` on Python 2 (if you use our boilerplate).
@@ -39,10 +47,12 @@ Description: Let's write Python 3 right now!
in a single codebase, I recommend reading this:
http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/
+
Using nine
==========
- In your code, start by importing Python 3 behaviours from __future__.
+ In each of your modules, start by declaring a text encoding and
+ importing Python 3 behaviours from __future__.
Then import variables from *nine*, as per this boilerplate::
# -*- coding: utf-8 -*-
@@ -54,12 +64,43 @@ Description: Let's write Python 3 right now!
implements_iterator, implements_to_string, implements_repr, nine,
nimport)
+ I know that is ugly. What did you expect? *nine* is 3 squared.
+ OK, in many cases you can get away with less::
+
+ # -*- coding: utf-8 -*-
+
+ from __future__ import (absolute_import, division, print_function,
+ unicode_literals)
+ from nine import IS_PYTHON2, nimport, nine, range, str, basestring
+
+ But in the second case you need to remember to import the missing stuff when
+ you use it, and it is not realistic to expect that you will remember, is it?
+
+
+ Unicode
+ =======
+
+ Because of the ``unicode_literals`` import, **all string literals in the module
+ become unicode objects**. No need to add a "u" prefix to each string literal.
+ This is the saner approach since in Python 3 strings are unicode objects
+ by default, and you can then indicate ``b"this is a byte string literal"``.
+ The literals that actually need to be byte strings are very rare.
+ But you wouldn't believe how many developers are irrationally afraid
+ of taking this simple step...
+
+ If you don't know much about Unicode, just read
+ `The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) <http://www.joelonsoftware.com/articles/Unicode.html>`_
+
+
Importing moved stuff
=====================
- Next, we deal with the problem of importing moved names. For instance,
- instead of writing this to import pickle::
+ Many standard library modules were renamed in Python 3, but nine can
+ help. The ``nimport`` function gets the new Python 3 name, but knows to
+ import the old name if running in Python 2.
+ For instance, instead of writing this to import pickle::
+ # Bad:
try:
import cPickle as pickle # Python 2.x
except ImportError:
@@ -67,6 +108,7 @@ Description: Let's write Python 3 right now!
...you can write this::
+ # Good:
pickle = nimport('pickle')
For variables that have been moved: In the argument, please separate the module
@@ -76,6 +118,7 @@ Description: Let's write Python 3 right now!
Want StringIO? I recommend you build lists instead. But if you really need it::
+ # Good:
if IS_PYTHON2:
from cStringIO import StringIO as BytesIO, StringIO
NativeStringIO = BytesIO
@@ -90,9 +133,71 @@ Description: Let's write Python 3 right now!
`use the source <https://github.com/nandoflorestan/nine/blob/master/nine/__init__.py>`_!
See the
- `project page at GitHub <https://github.com/nandoflorestan/nine>`_! We also have
+ `project page at GitHub <https://github.com/nandoflorestan/nine>`_!
+ We also have
`continuous integration at Travis-CI <https://travis-ci.org/nandoflorestan/nine>`_.
+
+ The *nine* class decorator
+ ==========================
+
+ We provide a class decorator for Python 2 and 3 compatibility of magic methods.
+ Magic methods are those that start and end with two underlines.
+
+ You define the magic methods with their Python 3 names and,
+ on Python 2, they get their corresponding names. You may write:
+
+ * ``__next__()``. Use the ``next(iterator)`` function to iterate.
+ * ``__str__()``: must return a unicode string. In Python 2, we implement
+ ``__unicode__()`` and ``__bytes__()`` for you, based on your ``__str__()``.
+ * ``__repr__()``: must return a unicode string.
+ * ``__bytes__()``: must return a bytes object.
+
+ Example::
+
+ @nine
+ class MyClass(object):
+
+ def __str__(self):
+ return "MyClass" # a unicode string
+
+
+ Porting steps
+ =============
+
+ When you are starting to apply *nine* on Python 2 code to achieve Python 3
+ compatibility, you can start by following this list of tasks. It isn't
+ exhaustive, just a good start. You can upgrade one ``.py`` module at a time:
+
+ * Add our header as mentioned above.
+ * Replace ocurrences of the print statement with the print function
+ (this roughly means, add parentheses).
+ * Replace ``str()``, usually with nine's ``native_str()`` or with ``bytes()``.
+ * Replace ``unicode()`` with ``str()`` and ``from nine import str``
+ * Replace ``__unicode__()`` methods with ``__str__()`` methods;
+ apply the ``@nine`` decorator on the class.
+ * Also apply the ``@nine`` decorator on classes that define ``__repr__()``.
+ * Search for ``range`` and replace with nine's ``range`` or ``range_list``
+ * Some dict methods return different things in Python 3. Only if you need
+ exactly the same behavior in both versions, replace:
+
+ * ``d.keys()`` or ``d.iterkeys()`` with nine's ``iterkeys(d)``;
+ * ``d.values()`` or ``d.itervalues()`` with nine's ``itervalues(d)``; and
+ * ``d.items()`` or ``d.iteritems()`` with nine's ``iteritems(d)``.
+
+ * Notice that ``map()``, ``zip()`` and ``filter()``, in nine's versions,
+ always return iterators independently of Python version.
+
+ If you had been using *six* or another compatibility library before:
+
+ * Replace ``string_types`` with nine's ``basestring``
+
+ Then run your tests in all the Python versions you wish to support.
+
+ If I forgot to mention anything, could you
+ `make a pull request <https://github.com/nandoflorestan/nine>`_, for the
+ benefit of other developers?
+
Keywords: python 2,python 3,python2,python3,migration,compatibility,nine,six,2to3,3to2,future
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
@@ -106,3 +211,5 @@ Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
diff --git a/README.rst b/README.rst
index 1942bdb..b7c6c12 100644
--- a/README.rst
+++ b/README.rst
@@ -6,19 +6,27 @@ When the best Python 2/Python 3 compatibility modules -- especially the famous
-- were created, they were written from the point of view of a Python 2
programmer starting to grok Python 3.
-It is 2013.
+But it is 2016. Python 3.5 is here. 3.5!!!
-Python 3.3 is here.
+If you use *six*, your code is compatible, but stuck in Python 2 idioms.
-When thou writeth Python, thou shalt write Python 3 and, just for a while,
-ensure that the thing worketh on Python 2.7 and, possibly, even 2.6.
+**nine** turns **six** upside down. You write your code using Python 3 idioms
+-- as much as possible --, and it is the Python 2 "version" that is patched.
+Needless to say, this approach is more future-proof.
-Just before Python 2 is finally phased out, thine codebase shall
-look more like 3 than like 2.
+When thou writeth Python, thou shalt write Python 3 and,
+just for a little longer, ensure that the thing worketh on Python 2.7.
-*nine* facilitates this new point of view. You can write code
+Honestly you should not spend one thought on Python 2.6 anymore, it is
+`no longer supported <https://mail.python.org/pipermail/python-dev/2013-September/128287.html>`_
+since its final release (2.6.9) in October 2013. Nobody uses 3.0 or 3.1 either.
+
+Python 2.7 will finally meet its demise in the year 2020. So, starting now,
+thine codebase shall look more like 3 than 2.
+
+*nine* facilitates this point of view. You can write code
that is as 3ish as possible while still supporting 2.6.
-Very comfortable for writing new projects.
+Very comfortable for new projects.
For instance, you don't type ``unicode`` anymore, you type ``str``, and *nine*
makes ``str`` point to ``unicode`` on Python 2 (if you use our boilerplate).
@@ -31,10 +39,12 @@ To understand most of the intricacies involved in achieving 2&3 compatibility
in a single codebase, I recommend reading this:
http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/
+
Using nine
==========
-In your code, start by importing Python 3 behaviours from __future__.
+In each of your modules, start by declaring a text encoding and
+importing Python 3 behaviours from __future__.
Then import variables from *nine*, as per this boilerplate::
# -*- coding: utf-8 -*-
@@ -46,12 +56,43 @@ Then import variables from *nine*, as per this boilerplate::
implements_iterator, implements_to_string, implements_repr, nine,
nimport)
+I know that is ugly. What did you expect? *nine* is 3 squared.
+OK, in many cases you can get away with less::
+
+ # -*- coding: utf-8 -*-
+
+ from __future__ import (absolute_import, division, print_function,
+ unicode_literals)
+ from nine import IS_PYTHON2, nimport, nine, range, str, basestring
+
+But in the second case you need to remember to import the missing stuff when
+you use it, and it is not realistic to expect that you will remember, is it?
+
+
+Unicode
+=======
+
+Because of the ``unicode_literals`` import, **all string literals in the module
+become unicode objects**. No need to add a "u" prefix to each string literal.
+This is the saner approach since in Python 3 strings are unicode objects
+by default, and you can then indicate ``b"this is a byte string literal"``.
+The literals that actually need to be byte strings are very rare.
+But you wouldn't believe how many developers are irrationally afraid
+of taking this simple step...
+
+If you don't know much about Unicode, just read
+`The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) <http://www.joelonsoftware.com/articles/Unicode.html>`_
+
+
Importing moved stuff
=====================
-Next, we deal with the problem of importing moved names. For instance,
-instead of writing this to import pickle::
+Many standard library modules were renamed in Python 3, but nine can
+help. The ``nimport`` function gets the new Python 3 name, but knows to
+import the old name if running in Python 2.
+For instance, instead of writing this to import pickle::
+ # Bad:
try:
import cPickle as pickle # Python 2.x
except ImportError:
@@ -59,6 +100,7 @@ instead of writing this to import pickle::
...you can write this::
+ # Good:
pickle = nimport('pickle')
For variables that have been moved: In the argument, please separate the module
@@ -68,6 +110,7 @@ from the variable with a colon::
Want StringIO? I recommend you build lists instead. But if you really need it::
+ # Good:
if IS_PYTHON2:
from cStringIO import StringIO as BytesIO, StringIO
NativeStringIO = BytesIO
@@ -82,5 +125,67 @@ When in doubt,
`use the source <https://github.com/nandoflorestan/nine/blob/master/nine/__init__.py>`_!
See the
-`project page at GitHub <https://github.com/nandoflorestan/nine>`_! We also have
+`project page at GitHub <https://github.com/nandoflorestan/nine>`_!
+We also have
`continuous integration at Travis-CI <https://travis-ci.org/nandoflorestan/nine>`_.
+
+
+The *nine* class decorator
+==========================
+
+We provide a class decorator for Python 2 and 3 compatibility of magic methods.
+Magic methods are those that start and end with two underlines.
+
+You define the magic methods with their Python 3 names and,
+on Python 2, they get their corresponding names. You may write:
+
+* ``__next__()``. Use the ``next(iterator)`` function to iterate.
+* ``__str__()``: must return a unicode string. In Python 2, we implement
+ ``__unicode__()`` and ``__bytes__()`` for you, based on your ``__str__()``.
+* ``__repr__()``: must return a unicode string.
+* ``__bytes__()``: must return a bytes object.
+
+Example::
+
+ @nine
+ class MyClass(object):
+
+ def __str__(self):
+ return "MyClass" # a unicode string
+
+
+Porting steps
+=============
+
+When you are starting to apply *nine* on Python 2 code to achieve Python 3
+compatibility, you can start by following this list of tasks. It isn't
+exhaustive, just a good start. You can upgrade one ``.py`` module at a time:
+
+* Add our header as mentioned above.
+* Replace ocurrences of the print statement with the print function
+ (this roughly means, add parentheses).
+* Replace ``str()``, usually with nine's ``native_str()`` or with ``bytes()``.
+* Replace ``unicode()`` with ``str()`` and ``from nine import str``
+* Replace ``__unicode__()`` methods with ``__str__()`` methods;
+ apply the ``@nine`` decorator on the class.
+* Also apply the ``@nine`` decorator on classes that define ``__repr__()``.
+* Search for ``range`` and replace with nine's ``range`` or ``range_list``
+* Some dict methods return different things in Python 3. Only if you need
+ exactly the same behavior in both versions, replace:
+
+ * ``d.keys()`` or ``d.iterkeys()`` with nine's ``iterkeys(d)``;
+ * ``d.values()`` or ``d.itervalues()`` with nine's ``itervalues(d)``; and
+ * ``d.items()`` or ``d.iteritems()`` with nine's ``iteritems(d)``.
+
+* Notice that ``map()``, ``zip()`` and ``filter()``, in nine's versions,
+ always return iterators independently of Python version.
+
+If you had been using *six* or another compatibility library before:
+
+* Replace ``string_types`` with nine's ``basestring``
+
+Then run your tests in all the Python versions you wish to support.
+
+If I forgot to mention anything, could you
+`make a pull request <https://github.com/nandoflorestan/nine>`_, for the
+benefit of other developers?
diff --git a/nine.egg-info/PKG-INFO b/nine.egg-info/PKG-INFO
index 2ad6228..0a4c6ba 100644
--- a/nine.egg-info/PKG-INFO
+++ b/nine.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: nine
-Version: 0.3.4
+Version: 1.0.0
Summary: Python 2 / 3 compatibility, like six, but favouring Python 3
Home-page: https://github.com/nandoflorestan/nine
Author: Nando Florestan
@@ -14,19 +14,27 @@ Description: Let's write Python 3 right now!
-- were created, they were written from the point of view of a Python 2
programmer starting to grok Python 3.
- It is 2013.
+ But it is 2016. Python 3.5 is here. 3.5!!!
- Python 3.3 is here.
+ If you use *six*, your code is compatible, but stuck in Python 2 idioms.
- When thou writeth Python, thou shalt write Python 3 and, just for a while,
- ensure that the thing worketh on Python 2.7 and, possibly, even 2.6.
+ **nine** turns **six** upside down. You write your code using Python 3 idioms
+ -- as much as possible --, and it is the Python 2 "version" that is patched.
+ Needless to say, this approach is more future-proof.
- Just before Python 2 is finally phased out, thine codebase shall
- look more like 3 than like 2.
+ When thou writeth Python, thou shalt write Python 3 and,
+ just for a little longer, ensure that the thing worketh on Python 2.7.
- *nine* facilitates this new point of view. You can write code
+ Honestly you should not spend one thought on Python 2.6 anymore, it is
+ `no longer supported <https://mail.python.org/pipermail/python-dev/2013-September/128287.html>`_
+ since its final release (2.6.9) in October 2013. Nobody uses 3.0 or 3.1 either.
+
+ Python 2.7 will finally meet its demise in the year 2020. So, starting now,
+ thine codebase shall look more like 3 than 2.
+
+ *nine* facilitates this point of view. You can write code
that is as 3ish as possible while still supporting 2.6.
- Very comfortable for writing new projects.
+ Very comfortable for new projects.
For instance, you don't type ``unicode`` anymore, you type ``str``, and *nine*
makes ``str`` point to ``unicode`` on Python 2 (if you use our boilerplate).
@@ -39,10 +47,12 @@ Description: Let's write Python 3 right now!
in a single codebase, I recommend reading this:
http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/
+
Using nine
==========
- In your code, start by importing Python 3 behaviours from __future__.
+ In each of your modules, start by declaring a text encoding and
+ importing Python 3 behaviours from __future__.
Then import variables from *nine*, as per this boilerplate::
# -*- coding: utf-8 -*-
@@ -54,12 +64,43 @@ Description: Let's write Python 3 right now!
implements_iterator, implements_to_string, implements_repr, nine,
nimport)
+ I know that is ugly. What did you expect? *nine* is 3 squared.
+ OK, in many cases you can get away with less::
+
+ # -*- coding: utf-8 -*-
+
+ from __future__ import (absolute_import, division, print_function,
+ unicode_literals)
+ from nine import IS_PYTHON2, nimport, nine, range, str, basestring
+
+ But in the second case you need to remember to import the missing stuff when
+ you use it, and it is not realistic to expect that you will remember, is it?
+
+
+ Unicode
+ =======
+
+ Because of the ``unicode_literals`` import, **all string literals in the module
+ become unicode objects**. No need to add a "u" prefix to each string literal.
+ This is the saner approach since in Python 3 strings are unicode objects
+ by default, and you can then indicate ``b"this is a byte string literal"``.
+ The literals that actually need to be byte strings are very rare.
+ But you wouldn't believe how many developers are irrationally afraid
+ of taking this simple step...
+
+ If you don't know much about Unicode, just read
+ `The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) <http://www.joelonsoftware.com/articles/Unicode.html>`_
+
+
Importing moved stuff
=====================
- Next, we deal with the problem of importing moved names. For instance,
- instead of writing this to import pickle::
+ Many standard library modules were renamed in Python 3, but nine can
+ help. The ``nimport`` function gets the new Python 3 name, but knows to
+ import the old name if running in Python 2.
+ For instance, instead of writing this to import pickle::
+ # Bad:
try:
import cPickle as pickle # Python 2.x
except ImportError:
@@ -67,6 +108,7 @@ Description: Let's write Python 3 right now!
...you can write this::
+ # Good:
pickle = nimport('pickle')
For variables that have been moved: In the argument, please separate the module
@@ -76,6 +118,7 @@ Description: Let's write Python 3 right now!
Want StringIO? I recommend you build lists instead. But if you really need it::
+ # Good:
if IS_PYTHON2:
from cStringIO import StringIO as BytesIO, StringIO
NativeStringIO = BytesIO
@@ -90,9 +133,71 @@ Description: Let's write Python 3 right now!
`use the source <https://github.com/nandoflorestan/nine/blob/master/nine/__init__.py>`_!
See the
- `project page at GitHub <https://github.com/nandoflorestan/nine>`_! We also have
+ `project page at GitHub <https://github.com/nandoflorestan/nine>`_!
+ We also have
`continuous integration at Travis-CI <https://travis-ci.org/nandoflorestan/nine>`_.
+
+ The *nine* class decorator
+ ==========================
+
+ We provide a class decorator for Python 2 and 3 compatibility of magic methods.
+ Magic methods are those that start and end with two underlines.
+
+ You define the magic methods with their Python 3 names and,
+ on Python 2, they get their corresponding names. You may write:
+
+ * ``__next__()``. Use the ``next(iterator)`` function to iterate.
+ * ``__str__()``: must return a unicode string. In Python 2, we implement
+ ``__unicode__()`` and ``__bytes__()`` for you, based on your ``__str__()``.
+ * ``__repr__()``: must return a unicode string.
+ * ``__bytes__()``: must return a bytes object.
+
+ Example::
+
+ @nine
+ class MyClass(object):
+
+ def __str__(self):
+ return "MyClass" # a unicode string
+
+
+ Porting steps
+ =============
+
+ When you are starting to apply *nine* on Python 2 code to achieve Python 3
+ compatibility, you can start by following this list of tasks. It isn't
+ exhaustive, just a good start. You can upgrade one ``.py`` module at a time:
+
+ * Add our header as mentioned above.
+ * Replace ocurrences of the print statement with the print function
+ (this roughly means, add parentheses).
+ * Replace ``str()``, usually with nine's ``native_str()`` or with ``bytes()``.
+ * Replace ``unicode()`` with ``str()`` and ``from nine import str``
+ * Replace ``__unicode__()`` methods with ``__str__()`` methods;
+ apply the ``@nine`` decorator on the class.
+ * Also apply the ``@nine`` decorator on classes that define ``__repr__()``.
+ * Search for ``range`` and replace with nine's ``range`` or ``range_list``
+ * Some dict methods return different things in Python 3. Only if you need
+ exactly the same behavior in both versions, replace:
+
+ * ``d.keys()`` or ``d.iterkeys()`` with nine's ``iterkeys(d)``;
+ * ``d.values()`` or ``d.itervalues()`` with nine's ``itervalues(d)``; and
+ * ``d.items()`` or ``d.iteritems()`` with nine's ``iteritems(d)``.
+
+ * Notice that ``map()``, ``zip()`` and ``filter()``, in nine's versions,
+ always return iterators independently of Python version.
+
+ If you had been using *six* or another compatibility library before:
+
+ * Replace ``string_types`` with nine's ``basestring``
+
+ Then run your tests in all the Python versions you wish to support.
+
+ If I forgot to mention anything, could you
+ `make a pull request <https://github.com/nandoflorestan/nine>`_, for the
+ benefit of other developers?
+
Keywords: python 2,python 3,python2,python3,migration,compatibility,nine,six,2to3,3to2,future
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
@@ -106,3 +211,5 @@ Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
diff --git a/nine.egg-info/SOURCES.txt b/nine.egg-info/SOURCES.txt
index e51d450..357a787 100644
--- a/nine.egg-info/SOURCES.txt
+++ b/nine.egg-info/SOURCES.txt
@@ -1,7 +1,7 @@
LICENSE.rst
MANIFEST.in
README.rst
-porting.rst
+setup.cfg
setup.py
nine/__init__.py
nine/decorator.py
diff --git a/nine/__init__.py b/nine/__init__.py
index d1aed75..3607562 100644
--- a/nine/__init__.py
+++ b/nine/__init__.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
-'''For documentation and usage, please see the file README.rst.
+"""For documentation and usage, please see the file README.rst.
This module is donated to the public domain.
-'''
+"""
import sys
# Test for Python 2, not 3; don't get bitten when Python 4 appears:
@@ -59,28 +59,31 @@ else:
# ===== Class decorators =====
if IS_PYTHON2:
def implements_to_string(cls):
- '''Class decorator. You define __str__() and it is moved to
- __unicode__() on Python 2.
+ """Class decorator that converts __str__() and __bytes__.
+
+ You define __str__() and it is moved to __unicode__() on Python 2.
Additionally, if you define __bytes__(), it becomes __str__() on
Python 2. If __bytes__() is not defined, __str__() executes
__unicode__() and encodes the result to utf-8.
- '''
+ """
cls.__unicode__ = cls.__str__
cls.__str__ = cls.__bytes__ if hasattr(cls, '__bytes__') \
else lambda x: x.__unicode__().encode('utf-8')
return cls
def implements_iterator(cls):
- '''Class decorator. next() has been renamed to __next__().'''
+ """Class decorator. next() has been renamed to __next__()."""
cls.next = cls.__next__
del cls.__next__
return cls
def implements_repr(cls):
- '''Class decorator. You implement __repr__() returning a
- unicode string, and in Python 2, I encode it for you.
- '''
+ """Class decorator that wraps __repr__() in Python 2.
+
+ You implement __repr__() returning a unicode string,
+ and in Python 2, I encode it to utf-8 for you.
+ """
cls.__repr_unicode__ = cls.__repr__
def wrapper(self):
@@ -89,7 +92,8 @@ if IS_PYTHON2:
return cls
def nine(cls):
- '''Class decorator for Python 2 and 3 compatibility of magic methods.
+ """Class decorator for Python 2 and 3 compatibility of magic methods.
+
You define the magic methods with their Python 3 names and,
on Python 2, they get their corresponding names. You may write:
@@ -99,7 +103,7 @@ if IS_PYTHON2:
* __bytes__(): must return a bytes object.
(*nine* is all the above class decorators in one.)
- '''
+ """
if hasattr(cls, '__str__'):
cls = implements_to_string(cls)
if hasattr(cls, '__next__'):
@@ -183,15 +187,18 @@ _moved = { # Mapping from Python 3 to Python 2 location. May need improvement.
def nimport(spec):
- '''Given a spec such as "os.path:join", imports either a module or
- a name from a module, and returns it. Example usage::
+ """Given a Python 3 resource spec, imports and returns it.
+
+ Example usage::
join = nimport('os.path:join')
- The spec should provide the new location of the module or variable.
+ The ":" indicates "join" is a variable in the module "os.path".
+
+ The spec should provide the **new** location of the module or variable.
*nine* is supposed to know the corresponding, old Python 2 location.
Bug reports and pull requests are welcome.
- '''
+ """
assert spec
if IS_PYTHON2: # Get the Python 2 location of the name, first.
spec = _moved.get(spec, spec)
diff --git a/nine/test_nine.py b/nine/test_nine.py
index dc338aa..2416691 100644
--- a/nine/test_nine.py
+++ b/nine/test_nine.py
@@ -8,6 +8,7 @@ import unittest
class TestNine(unittest.TestCase):
+
def test_import(self):
from nine import (
IS_PYTHON2, str, basestring, native_str,
diff --git a/porting.rst b/porting.rst
deleted file mode 100644
index 090c111..0000000
--- a/porting.rst
+++ /dev/null
@@ -1,21 +0,0 @@
-When you are starting to apply *nine* on Python 2 code to achieve Python 3
-compatibility, you can start by following this list of tasks. It isn't
-exhaustive, just a good start:
-
-* Replace str(), usually with nine's native_str() or with bytes()
-* Replace unicode() with str() and ``from nine import str``
-* Replace __unicode__() with __str__(); apply the *nine* decorator on the class
-* Apply the *nine* decorator on classes that define __repr__()
-* Search for *range* and replace with nine's *range* or *range_list*
-* Where performance matters, replace d.keys() or d.iterkeys()
- with nine's *iterkeys(d)*
-* Where performance matters, replace d.values() or d.itervalues()
- with nine's *itervalues(d)*
-* Where performance matters, replace d.items() or d.iteritems()
- with nine's *iteritems(d)*
-* Where performance matters, replace map(), zip() and filter() with
- nine's versions (which always return iterators).
-
-If you had been using *six* or another library before:
-
-* Replace ``string_types`` with nine's ``basestring``
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..6f08d0e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,3 +1,6 @@
+[bdist_wheel]
+universal = 1
+
[egg_info]
tag_build =
tag_date = 0
diff --git a/setup.py b/setup.py
index 6673702..9769503 100755
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@ if version_info[:2] < (2, 7):
setup(
name="nine",
- version='0.3.4',
+ version='1.0.0',
description="Python 2 / 3 compatibility, like six, but favouring Python 3",
long_description=long_description,
url='https://github.com/nandoflorestan/nine',
@@ -29,8 +29,9 @@ setup(
zip_safe=False,
test_suite='nine',
install_requires=requires,
- keywords=["python 2", 'python 3', 'python2', 'python3', 'migration',
- 'compatibility', 'nine', 'six', '2to3', '3to2', 'future',
+ keywords=[
+ "python 2", 'python 3', 'python2', 'python3', 'migration',
+ 'compatibility', 'nine', 'six', '2to3', '3to2', 'future',
],
classifiers=[ # http://pypi.python.org/pypi?:action=list_classifiers
"Development Status :: 5 - Production/Stable",
@@ -44,5 +45,7 @@ setup(
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
+ "Programming Language :: Python :: 3.4",
+ "Programming Language :: Python :: 3.5",
],
)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-nine.git
More information about the Python-modules-commits
mailing list