[Python-modules-commits] [speaklater] 06/10: Add Python3 compatibility patches by Thomas Waldmann from https://github.com/ThomasWaldmann/speaklater

Jan Dittberner jandd at moszumanska.debian.org
Sun Jan 24 13:40:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

jandd pushed a commit to branch master
in repository speaklater.

commit 2dc5753a03bbf9e667e3290ebd725dbb0034301f
Merge: 8e8cf86 1025788
Author: Jan Dittberner <jandd at debian.org>
Date:   Sun Jan 24 14:13:14 2016 +0100

    Add Python3 compatibility patches by Thomas Waldmann from
    https://github.com/ThomasWaldmann/speaklater

 debian/.git-dpm                                    |   4 +-
 debian/changelog                                   |   2 +
 ...figuration-bumped-version-in-setup.py-add.patch |  46 +++++
 ...rt-to-python-3.3-and-also-support-2.6-2.7.patch | 187 +++++++++++++++++++++
 debian/patches/series                              |   2 +
 setup.py                                           |   9 +-
 speaklater.py                                      |  65 ++++---
 tox.ini                                            |   5 +
 8 files changed, 297 insertions(+), 23 deletions(-)

diff --cc debian/.git-dpm
index 9a9cece,0000000..c53e390
mode 100644,000000..100644
--- a/debian/.git-dpm
+++ b/debian/.git-dpm
@@@ -1,11 -1,0 +1,11 @@@
 +# see git-dpm(1) from git-dpm package
- 8204c48ab3176a8e97f65fe7a3bb960222be1ac8
- 8204c48ab3176a8e97f65fe7a3bb960222be1ac8
++1025788455672c2b22ca2f9a3709f8fc84cef4a3
++1025788455672c2b22ca2f9a3709f8fc84cef4a3
 +8204c48ab3176a8e97f65fe7a3bb960222be1ac8
 +8204c48ab3176a8e97f65fe7a3bb960222be1ac8
 +speaklater_1.3.orig.tar.gz
 +65551c6896de20e58dbae795392b7e551ccfe318
 +3582
 +debianTag="debian/%e%v"
 +patchedTag="patched/%e%v"
 +upstreamTag="upstream/%e%u"
diff --cc debian/changelog
index b0ca7f1,0000000..00a40f9
mode 100644,000000..100644
--- a/debian/changelog
+++ b/debian/changelog
@@@ -1,26 -1,0 +1,28 @@@
 +speaklater (1.3-3) UNRELEASED; urgency=medium
 +
 +  * Team upload.
 +  * Add Python3 support
 +  * Bump Standards-Version (no changes)
 +  * use dh-python and pybuild
