15
0

- Add patch support-python-313.patch:

* No longer use now-removed pipes module.
- Remove Python 2 leftovers.
- Switch to pyproject macros.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-humanfriendly?expand=0&rev=42
This commit is contained in:
2024-10-30 02:58:53 +00:00
committed by Git OBS Bridge
commit 446e4b0b82
9 changed files with 717 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -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

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

3
_multibuild Normal file
View File

@@ -0,0 +1,3 @@
<multibuild>
<package>test</package>
</multibuild>

BIN
humanfriendly-10.0.tar.gz LFS Normal file

Binary file not shown.

37
pytest-7-support.patch Normal file
View File

@@ -0,0 +1,37 @@
From 1789ed31946ba6353c8b26332344608519722a88 Mon Sep 17 00:00:00 2001
From: Steve Kowalik <steven@wedontsleep.org>
Date: Fri, 29 Jul 2022 17:19:38 +1000
Subject: [PATCH] Do not import setup in the tests module
pytest 7 and above will call any setup as a hook for any module
collected, which in this case calls into the Sphinx machinery due to
importing the setup function from there. Import it as something else so
that pytest will not call it.
Fixes #64
---
humanfriendly/tests.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/humanfriendly/tests.py b/humanfriendly/tests.py
index 72dad99..d019a2f 100644
--- a/humanfriendly/tests.py
+++ b/humanfriendly/tests.py
@@ -59,7 +59,7 @@
deprecation_note_callback,
man_role,
pypi_role,
- setup,
+ setup as sphinx_setup,
special_methods_callback,
usage_message_callback,
)
@@ -1444,7 +1444,7 @@ def bogus_usage(self):
# Test event callback registration.
fake_app = FakeApp()
- setup(fake_app)
+ sphinx_setup(fake_app)
assert man_role == fake_app.roles['man']
assert pypi_role == fake_app.roles['pypi']
assert deprecation_note_callback in fake_app.callbacks['autodoc-process-docstring']

View File

@@ -0,0 +1,13 @@
Index: humanfriendly-10.0/humanfriendly/tests.py
===================================================================
--- humanfriendly-10.0.orig/humanfriendly/tests.py 2021-06-11 12:43:08.000000000 +0200
+++ humanfriendly-10.0/humanfriendly/tests.py 2022-03-21 13:05:02.302356424 +0100
@@ -123,7 +123,7 @@ from humanfriendly.usage import (
)
# Test dependencies.
-from mock import MagicMock
+from unittest.mock import MagicMock
class HumanFriendlyTestCase(TestCase):

View File

