commit 7ca2a8f47cb603e87ec5dca6e01ccbd63e2b61d575002961af5541babde37894 Author: Matej Cepl Date: Mon Feb 7 21:13:53 2022 +0000 Accepting request 951766 from home:badshah400:branches:science New package - A python module to display simple lists in formatted columns. OBS-URL: https://build.opensuse.org/request/show/951766 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-columnize?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/columnize-0.3.10.tar.gz b/columnize-0.3.10.tar.gz new file mode 100644 index 0000000..ba0f65c --- /dev/null +++ b/columnize-0.3.10.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5669984ae49447ee21dc33b6635a23827b25f4015e92c0858e1ac29f4e6cf5cc +size 9690 diff --git a/drop-nose-requirement.patch b/drop-nose-requirement.patch new file mode 100644 index 0000000..57aefcc --- /dev/null +++ b/drop-nose-requirement.patch @@ -0,0 +1,11 @@ +Index: columnize-0.3.10/setup.py +=================================================================== +--- columnize-0.3.10.orig/setup.py ++++ columnize-0.3.10/setup.py +@@ -34,6 +34,5 @@ setup( + py_modules = py_modules, + install_requires = install_requires, + tests_require = tests_require, +- setup_requires = ['nose>=1.0'], + zip_safe = zip_safe + ) diff --git a/python-columnize.changes b/python-columnize.changes new file mode 100644 index 0000000..5180bad --- /dev/null +++ b/python-columnize.changes @@ -0,0 +1,22 @@ +------------------------------------------------------------------- +Sat Feb 5 17:08:57 UTC 2022 - Atri Bhattacharya + +- Include test file missed from being included in source tarball + and enable tests using pytest; additional BuildRequires for + tests: python-pytest, python-mock. + +------------------------------------------------------------------- +Sun Jan 30 00:42:44 UTC 2022 - Atri Bhattacharya + +- Update to version 0.3.10: + * Make compatible with Python version 2.4..3.8 now. + * Use TideLift security and make compliant. +- Add drop-nose-requirement.patch -- Drop requirement on outdated + nose; we do not run tests anyway. +- Update License to MIT in keeping with upstream. +- More fine-grained file list. + +------------------------------------------------------------------- +Sun Jan 12 06:05:54 AM UTC 2020 - John Vandenberg + +- Initial spec for v0.3.9 diff --git a/python-columnize.spec b/python-columnize.spec new file mode 100644 index 0000000..e4feb1a --- /dev/null +++ b/python-columnize.spec @@ -0,0 +1,68 @@ +# +# spec file for package python-columnize +# +# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ + + +%define modname columnize +%{?!python_module:%define python_module() python-%{**} python3-%{**}} +Name: python-columnize +Version: 0.3.10 +Release: 0 +License: MIT +Summary: Format a simple (i.e. not nested) list into aligned columns +Url: https://github.com/rocky/pycolumnize +Group: Development/Languages/Python +Source0: https://files.pythonhosted.org/packages/source/c/columnize/columnize-%{version}.tar.gz +# Include test file missed from being included in source tarball +Source1: https://raw.githubusercontent.com/rocky/pycolumnize/%{version}/test_columnize.py +# PATCH-FEATURE-OPENSUSE drop-nose-requirement.patch badshah400@gmail.com -- Drop requirement on outdated nose; we do not run tests anyway +Patch0: drop-nose-requirement.patch +BuildRequires: python-rpm-macros +BuildRequires: %{python_module setuptools} +# SECTION For tests +BuildRequires: %{python_module mock} +BuildRequires: %{python_module pytest} +# /SECTION +BuildRequires: fdupes +BuildArch: noarch + +%python_subpackages + +%description +Format a simple (i.e. not nested) list into aligned columns. + +%prep +%autosetup -p1 -n columnize-%{version} + +cp %{SOURCE1} ./ + +%build +%python_build + +%install +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitelib} + +%check +%pytest + +%files %{python_files} +%doc NEWS.md README.rst +%license LICENSE +%{python_sitelib}/%{modname}.py* +%{python_sitelib}/%{modname}-%{version}-py%{python_version}.egg-info/ +%pycache_only %{python_sitelib}/__pycache__/* + +%changelog diff --git a/test_columnize.py b/test_columnize.py new file mode 100644 index 0000000..ce466d3 --- /dev/null +++ b/test_columnize.py @@ -0,0 +1,178 @@ +#!/usr/bin/env python +# -*- Python -*- +"Unit test for Columnize" +import mock, operator, os, sys, unittest + +top_builddir = os.path.join(os.path.dirname(__file__), os.path.pardir) +if top_builddir[-1] != os.path.sep: + top_builddir += os.path.sep +sys.path.insert(0, top_builddir) + +from columnize import columnize + +class TestColumize(unittest.TestCase): + + def test_basic(self): + """Basic sanity and status testing.""" + self.assertEqual("1, 2, 3\n", + columnize(['1', '2', '3'], 10, ', ')) + self.assertEqual("1 3\n2 4\n", + columnize(['1', '2', '3', '4'], 4)) + + self.assertEqual("1 3\n2 4\n", + columnize(['1', '2', '3', '4'], 7)) + + self.assertEqual("0 1 2\n3\n", + columnize(['0', '1', '2', '3'], 7, + arrange_vertical=False)) + + self.assertEqual("\n", columnize([])) + self.assertEqual("oneitem\n", columnize(["oneitem"])) + + data = [str(i) for i in range(55)] + self.assertEqual( + "0, 6, 12, 18, 24, 30, 36, 42, 48, 54\n" + + "1, 7, 13, 19, 25, 31, 37, 43, 49\n" + + "2, 8, 14, 20, 26, 32, 38, 44, 50\n" + + "3, 9, 15, 21, 27, 33, 39, 45, 51\n" + + "4, 10, 16, 22, 28, 34, 40, 46, 52\n" + + "5, 11, 17, 23, 29, 35, 41, 47, 53\n", + columnize(data, displaywidth=39, ljust=False, + arrange_vertical=True, colsep=', ')) + + self.assertEqual( + " 0, 7, 14, 21, 28, 35, 42, 49\n" + + " 1, 8, 15, 22, 29, 36, 43, 50\n" + + " 2, 9, 16, 23, 30, 37, 44, 51\n" + + " 3, 10, 17, 24, 31, 38, 45, 52\n" + + " 4, 11, 18, 25, 32, 39, 46, 53\n" + + " 5, 12, 19, 26, 33, 40, 47, 54\n" + + " 6, 13, 20, 27, 34, 41, 48\n", + columnize(data, displaywidth=39, ljust=False, + arrange_vertical=True, colsep=', ', + lineprefix=' ')) + + self.assertEqual( + " 0, 1, 2, 3, 4, 5, 6, 7, 8, 9\n" + + "10, 11, 12, 13, 14, 15, 16, 17, 18, 19\n" + + "20, 21, 22, 23, 24, 25, 26, 27, 28, 29\n" + + "30, 31, 32, 33, 34, 35, 36, 37, 38, 39\n" + + "40, 41, 42, 43, 44, 45, 46, 47, 48, 49\n" + + "50, 51, 52, 53, 54\n", + columnize(data, displaywidth=39, ljust=False, + arrange_vertical=False, colsep=', ')) + + self.maxDiff = None + self.assertEqual( + " 0, 1, 2, 3, 4, 5, 6, 7\n" + + " 8, 9, 10, 11, 12, 13, 14, 15\n" + + " 16, 17, 18, 19, 20, 21, 22, 23\n" + + " 24, 25, 26, 27, 28, 29, 30, 31\n" + + " 32, 33, 34, 35, 36, 37, 38, 39\n" + + " 40, 41, 42, 43, 44, 45, 46, 47\n" + + " 48, 49, 50, 51, 52, 53, 54\n", + columnize(data, displaywidth=34, ljust=False, + arrange_vertical=False, colsep=', ', + lineprefix=' ')) + + + data = ( + "one", "two", "three", + "for", "five", "six", + "seven", "eight", "nine", + "ten", "eleven", "twelve", + "thirteen", "fourteen", "fifteen", + "sixteen", "seventeen", "eightteen", + "nineteen", "twenty", "twentyone", + "twentytwo", "twentythree", "twentyfour", + "twentyfive","twentysix", "twentyseven",) + + self.assertEqual( +"one two three for five six \n" + +"seven eight nine ten eleven twelve \n" + +"thirteen fourteen fifteen sixteen seventeen eightteen \n" + +"nineteen twenty twentyone twentytwo twentythree twentyfour\n" + +"twentyfive twentysix twentyseven\n", columnize(data, arrange_vertical=False)) + + self.assertEqual( +"one five nine thirteen seventeen twentyone twentyfive \n" + +"two six ten fourteen eightteen twentytwo twentysix \n" + +"three seven eleven fifteen nineteen twentythree twentyseven\n" + +"for eight twelve sixteen twenty twentyfour \n", columnize(data)) + + self.assertEqual('0 1 2 3\n', columnize(list(range(4)))) + + self.assertEqual( +"[ 0, 1, 2, 3, 4, 5, 6, 7, 8,\n"+ +" 9, 10, 11, 12, 13, 14, 15, 16, 17,\n"+ +" 18, 19, 20, 21, 22, 23, 24, 25, 26,\n"+ +" 27, 28, 29, 30, 31, 32, 33, 34, 35,\n"+ +" 36, 37, 38, 39, 40, 41, 42, 43, 44,\n"+ +" 45, 46, 47, 48, 49, 50, 51, 52, 53,\n"+ +" 54]\n\n", columnize(list(range(55)), + opts={'displaywidth':38, 'arrange_array':True})) + + self.assertEqual("""[ 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11] + +""", columnize(list(range(12)), + opts={'displaywidth':6, 'arrange_array':True})) + + self.assertEqual("""[ 0, 1, + 2, 3, + 4, 5, + 6, 7, + 8, 9, + 10, 11] + +""", columnize(list(range(12)), + opts={'displaywidth':9, 'arrange_array':True})) + + return + + def test_colfmt(self): + self.assertEqual(' 0 1 2 3\n', + columnize([0, 1, 2, 3], 7, + arrange_vertical=False, + opts={'colfmt': '%5d'})) + + def test_lineprefix(self): + self.assertEqual('>>> 0\n>>> 1\n>>> 2\n>>> 3\n', + columnize([0, 1, 2, 3], 7, + arrange_vertical=False, + opts={'colfmt': '%5d', + 'displaywidth': 16, + 'lineprefix': '>>> '})) + + def test_lineprefix_just_wide_enough(self): + self.assertEqual('>>>10 12\n>>>11 13\n', + columnize([10, 11, 12, 13], + opts={'lineprefix': '>>>', + 'displaywidth': 9})) + + if sys.version_info[:2] >= (3, 6): + + @mock.patch.dict('os.environ', {'COLUMNS': '87'}, clear=True) + def test_computed_displaywidth_environ_COLUMNS_set(self): + from columnize import computed_displaywidth + width = computed_displaywidth() + self.assertEqual(width, 87) + + def test_errors(self): + """Test various error conditions.""" + self.assertRaises(TypeError, columnize, 5, 'reject input - not array') + return + pass + +if __name__ == '__main__': + unittest.main()