[python-blessings] initial version

Dan Callaghan dcallagh at fedoraproject.org
Mon Dec 10 22:31:19 UTC 2012


commit 70a8475708dd3b54c05bcf9941c48897208ea95c
Author: Dan Callaghan <dcallagh at redhat.com>
Date:   Fri Nov 30 15:09:36 2012 +1000

    initial version

 .gitignore                            |    1 +
 blessings-1.5-tests-without-tty.patch |   66 ++++++++++++++++++++++
 python-blessings.spec                 |   96 +++++++++++++++++++++++++++++++++
 sources                               |    1 +
 4 files changed, 164 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..27677d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/blessings-1.5.tar.gz
diff --git a/blessings-1.5-tests-without-tty.patch b/blessings-1.5-tests-without-tty.patch
new file mode 100644
index 0000000..a36c11b
--- /dev/null
+++ b/blessings-1.5-tests-without-tty.patch
@@ -0,0 +1,66 @@
+From ba9489d42e8535435e76e97d0da792998abc893e Mon Sep 17 00:00:00 2001
+From: Dan Callaghan <dcallagh at redhat.com>
+Date: Fri, 30 Nov 2012 14:05:04 +1000
+Subject: [PATCH] fix tests when run without a tty (fixes #25)
+
+---
+ blessings/__init__.py | 2 +-
+ blessings/tests.py    | 8 +++++---
+ 2 files changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/blessings/__init__.py b/blessings/__init__.py
+index 68212c2..e1adbda 100644
+--- a/blessings/__init__.py
++++ b/blessings/__init__.py
+@@ -448,7 +448,7 @@ class NullCallableString(unicode):
+         new = unicode.__new__(cls, u'')
+         return new
+ 
+-    def __call__(self, arg):
++    def __call__(self, arg, *extra_args):
+         if isinstance(arg, int):
+             return u''
+         return arg  # TODO: Force even strs in Python 2.x to be unicodes? Nah. How would I know what encoding to use to convert it?
+diff --git a/blessings/tests.py b/blessings/tests.py
+index a885c65..38eced4 100644
+--- a/blessings/tests.py
++++ b/blessings/tests.py
+@@ -44,6 +44,8 @@ def test_capability():
+ 
+     """
+     t = TestTerminal()
++    if not t.is_a_tty:
++        raise SkipTest
+     sc = unicode_cap('sc')
+     eq_(t.save, sc)
+     eq_(t.save, sc)  # Make sure caching doesn't screw it up.
+@@ -64,7 +66,7 @@ def test_capability_with_forced_tty():
+ 
+ def test_parametrization():
+     """Test parametrizing a capability."""
+-    eq_(TestTerminal().cup(3, 4), unicode_parm('cup', 3, 4))
++    eq_(TestTerminal(force_styling=True).cup(3, 4), unicode_parm('cup', 3, 4))
+ 
+ 
+ def height_and_width():
+@@ -143,7 +145,7 @@ def test_mnemonic_colors():
+ 
+     # Avoid testing red, blue, yellow, and cyan, since they might someday
+     # change depending on terminal type.
+-    t = TestTerminal()
++    t = TestTerminal(force_styling=True)
+     eq_(t.white, color(7))
+     eq_(t.green, color(2))  # Make sure it's different than white.
+     eq_(t.on_black, on_color(0))
+@@ -247,7 +249,7 @@ def test_nice_formatting_errors():
+ def test_init_descriptor_always_initted():
+     """We should be able to get a height and width even on no-tty Terminals."""
+     t = Terminal(stream=StringIO())
+-    eq_(type(t.height), int)
++    assert isinstance(t.height, int) or t.height is None
+ 
+ 
+ def test_force_styling_none():
+-- 
+1.7.11.7
+
diff --git a/python-blessings.spec b/python-blessings.spec
new file mode 100644
index 0000000..a6997b0
--- /dev/null
+++ b/python-blessings.spec
@@ -0,0 +1,96 @@
+%global upstream_name blessings
+
+%if 0%{?fedora} || 0%{?rhel} > 6
+%bcond_without python3
+%else
+%bcond_with python3
+%endif
+
+Name:           python-%{upstream_name}
+Version:        1.5
+Release:        1%{?dist}
+Summary:        Python library for terminal coloring, styling, and positioning
+License:        MIT
+URL:            https://github.com/erikrose/blessings
+Source0:        http://pypi.python.org/packages/source/b/%{upstream_name}/%{upstream_name}-%{version}.tar.gz
+# https://github.com/erikrose/blessings/issues/25
+Patch0:         blessings-1.5-tests-without-tty.patch
+BuildArch:      noarch
+BuildRequires:  python2-devel
+BuildRequires:  python-setuptools
+BuildRequires:  python-nose
+%if %{with python3}
+BuildRequires:  python3-devel
+BuildRequires:  python3-setuptools
+BuildRequires:  python3-nose
+%endif
+
+%description
+Blessings is a thin, practical wrapper around terminal coloring, styling, and 
+positioning in Python.
+
+%if %{with python3}
+%package -n python3-%{upstream_name}
+Summary:        Python library for terminal coloring, styling, and positioning
+
+%description -n python3-%{upstream_name}
+Blessings is a thin, practical wrapper around terminal coloring, styling, and 
+positioning in Python.
+%endif
+
+%prep
+%setup -q -n %{upstream_name}-%{version}
+%patch0 -p1
+rm -rf blessings.egg-info
+
+%if %{with python3}
+rm -rf %{py3dir}
+cp -a . %{py3dir}
+%endif
+
+%build
+%{__python} setup.py build
+
+%if %{with python3}
+pushd %{py3dir}
+%{__python3} setup.py build
+popd
+%endif
+
+%install
+%if %{with python3}
+pushd %{py3dir}
+%{__python3} setup.py install --skip-build --root %{buildroot}
+popd
+%endif
+
+%{__python} setup.py install --skip-build --root %{buildroot}
+
+%check
+%{__python} setup.py test
+
+%if %{with python3}
+pushd %{py3dir}
+%if %{?fedora} <= 17
+nosetests-3.2 build/lib
+%else
+nosetests-3.3 build/lib
+%endif
+popd
+%endif
+
+%files
+%doc README.rst LICENSE
+%{python_sitelib}/blessings
+%{python_sitelib}/blessings*.egg-info
+
+%if %{with python3}
+%files -n python3-%{upstream_name}
+%doc README.rst LICENSE
+%{python3_sitelib}/blessings
+%{python3_sitelib}/blessings*.egg-info
+%endif
+
+%changelog
+* Fri Nov 30 2012 Dan Callaghan <dcallagh at redhat.com> - 1.5-1
+- initial version
diff --git a/sources b/sources
index e69de29..7a82cf7 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+368094303d698512f86e1aab8dde3b9e  blessings-1.5.tar.gz


More information about the scm-commits mailing list