@@ -0,0 +1,450 @@
-------------------------------------------------------------------
Wed Oct 30 02:58:39 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch support-python-313.patch:
* No longer use now-removed pipes module.
- Remove Python 2 leftovers.
- Switch to pyproject macros.
-------------------------------------------------------------------
Fri Apr 21 12:26:28 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add sle15_python_module_pythons (jsc#PED-68)
-------------------------------------------------------------------
Thu Apr 13 22:41:56 UTC 2023 - Matej Cepl <mcepl@suse.com>
- Make calling of %{sle15modernpython} optional.
-------------------------------------------------------------------
Tue Aug 2 03:12:41 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Remove unneeded BuildRequires on mock.
-------------------------------------------------------------------
Fri Jul 29 07:42:02 UTC 2022 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch pytest-7-support.patch:
* Support pytest >= 7.
-------------------------------------------------------------------
Mon Mar 21 12:15:56 UTC 2022 - pgajdos@suse.com
- do not require mock for build
- added patches
fix https://github.com/xolox/python-humanfriendly/issues/62
+ python-humanfriendly-no-mock.patch
-------------------------------------------------------------------
Thu Nov 18 11:55:15 UTC 2021 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Update to 10.0
**Noteworthy changes:**
* Merged pull request `#45`_ to resolve the issue caused by the conditional
:pypi:`pyreadline` requirement on Windows not supporting Python 3.9+.
* Updated the readme to use Python 3 in the example (reported in issue `#56`_).
Also added a mention of the ``humanfriendly --demo`` command.
* Removed the ``humanfriendly.compat.unittest`` alias that presumably no-one is
using at this point; it had been rendered useless quite a long time ago
(requested in issue `#53`_).
**Internal changes:**
* Merged pull request `#54`_ which migrates the :pypi:`humanfriendly` project
from Travis CI to GitHub Actions and from Coveralls.io to Codecov.
* Fixed a deprecation warning concerning ``setup.cfg`` and some Sphinx
documentation errors.
-------------------------------------------------------------------
Tue Aug 17 10:58:03 UTC 2021 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Update to 9.2
Maintenance release:
* Merged pull request `#46`_ which fixes several :pypi:`flake8` warnings.
* Merged pull request `#49`_ which marks Python 3.9 support final.
* Merged pull request `#51`_ which helps to stabilize the test suite.
* Merged pull request `#52`_ which updates the :mod:`humanfriendly.sphinx`
module to include Sphinx extension metadata that has become mandatory in a
recent Sphinx release. After merging the pull request I added additional
metadata including the version.
- from version 9.1
* Added :func:`~humanfriendly.compat.on_macos()` function to detect Apple MacOS
(I need this in an upcoming :pypi:`coloredlogs` release and don't want to have
to think about how to detect MacOS again in the future 😇).
- from version 9.0
The major version number was bumped because the bug fix for
:func:`~humanfriendly.text.pluralize()` is backwards incompatible
and (even though this seems like very "cosmetic" functionality)
version numbers are cheap, so who cares 😉.
**Bug fixes:**
* Changed :func:`~humanfriendly.format_number()` to properly support negative
numbers (as suggested in `issue #40`_).
* Changed :func:`~humanfriendly.text.pluralize()` to generate "1.5 seconds"
instead of "1.5 second" (as suggested in `issue #43`_).
**Enhancements:**
* Enhanced :func:`~humanfriendly.text.concatenate()` to support ``conjunction``
and ``serial_comma`` keyword arguments (as suggested in `issue #30`_).
* Added :func:`~humanfriendly.text.pluralize_raw()` to select singular or
plural form without prefixing the count to the text that is returned.
- from version 8.2
* Added a simple case insensitive dictionary implementation, for details refer to
the new :mod:`humanfriendly.case` module.
-------------------------------------------------------------------
Thu Apr 23 11:01:33 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
- Fix build without python2
-------------------------------------------------------------------
Mon Mar 30 09:38:31 UTC 2020 - Marketa Calabkova <mcalabkova@suse.com>
- Update to 8.1
* Make it possible to opt out of the output capturing that
:func:`humanfriendly.testing.run_cli()` sets up by default.
* Improve feature parity between :class:`humanfriendly.testing.CaptureOutput`
and my :pypi:`capturer` package to the point where most of the
:pypi:`humanfriendly` test suite can now run without :pypi:`capturer`.
* Refactored the test suite to import all names separately instead of referring
to identifiers via their modules (my preferences have changed since this code
was written a long time ago).
* Adopt :func:`functools.wraps()` to make decorator functions more robust.
* Make the :class:`~humanfriendly.terminal.spinners.Spinner` class more
customizable. The interval at which spinners are updated and the characters
used to draw the animation of spinners can now be customized by callers.
This was triggered by `executor issue #2`_.
* Improve test skipping based on exception types.
* The "deprecated imports" feature provided by :mod:`humanfriendly.deprecation`
has been adopted to clean up the maze of (almost but not quite) cyclic import
dependencies between modules.
* HTML to ANSI functionality has been extracted to a new
:mod:`humanfriendly.terminal.html` module.
* Support for spinners has been extracted to a new
:mod:`humanfriendly.terminal.spinners` module.
* The use of positional arguments to initialize
:class:`~humanfriendly.terminal.spinners.Spinner` objects has been deprecated
using the new :func:`humanfriendly.deprecation.deprecated_args()` decorator
function.
* Added the :func:`humanfriendly.deprecation.deprecated_args()` decorator function
which makes it easy to switch from positional arguments to keyword arguments
without dropping backwards compatibility.
* Accept pluralized disk size units (`#26`_). I'm not claiming this is a full
solution to the problem, far from it. It does lessen the pain a bit (IMHO).
* Make sure the selected pager is available before trying to run it. While
testing :pypi:`humanfriendly` on Windows 10 I noticed that ``humanfriendly
*-help`` resulted in nothing but a traceback, because :man:`less` wasn't
available. That's not human friendly at all 😕 (even if it is Windows 😈).
* Merge pull request `#24`_: Fix bug in :func:`~humanfriendly.parse_length()` that rounded floats.
* Merge pull request `#32`_: Update hyperlinks in readme.
* Merge pull request `#33`_: Drop support for Python 2.6 and 3.0-3.4
* Merge pull request `#35`_: SVG badge in readme.
* Merge pull request `#36`_: Add support for nanoseconds and microseconds time units
* Fixed :func:`~humanfriendly.tables.format_rst_table()` omission from
``humanfriendly.tables.__all__``.
* Start testing on Python 3.8 and 3.9-dev.
* Emit an ANSI reset code when :func:`humanfriendly.terminal.html.HTMLConverter.close()`
* Added the :func:`humanfriendly.terminal.html_to_ansi()` function which is a
* Added ``humanfriendly.testing.TestCase.assertRaises()`` enhancements.
* Define ``humanfriendly.text.__all__``.
-------------------------------------------------------------------
Sat Feb 15 08:48:24 CET 2020 - Matej Cepl <mcepl@suse.com>
- Update to 6.1:
- Added a :pypy:`...` role for easy linking to packages on the
Python Package Index, for details refer to
:func:`humanfriendly.sphinx.pypi_role()`.
- Wasted quite a bit of time debugging a MacOS failure on
Travis CI caused by a broken man`pip` installation, fixed by
using get-pip.py to bootstrap an installation that actually
works wink.
- Enable :class:`~humanfriendly.testing.MockedProgram` to
customize the shell script code of mocked programs. This was
added to make it easy to mock a program that is expected to
generate specific output (I'm planning to use this in the
:pypi:`linux-utils` test suite).
- Defined __all__ for all public modules that previously lacked
"export control" and decided to bump the major version number
as a precaution:
- These changes should not have any impact on backwards
compatibility, unless I forgot entries, in which case
callers can get :exc:`~exceptions.ImportError`
exceptions...
- Imports of public modules were previously exported
(implicitly) and this pollutes code completion suggestions
which in turn can encourage bad practices (not importing
things using their "canonical" name).
- I started developing the humanfriendly package years before
I learned about the value of defining __all__ and so some
modules lacked a definition until now. I decided that now
was as good a time as any to add those definitions
innocent.
- Simplified the headings in docs/api.rst so that only the
module names remain. This was done because Sphinx doesn't
support nested links in HTML output and thus generated really
weird "Table of Contents" listings.
- Fixed the reStructuredText references in the documentation of
:func:`~humanfriendly.prompts.prompt_for_choice()`. This
function is imported from :mod:`humanfriendly.prompts` to
:mod:`humanfriendly` (for backwards compatibility) where it
can't use relative references to refer to the other functions
in the :mod:`humanfriendly.prompts` module.
- Embedded quite a few Python API references into recent
changelog entries, just because I could (I heart what
hyperlinks can do for the usability of technical
documentation, it gives a lot more context).
- Added custom :man:`...` role for easy linking to Linux manual
pages to the :mod:`humanfriendly.sphinx` module.
- Changed rendering of pretty tables to expand tab characters
to spaces: Until now pretty tables did not take the variable
width of tab characters into account which resulted in tables
whose "line drawing characters" were visually misaligned.
Tabs are now expanded to spaces using str.expandtabs().
- Stop testing on Python 2.6 and drop official support. The
world (including Travis CI) has moved on and preserving
Python 2.6 compatibility was clearly starting to drag the
project down...
- I decided to bump the major version number because each of
these changes can be considered backwards incompatible in one
way or another and version numbers are cheap anyway so there
stuck_out_tongue.
-------------------------------------------------------------------
Wed Dec 11 08:57:19 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Require full python stack for sqlite module
-------------------------------------------------------------------
Fri Mar 29 10:46:17 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Simplify the multibuild conditioning and name creation
-------------------------------------------------------------------
Tue Mar 12 16:03:38 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 4.18:
* Added humanfriendly.text.generate_slug() function.
* Fixed "invalid escape sequence" DeprecationWarning (pointed out by Python >= 3.6).
-------------------------------------------------------------------
Thu Jan 31 11:32:14 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 4.17:
* compatibility with python 3.7
-------------------------------------------------------------------
Wed Aug 29 08:22:29 UTC 2018 - tchvatal@suse.com
- Move the Name declaration above lua code to work on Leap 42.3
-------------------------------------------------------------------
Fri Aug 17 13:50:03 UTC 2018 - tchvatal@suse.com
- Update to 4.16.1:
* Added humanfriendly.text.compact_empty_lines() function.
* Enable optional html_to_ansi(data[, callback]) argument.
* Added a code sample and screenshot to the HTMLConverter documentation.
* Emit vertical whitespace for block tags like <div>, <p> and <pre> and post-process the generated output in __call__() to compact empty lines.
* Dont pre-process preformatted text using the user defined text callback.
* Improve robustness against malformed HTML (previously an IndexError would be raised when a closing </a> tag was encountered without a corresponding opening <a> tag).
* Emit an ANSI reset code when HTMLConverter.close() is called and a style is still active (improves robustness against malformed HTML).
* Support for 24-bit (RGB) terminal colors. Works by accepting a tuple or list with three integers representing an RGB (red, green, blue) color.
* Support for italic text rendering on the terminal.
* Make format_timespan() accept datetime.timedelta objects (fixes #27).
* Add license key to setup.py script (pointed out to me in coloredlogs pull request #53).
* Added the Timer.sleep() method to sleep “no more than” the given number of seconds.
* Added the format_rst_table() function to render RST (reStructuredText) tables.
- Enable and make sure tests are run
-------------------------------------------------------------------
Tue Aug 14 09:04:56 UTC 2018 - ms@suse.com
- Submission to SUSE:SLE-12-SP3:Update:PubClouds
This commit tracks the submission for fate#326575
and bsc#1103542
-------------------------------------------------------------------
Thu Feb 8 21:59:46 UTC 2018 - adrian.glaubitz@suse.com
- Update to version 4.8
* Add coerce_pattern() function
* Improve code consistency
- From version 4.7
* Support background colors and 256 color mode
* Tests for output(), message() and warning()
- From version 4.6
* Support for bright terminal colors
- From version 4.5
* Extend byte ranges, add RAM output to command line
- From version 4.4.2
* Reduce clock source sensitivity* (MacOS on Travis CI)
* Fix `Double requirement given' error
* Try to fix Python 2.6 tests on Travis CI
* Change Sphinx documentation theme
* Bump copyright
* Try to enable MacOS builds on Travis CI
* Fix ImportError exception on Windows
- From version 4.4.1
* Include docs to sdist
* PEP-8 fail
* Change cli test from 1.05 mm to 1.05 km
* Another correction to test_cli
* Corrected CLI format_length test
* Aim for more CLI coverage
* Add CLI tests for format-byte
* Added size test cases
* Size 1z is now valid
- From version 4.4
* Add touch() to __all__
* Make touch() create intermediate directories
* Add humanfriendly.testing.touch() function
- From version 4.3
* Don't log duplicate output in run_cli()
- From version 4.2
* Reconfigure logging in run_cli()
- From version 4.1
* Always log stderr as well in run_cli()
- From version 4.0
* Improve humanfriendly.testing.run_cli() (backwards incompatible)
- From version 3.8
* Make it easy to mock the $HOME directory
- From version 3.7
* Customizable skipping of tests
* Added .pyc to .gitignore
* Added Exa, Zetta & Yotta prefixes and tests
* Added -S --format-bytes option to use powers of 1024 rather than 1000 from command line.
- From version 3.6.1
* Improve robustness of Patched{Attribute,Item}
- From version 3.6
* Make retry limit configurable
* Refactor makefile and Travis CI configuration
- From version 3.5
* Bug fix for TestCase.assertRaises()
* Enhance TestCase.assertRaises()
- From version 3.4.1
* Bug fix for Python 3 syntax incompatibility
- From version 3.4
* Promote command line test function to public API
- From version 3.3
* Add humanfriendly.testing module (unittest helpers)
* Add humanfriendly.text.random_string() function
* Define humanfriendly.text.__all__
* Reorder functions in humanfriendly.text alphabetically
- From version 3.2
* Auto-encode terminal output to avoid encoding errors
* Remove unused import
- From version 3.1
* Improve usage message parsing and rendering
- From version 3.0
* Add Python 3.6 to tested versions
* Silence flake8 complaints
* Add min, mins tests
* Support min, mins abbreviations for minutes
- From version 2.4
* Restore Python 3 compatibility
* Make usage() and show_pager() more user friendly
* Remove redundant :py: prefixes in docstrings
* Improve docstrings in setup.py
- From version 2.3.2
* Bug fix: Don't hard code conditional dependencies in wheels
- From version 2.3.1
* Fix parse_usage() tripping up on commas in option labels
* Break test suite to reproduce parse_usage() bug
- From version 2.3
* Switch to monotonic clock for timers
* Bump copyright
* Minor improvements to setup script
* Improve intersphinx references
* s/readthedocs.org/readthedocs.io/g
- From version 2.2.1
* Fix timers being awkward as context managers
* Reproduce timers being awkward as context managers
* Minor improvements to reStructuredText in docstrings
- From version 2.2
* Fix parse_date() choking on Unicode strings
* Reproduce parse_date() bug in test suite
* Fix flake8 warning
* Only use readline hints in prompts when stdin is tty
-------------------------------------------------------------------
Wed Sep 6 16:36:13 UTC 2017 - toddrme2178@gmail.com
- Implement single-spec version.
- Update to version 4.4.1
* No changelog
-------------------------------------------------------------------
Mon Oct 10 19:21:56 UTC 2016 - mardnh@gmx.de
- Update to version 2.1
* Release 2.1: Support for sanitizing terminal output
* Support for sanitizing terminal output
* Merge #12: Update README.rst for new unit behaviour
* Update README.rst for new unit behaviour
* Release 2.0: Proper support for IEEE 1541 definitions of units? (fixes #4, merges #8 and #9)
* Proper support for IEEE 1541 definitions of units?
* Merge #9: Add note about IEEE 1541 definitions of units
* Merge #8: Allow correct behavior of 'parse_size' and 'format_size'
* Stop clearing coverage data on Travis CI :-)
* Release 1.44.9 (fixes #10 and #11)
* Restore Python 2.6 compatibility (#10 and #11)
* Resolve timespan formatting issues (#10 and #11)
* Reproduce timespan formatting issues reported in #10 and #11
* Refactor makefile, switch to py.test, wheel support, etc.
* Release 1.44.8 (fixes #7)
* Don't test tags on Travis CI
* Fix issue #7
* Reproduce issue #7 in test suite
* Minor improvements to setup script
* Add note about IEEE 1541 definitions of units
* Added unit tests
* Implemented correct handling of prefixes based on IEEE 1540
- Fix source url
- Minor specfile cleanup
-------------------------------------------------------------------
Wed Jun 1 20:56:09 UTC 2016 - okurz@suse.com
- Update to official release 1.44.7
Minor improvements to usage message reformatting
Remove undocumented .strip() from join_lines()
Why I noticed this: It has the potential to eat significant white
space in usage messages that are marked up in reStructuredText syntax.
Why I decided to change it: The behavior isn't documented and on
second thought I wouldn't expect a function called join_lines()
to strip any and all leading/trailing white space.
Improve usage message parsing algorithm (also add a proper test)
Refer to test_parse_usage_tricky() for an example of a usage message that
is now parsed correctly but would previously confuse the dumb "parsing"
algorithm in parse_usage().
Make usage message parsing a bit more strict
Admittedly this needs a lot more love to make it more robust but
I lack the time to implement this at the moment. Some day soon! :-)
Unbreak conditional importlib dependency*
* https://travis-ci.org/xolox/python-humanfriendly/builds/110585766
Kind of strange that everything worked fine locally. Then again,
I've never used wheel compatible conditional dependencies before
so of course my first attempt was bound to fail in same way :-s.
Make conditional importlib dependency compatible with wheels*
While running tox tests of another project of mine that uses the
humanfriendly package I noticed a traceback when importing the
humanfriendly package (because importlib was missing). After some
digging I found that tox uses pip to install packages and pip converts
source distributions to wheel distributions before/during installation,
thereby dropping the conditional importlib dependency.
Fix non-fatal log format error in prompt_for_choice()
Add humanfriendly.sphinx module
-------------------------------------------------------------------
Mon Jan 25 09:08:00 UTC 2016 - okurz@suse.de
- initial package

112
python-humanfriendly.spec Normal file
View File

@@ -0,0 +1,112 @@
#
# spec file for package python-humanfriendly
#
# Copyright (c) 2024 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix test
%bcond_without test
%else
%define psuffix %{nil}
%bcond_with test
%endif
%{?sle15_python_module_pythons}
Name: python-humanfriendly%{psuffix}
Version: 10.0
Release: 0
Summary: Human friendly input/output for text interfaces using Python
License: MIT
URL: https://github.com/xolox/python-humanfriendly
Source: https://files.pythonhosted.org/packages/source/h/humanfriendly/humanfriendly-%{version}.tar.gz
# https://github.com/xolox/python-humanfriendly/issues/62
Patch0: python-humanfriendly-no-mock.patch
# PATCH-FIX-UPSTREAM gh#xolox/python-humanfriendly#65
Patch1: pytest-7-support.patch
# PATCH-FIX-UPSTREAM gh#xolox/python-humanfriendly#75
Patch2: support-python-313.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python
Requires(post): update-alternatives
Requires(postun): update-alternatives
BuildArch: noarch
%if %{with test}
BuildRequires: %{python_module capturer >= 2.1}
BuildRequires: %{python_module coloredlogs >= 2}
BuildRequires: %{python_module docutils}
BuildRequires: %{python_module pytest >= 3.0.7}
BuildRequires: %{python_module pytest-cov >= 2.4.0}
BuildRequires: %{pythons}
%endif
%python_subpackages
%description
The functions and classes in the humanfriendly package can be used to make
text interfaces more user friendly.
Some example features:
* Parsing and formatting numbers, file sizes, pathnames and timespans in
simple, human friendly formats.
* Easy to use timers for long running operations, with human friendly
formatting of the resulting timespans.
* Prompting the user to select a choice from a list of options by typing
the options number or a unique substring of the option.
* Terminal interaction including text styling (ANSI escape sequences), user
friendly rendering of usage messages and querying the terminal for its size.
%prep
%autosetup -p1 -n humanfriendly-%{version}
%build
%pyproject_wheel
%install
%if !%{with test}
%pyproject_install
%python_clone -a %{buildroot}%{_bindir}/humanfriendly
%{python_expand chmod a+x %{buildroot}%{$python_sitelib}/humanfriendly/tests.py
sed -i "s|#!%{_bindir}/env python|#!%__$python|" %{buildroot}%{$python_sitelib}/humanfriendly/tests.py
$python -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}/humanfriendly/
$python -O -m compileall -d %{$python_sitelib} %{buildroot}%{$python_sitelib}/humanfriendly/
%fdupes %{buildroot}%{$python_sitelib}
}
%endif
%if %{with test}
%check
%pytest humanfriendly/tests.py
%endif
%if !%{with test}
%post
%python_install_alternative humanfriendly
%postun
%python_uninstall_alternative humanfriendly
%files %{python_files}
%license LICENSE.txt
%doc README.rst
%python_alternative %{_bindir}/humanfriendly
%{python_sitelib}/humanfriendly
%{python_sitelib}/humanfriendly-%{version}.dist-info
%endif
%changelog

75
support-python-313.patch Normal file
View File

@@ -0,0 +1,75 @@
From 13d05b8057010121acd2a402a337ef4ee5834062 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Thu, 30 May 2024 23:05:14 -0400
Subject: [PATCH] Replace pipes.quote with shlex.quote on Python 3
The shlex.quote() API is available from Python 3.3 on; pipes.quote() was
never documented, and is removed in Python 3.13.
Fixes #73.
---
humanfriendly/cli.py | 8 ++++++--
humanfriendly/testing.py | 8 ++++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/humanfriendly/cli.py b/humanfriendly/cli.py
index eb81db1..5dfc14a 100644
--- a/humanfriendly/cli.py
+++ b/humanfriendly/cli.py
@@ -79,10 +79,14 @@
# Standard library modules.
import functools
import getopt
-import pipes
import subprocess
import sys
+try:
+ from shlex import quote # Python 3
+except ImportError:
+ from pipes import quote # Python 2 (removed in 3.13)
+
# Modules included in our package.
from humanfriendly import (
Timer,
@@ -176,7 +180,7 @@ def main():
def run_command(command_line):
"""Run an external command and show a spinner while the command is running."""
timer = Timer()
- spinner_label = "Waiting for command: %s" % " ".join(map(pipes.quote, command_line))
+ spinner_label = "Waiting for command: %s" % " ".join(map(quote, command_line))
with Spinner(label=spinner_label, timer=timer) as spinner:
process = subprocess.Popen(command_line)
while True:
diff --git a/humanfriendly/testing.py b/humanfriendly/testing.py
index f6abddf..f9d66e4 100644
--- a/humanfriendly/testing.py
+++ b/humanfriendly/testing.py
@@ -25,13 +25,17 @@
import functools
import logging
import os
-import pipes
import shutil
import sys
import tempfile
import time
import unittest
+try:
+ from shlex import quote # Python 3
+except ImportError:
+ from pipes import quote # Python 2 (removed in 3.13)
+
# Modules included in our package.
from humanfriendly.compat import StringIO
from humanfriendly.text import random_string
@@ -521,7 +525,7 @@ def __enter__(self):
pathname = os.path.join(directory, self.program_name)
with open(pathname, 'w') as handle:
handle.write('#!/bin/sh\n')
- handle.write('echo > %s\n' % pipes.quote(self.program_signal_file))
+ handle.write('echo > %s\n' % quote(self.program_signal_file))
if self.program_script:
handle.write('%s\n' % self.program_script.strip())
handle.write('exit %i\n' % self.program_returncode)