++  * Add Python3 compatibility patches by Thomas Waldmann from
++    https://github.com/ThomasWaldmann/speaklater
 +
 + -- Jan Dittberner <jandd at debian.org>  Fri, 13 Nov 2015 17:24:29 +0100
 +
 +speaklater (1.3-2) unstable; urgency=low
 +
 +  * Upload to unstable.
 +  * debian/clean: Remove speaklater.egg-info/* to fix FTBFS if built two times
 +    in a row.
 +  * debian/control:
 +    - Bump python Build-Depends to 2.6.6-6~ for .pyremove support.
 +    - Add python-setuptools to Build-Depends for deterministic builds.
 +  * debian/python-speaklater.pyremove: remove SOURCES.txt.
 +
 + -- Sebastian Ramacher <sramacher at debian.org>  Sun, 05 May 2013 13:37:20 +0200
 +
 +speaklater (1.3-1) experimental; urgency=low
 +
 +  * Initial release. (Closes: #703536)
 +
 + -- Sebastian Ramacher <sramacher at debian.org>  Fri, 22 Mar 2013 14:43:32 +0100
diff --cc debian/patches/0001-add-tox-configuration-bumped-version-in-setup.py-add.patch
index 0000000,0000000..20e31fd
new file mode 100644
--- /dev/null
+++ b/debian/patches/0001-add-tox-configuration-bumped-version-in-setup.py-add.patch
@@@ -1,0 -1,0 +1,46 @@@
++From 64386075426e2bc0879430740f35b32fd2257fe7 Mon Sep 17 00:00:00 2001
++From: Thomas Waldmann <tw at waldmann-edv.de>
++Date: Sun, 2 Jun 2013 03:20:23 +0200
++Subject: add tox configuration, bumped version in setup.py, added classifiers
++
++---
++ setup.py | 7 +++++--
++ tox.ini  | 5 +++++
++ 2 files changed, 10 insertions(+), 2 deletions(-)
++ create mode 100644 tox.ini
++
++diff --git a/setup.py b/setup.py
++index 65fa51a..450a23d 100644
++--- a/setup.py
+++++ b/setup.py
++@@ -24,7 +24,7 @@ setup(
++     name='speaklater',
++     author='Armin Ronacher',
++     author_email='armin.ronacher at active-4.com',
++-    version='1.3',
+++    version='1.4',
++     url='http://github.com/mitsuhiko/speaklater',
++     py_modules=['speaklater'],
++     description='implements a lazy string for python useful for use with gettext',
++@@ -34,6 +34,9 @@ setup(
++         'Development Status :: 5 - Production/Stable',
++         'License :: OSI Approved :: BSD License',
++         'Topic :: Software Development :: Internationalization',
++-        'Programming Language :: Python'
+++        'Programming Language :: Python',
+++        'Programming Language :: Python :: 2',
+++        'Programming Language :: Python :: 2.6',
+++        'Programming Language :: Python :: 2.7',
++     ]
++ )
++diff --git a/tox.ini b/tox.ini
++new file mode 100644
++index 0000000..756de95
++--- /dev/null
+++++ b/tox.ini
++@@ -0,0 +1,5 @@
+++[tox]
+++envlist = py26, py27
+++
+++[testenv]
+++commands = python -m doctest -v speaklater.py
diff --cc debian/patches/0002-port-to-python-3.3-and-also-support-2.6-2.7.patch
index 0000000,0000000..3dc2932
new file mode 100644
--- /dev/null
+++ b/debian/patches/0002-port-to-python-3.3-and-also-support-2.6-2.7.patch
@@@ -1,0 -1,0 +1,187 @@@
++From 1025788455672c2b22ca2f9a3709f8fc84cef4a3 Mon Sep 17 00:00:00 2001
++From: Thomas Waldmann <tw at waldmann-edv.de>
++Date: Sun, 2 Jun 2013 04:01:37 +0200
++Subject: port to python 3.3 (and also support 2.6 / 2.7)
++
++added 3.3 to tox, py3 classifiers to setup.py
++added some compatibility wrappers
++adapted doctests so they work the same way on py2 and py3
++changed __repr__ so it gives the same on py2 and py3 (no "u" on py2)
++---
++ setup.py      |  2 ++
++ speaklater.py | 65 ++++++++++++++++++++++++++++++++++++++++++-----------------
++ tox.ini       |  2 +-
++ 3 files changed, 49 insertions(+), 20 deletions(-)
++
++diff --git a/setup.py b/setup.py
++index 450a23d..0e33d1c 100644
++--- a/setup.py
+++++ b/setup.py
++@@ -38,5 +38,7 @@ setup(
++         'Programming Language :: Python :: 2',
++         'Programming Language :: Python :: 2.6',
++         'Programming Language :: Python :: 2.7',
+++        'Programming Language :: Python :: 3',
+++        'Programming Language :: Python :: 3.3',
++     ]
++ )
++diff --git a/speaklater.py b/speaklater.py
++index 67a4dc5..d14f819 100644
++--- a/speaklater.py
+++++ b/speaklater.py
++@@ -12,24 +12,24 @@ r"""
++ 
++     Example:
++ 
++-    >>> from speaklater import make_lazy_string
+++    >>> from speaklater import make_lazy_string, text_type
++     >>> sval = u'Hello World'
++     >>> string = make_lazy_string(lambda: sval)
++ 
++     This lazy string will evaluate to the value of the `sval` variable.
++ 
++     >>> string
++-    lu'Hello World'
++-    >>> unicode(string)
++-    u'Hello World'
++-    >>> string.upper()
++-    u'HELLO WORLD'
+++    l'Hello World'
+++    >>> text_type(string) == u'Hello World'
+++    True
+++    >>> string.upper() == u'HELLO WORLD'
+++    True
++ 
++     If you change the value, the lazy string will change as well:
++ 
++     >>> sval = u'Hallo Welt'
++-    >>> string.upper()
++-    u'HALLO WELT'
+++    >>> string.upper() == u'HALLO WELT'
+++    True
++ 
++     This is especially handy when combined with a thread local and gettext
++     translations or dicts of translatable strings:
++@@ -40,10 +40,10 @@ r"""
++     >>> l.translations = {u'Yes': 'Ja'}
++     >>> lazy_gettext = make_lazy_gettext(lambda: l.translations.get)
++     >>> yes = lazy_gettext(u'Yes')
++-    >>> print yes
+++    >>> print(yes)
++     Ja
++     >>> l.translations[u'Yes'] = u'Si'
++-    >>> print yes
+++    >>> print(yes)
++     Si
++ 
++     Lazy strings are no real strings so if you pass this sort of string to
++@@ -59,6 +59,9 @@ r"""
++     >>> is_lazy_string(yes)
++     True
++ 
+++    New in version 1.4: python >= 3.3 (and also 2.6 and 2.7) support,
+++                        repr(lazystring) is l"foo" on py2 and py3 - no "u" on py2!
+++
++     New in version 1.2: It's now also possible to pass keyword arguments to
++     the callback used with `make_lazy_string`.
++ 
++@@ -66,6 +69,28 @@ r"""
++     :license: BSD, see LICENSE for more details.
++ """
++ 
+++import sys
+++
+++PY2 = sys.version_info[0] == 2
+++_identity = lambda x: x
+++
+++if not PY2:
+++    text_type = str
+++    implements_to_string = _identity
+++    implements_bool = _identity
+++else:
+++    text_type = unicode
+++
+++    def implements_to_string(cls):
+++        cls.__unicode__ = cls.__str__
+++        cls.__str__ = lambda x: x.__unicode__().encode('utf-8')
+++        return cls
+++
+++    def implements_bool(cls):
+++        cls.__nonzero__ = cls.__bool__
+++        del cls.__bool__
+++        return cls
+++
++ 
++ def is_lazy_string(obj):
++     """Checks if the given object is a lazy string."""
++@@ -87,10 +112,10 @@ def make_lazy_gettext(lookup_func):
++     >>> lazy_gettext = make_lazy_gettext(lambda: translations.get)
++     >>> x = lazy_gettext(u'Yes')
++     >>> x
++-    lu'Ja'
+++    l'Ja'
++     >>> translations[u'Yes'] = u'Si'
++     >>> x
++-    lu'Si'
+++    l'Si'
++     """
++     def lazy_gettext(string):
++         if is_lazy_string(string):
++@@ -99,6 +124,8 @@ def make_lazy_gettext(lookup_func):
++     return lazy_gettext
++ 
++ 
+++ at implements_bool
+++ at implements_to_string
++ class _LazyString(object):
++     """Class for strings created by a function call.
++ 
++@@ -117,11 +144,11 @@ class _LazyString(object):
++     def __contains__(self, key):
++         return key in self.value
++ 
++-    def __nonzero__(self):
+++    def __bool__(self):
++         return bool(self.value)
++ 
++     def __dir__(self):
++-        return dir(unicode)
+++        return dir(text_type)
++ 
++     def __iter__(self):
++         return iter(self.value)
++@@ -130,10 +157,7 @@ class _LazyString(object):
++         return len(self.value)
++ 
++     def __str__(self):
++-        return str(self.value)
++-
++-    def __unicode__(self):
++-        return unicode(self.value)
+++        return text_type(self.value)
++ 
++     def __add__(self, other):
++         return self.value + other
++@@ -190,7 +214,10 @@ class _LazyString(object):
++ 
++     def __repr__(self):
++         try:
++-            return 'l' + repr(self.value)
+++            r = repr(self.value)
+++            if PY2 and r.startswith('u'):
+++                r = r[1:]  # make it look same as on py3
+++            return 'l' + r
++         except Exception:
++             return '<%s broken>' % self.__class__.__name__
++ 
++diff --git a/tox.ini b/tox.ini
++index 756de95..af0c839 100644
++--- a/tox.ini
+++++ b/tox.ini
++@@ -1,5 +1,5 @@
++ [tox]
++-envlist = py26, py27
+++envlist = py26, py27, py33
++ 
++ [testenv]
++ commands = python -m doctest -v speaklater.py
diff --cc debian/patches/series
index 0000000,0000000..52f2822
new file mode 100644
--- /dev/null
+++ b/debian/patches/series
@@@ -1,0 -1,0 +1,2 @@@
++0001-add-tox-configuration-bumped-version-in-setup.py-add.patch
++0002-port-to-python-3.3-and-also-support-2.6-2.7.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/speaklater.git



More information about the Python-modules-commits mailing list