Hello community,
here is the log from the commit of package python-python-utils for
openSUSE:Factory checked in at 2020-03-20 23:59:19
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-python-utils (Old)
and /work/SRC/openSUSE:Factory/.python-python-utils.new.3160 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-python-utils"
Fri Mar 20 23:59:19 2020 rev:4 rq:786827 version:2.4.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-python-utils/python-python-utils.changes
2018-12-24 11:42:44.905379963 +0100
+++
/work/SRC/openSUSE:Factory/.python-python-utils.new.3160/python-python-utils.changes
2020-03-21 00:02:48.733145745 +0100
@@ -1,0 +2,6 @@
+Fri Mar 20 11:00:23 UTC 2020 - [email protected]
+
+- version update to 2.4.0
+ * added map/remap/scale/rescale function
+
+-------------------------------------------------------------------
Old:
----
python-utils-2.3.0.tar.gz
New:
----
python-utils-2.4.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-python-utils.spec ++++++
--- /var/tmp/diff_new_pack.3wFsXQ/_old 2020-03-21 00:02:50.633146787 +0100
+++ /var/tmp/diff_new_pack.3wFsXQ/_new 2020-03-21 00:02:50.637146788 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-python-utils
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,12 +18,12 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-python-utils
-Version: 2.3.0
+Version: 2.4.0
Release: 0
Summary: Utilities not included with the standard Python install
License: BSD-3-Clause
Group: Development/Languages/Python
-Url: https://github.com/WoLpH/python-utils
+URL: https://github.com/WoLpH/python-utils
Source:
https://files.pythonhosted.org/packages/source/p/python-utils/python-utils-%{version}.tar.gz
BuildRequires: %{python_module pytest-runner}
BuildRequires: %{python_module setuptools}
++++++ python-utils-2.3.0.tar.gz -> python-utils-2.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/PKG-INFO
new/python-utils-2.4.0/PKG-INFO
--- old/python-utils-2.3.0/PKG-INFO 2018-02-12 01:22:30.000000000 +0100
+++ new/python-utils-2.4.0/PKG-INFO 2020-03-03 02:01:40.710834500 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: python-utils
-Version: 2.3.0
+Version: 2.4.0
Summary: Python Utils is a module with some convenient utilities not included
with the standard Python install
Home-page: https://github.com/WoLpH/python-utils
Author: Rick van Hattem
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/python_utils/__about__.py
new/python-utils-2.4.0/python_utils/__about__.py
--- old/python-utils-2.3.0/python_utils/__about__.py 2018-02-12
00:05:31.000000000 +0100
+++ new/python-utils-2.4.0/python_utils/__about__.py 2020-03-03
02:01:23.000000000 +0100
@@ -1,5 +1,5 @@
__package_name__ = 'python-utils'
-__version__ = '2.3.0'
+__version__ = '2.4.0'
__author__ = 'Rick van Hattem'
__author_email__ = '[email protected]'
__description__ = (
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/python_utils/converters.py
new/python-utils-2.4.0/python_utils/converters.py
--- old/python-utils-2.3.0/python_utils/converters.py 2018-02-12
00:05:31.000000000 +0100
+++ new/python-utils-2.4.0/python_utils/converters.py 2020-03-03
02:01:23.000000000 +0100
@@ -7,7 +7,7 @@
def to_int(input_, default=0, exception=(ValueError, TypeError), regexp=None):
- '''
+ r'''
Convert the given input to an integer or return default
When trying to convert the exceptions given in the exception parameter
@@ -37,23 +37,23 @@
123
>>> to_int('abc123abc456', regexp=True)
123
- >>> to_int('abc123', regexp=re.compile('(\d+)'))
+ >>> to_int('abc123', regexp=re.compile(r'(\d+)'))
123
- >>> to_int('123abc', regexp=re.compile('(\d+)'))
+ >>> to_int('123abc', regexp=re.compile(r'(\d+)'))
123
- >>> to_int('abc123abc', regexp=re.compile('(\d+)'))
+ >>> to_int('abc123abc', regexp=re.compile(r'(\d+)'))
123
- >>> to_int('abc123abc456', regexp=re.compile('(\d+)'))
+ >>> to_int('abc123abc456', regexp=re.compile(r'(\d+)'))
123
- >>> to_int('abc123', regexp='(\d+)')
+ >>> to_int('abc123', regexp=r'(\d+)')
123
- >>> to_int('123abc', regexp='(\d+)')
+ >>> to_int('123abc', regexp=r'(\d+)')
123
- >>> to_int('abc', regexp='(\d+)')
+ >>> to_int('abc', regexp=r'(\d+)')
0
- >>> to_int('abc123abc', regexp='(\d+)')
+ >>> to_int('abc123abc', regexp=r'(\d+)')
123
- >>> to_int('abc123abc456', regexp='(\d+)')
+ >>> to_int('abc123abc456', regexp=r'(\d+)')
123
>>> to_int('1234', default=1)
1234
@@ -66,7 +66,7 @@
'''
if regexp is True:
- regexp = re.compile('(\d+)')
+ regexp = re.compile(r'(\d+)')
elif isinstance(regexp, six.string_types):
regexp = re.compile(regexp)
elif hasattr(regexp, 'search'):
@@ -86,7 +86,7 @@
def to_float(input_, default=0, exception=(ValueError, TypeError),
regexp=None):
- '''
+ r'''
Convert the given `input_` to an integer or return default
When trying to convert the exceptions given in the exception parameter
@@ -110,23 +110,23 @@
'123.00'
>>> '%.2f' % to_float('abc0.456', regexp=True)
'0.46'
- >>> '%.2f' % to_float('abc123.456', regexp=re.compile('(\d+\.\d+)'))
+ >>> '%.2f' % to_float('abc123.456', regexp=re.compile(r'(\d+\.\d+)'))
'123.46'
- >>> '%.2f' % to_float('123.456abc', regexp=re.compile('(\d+\.\d+)'))
+ >>> '%.2f' % to_float('123.456abc', regexp=re.compile(r'(\d+\.\d+)'))
'123.46'
- >>> '%.2f' % to_float('abc123.46abc', regexp=re.compile('(\d+\.\d+)'))
+ >>> '%.2f' % to_float('abc123.46abc', regexp=re.compile(r'(\d+\.\d+)'))
'123.46'
- >>> '%.2f' % to_float('abc123abc456', regexp=re.compile('(\d+(\.\d+|))'))
+ >>> '%.2f' % to_float('abc123abc456', regexp=re.compile(r'(\d+(\.\d+|))'))
'123.00'
- >>> '%.2f' % to_float('abc', regexp='(\d+)')
+ >>> '%.2f' % to_float('abc', regexp=r'(\d+)')
'0.00'
- >>> '%.2f' % to_float('abc123', regexp='(\d+)')
+ >>> '%.2f' % to_float('abc123', regexp=r'(\d+)')
'123.00'
- >>> '%.2f' % to_float('123abc', regexp='(\d+)')
+ >>> '%.2f' % to_float('123abc', regexp=r'(\d+)')
'123.00'
- >>> '%.2f' % to_float('abc123abc', regexp='(\d+)')
+ >>> '%.2f' % to_float('abc123abc', regexp=r'(\d+)')
'123.00'
- >>> '%.2f' % to_float('abc123abc456', regexp='(\d+)')
+ >>> '%.2f' % to_float('abc123abc456', regexp=r'(\d+)')
'123.00'
>>> '%.2f' % to_float('1234', default=1)
'1234.00'
@@ -139,7 +139,7 @@
'''
if regexp is True:
- regexp = re.compile('(\d+(\.\d+|))')
+ regexp = re.compile(r'(\d+(\.\d+|))')
elif isinstance(regexp, six.string_types):
regexp = re.compile(regexp)
elif hasattr(regexp, 'search'):
@@ -234,3 +234,67 @@
scaled = float(x) / (2 ** (10 * power))
return scaled, power
+
+def remap(value, old_min, old_max, new_min, new_max):
+ """
+ remap a value from one range into another.
+
+ >>> remap(500, 0, 1000, 0, 100)
+ 50
+ >>> remap(250.0, 0.0, 1000.0, 0.0, 100.0)
+ 25.0
+ >>> remap(-75, -100, 0, -1000, 0)
+ -750
+ >>> remap(33, 0, 100, -500, 500)
+ -170
+
+ This is a great use case example. Take an AVR that has dB values the
+ minimum being -80dB and the maximum being 10dB and you want to convert
+ volume percent to the equilivint in that dB range
+
+ >>> remap(46.0, 0.0, 100.0, -80.0, 10.0)
+ -38.6
+
+ Some edge cases to test
+ >>> remap(0, 0, 0, 0, 0)
+ 0
+ >>> remap(0, 0, 0, 1, 0)
+ 1
+
+ :param value: value to be converted
+ :type value: int, float
+
+ :param old_min: minimum of the range for the value that has been passed
+ :type old_min: int, float
+
+ :param old_max: maximum of the range for the value that has been passed
+ :type old_max: int, float
+
+ :param new_min: the minimum of the new range
+ :type new_min: int, float
+
+ :param new_max: the maximum of the new range
+ :type new_max: int, float
+
+ :return: value that has been re ranged, if the value is an int floor
+ division is used so the returned value will always be rounded down
+ to the closest whole number.
+ :rtype: int, float
+ """
+ old_range = old_max - old_min
+ new_range = new_max - new_min
+ if new_range == 0:
+ return 0
+
+ if old_range == 0:
+ new_value = new_min
+ else:
+ new_value = (value - old_min) * new_range
+ if isinstance(value, int):
+ new_value = new_value // old_range
+ else:
+ new_value = new_value / old_range
+
+ new_value += new_min
+
+ return new_value
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/python_utils/time.py
new/python-utils-2.4.0/python_utils/time.py
--- old/python-utils-2.3.0/python_utils/time.py 2018-02-12 00:05:31.000000000
+0100
+++ new/python-utils-2.4.0/python_utils/time.py 2020-03-03 02:01:23.000000000
+0100
@@ -71,9 +71,9 @@
seconds = seconds - (seconds % precision_seconds)
return str(datetime.timedelta(seconds=seconds))
- elif isinstance(timestamp, datetime.datetime):
+ elif isinstance(timestamp, datetime.datetime): # pragma: no cover
# Python 2 doesn't have the timestamp method
- if hasattr(timestamp, 'timestamp'): # pragma: no cover
+ if hasattr(timestamp, 'timestamp'):
seconds = timestamp.timestamp()
else:
seconds = timedelta_to_seconds(timestamp - epoch)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/python_utils.egg-info/PKG-INFO
new/python-utils-2.4.0/python_utils.egg-info/PKG-INFO
--- old/python-utils-2.3.0/python_utils.egg-info/PKG-INFO 2018-02-12
01:22:30.000000000 +0100
+++ new/python-utils-2.4.0/python_utils.egg-info/PKG-INFO 2020-03-03
02:01:40.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: python-utils
-Version: 2.3.0
+Version: 2.4.0
Summary: Python Utils is a module with some convenient utilities not included
with the standard Python install
Home-page: https://github.com/WoLpH/python-utils
Author: Rick van Hattem
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/python_utils.egg-info/SOURCES.txt
new/python-utils-2.4.0/python_utils.egg-info/SOURCES.txt
--- old/python-utils-2.3.0/python_utils.egg-info/SOURCES.txt 2018-02-12
01:22:30.000000000 +0100
+++ new/python-utils-2.4.0/python_utils.egg-info/SOURCES.txt 2020-03-03
02:01:40.000000000 +0100
@@ -32,11 +32,13 @@
tests/__pycache__/test_import.cpython-35-PYTEST.pyc
tests/__pycache__/test_import.cpython-35.pyc
tests/__pycache__/test_import.cpython-36-PYTEST.pyc
+tests/__pycache__/test_import.cpython-38-pytest-5.3.5.pyc
tests/__pycache__/test_import.pypy-27-PYTEST.pyc
tests/__pycache__/test_import.pypy3-24-PYTEST.pyc
tests/__pycache__/test_python_utils.cpython-27-PYTEST.pyc
tests/__pycache__/test_python_utils.cpython-35-PYTEST.pyc
tests/__pycache__/test_python_utils.cpython-35.pyc
tests/__pycache__/test_python_utils.cpython-36-PYTEST.pyc
+tests/__pycache__/test_python_utils.cpython-38-pytest-5.3.5.pyc
tests/__pycache__/test_python_utils.pypy-27-PYTEST.pyc
tests/__pycache__/test_python_utils.pypy3-24-PYTEST.pyc
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/setup.cfg
new/python-utils-2.4.0/setup.cfg
--- old/python-utils-2.3.0/setup.cfg 2018-02-12 01:22:30.000000000 +0100
+++ new/python-utils-2.4.0/setup.cfg 2020-03-03 02:01:40.711674000 +0100
@@ -1,3 +1,6 @@
+[aliases]
+test = pytest
+
[metadata]
description-file = README.rst
@@ -28,5 +31,4 @@
[egg_info]
tag_build =
tag_date = 0
-tag_svn_revision = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/setup.py
new/python-utils-2.4.0/setup.py
--- old/python-utils-2.3.0/setup.py 2016-12-12 10:53:50.000000000 +0100
+++ new/python-utils-2.4.0/setup.py 2020-03-03 02:01:23.000000000 +0100
@@ -1,4 +1,5 @@
import os
+import sys
import setuptools
# To prevent importing about and thereby breaking the coverage info we use this
@@ -14,9 +15,13 @@
long_description = 'See http://pypi.python.org/pypi/python-utils/'
+needs_pytest = set(['ptr', 'pytest', 'test']).intersection(sys.argv)
+pytest_runner = ['pytest-runner'] if needs_pytest else []
+
+
if __name__ == '__main__':
setuptools.setup(
- name=about['__package_name__'],
+ name='python-utils',
version=about['__version__'],
author=about['__author__'],
author_email=about['__author_email__'],
@@ -27,7 +32,7 @@
long_description=long_description,
install_requires=['six'],
tests_require=['pytest'],
- setup_requires=['pytest-runner'],
+ setup_requires=[] + pytest_runner,
classifiers=['License :: OSI Approved :: BSD License'],
)
Binary files
old/python-utils-2.3.0/tests/__pycache__/test_import.cpython-38-pytest-5.3.5.pyc
and
new/python-utils-2.4.0/tests/__pycache__/test_import.cpython-38-pytest-5.3.5.pyc
differ
Binary files
old/python-utils-2.3.0/tests/__pycache__/test_python_utils.cpython-38-pytest-5.3.5.pyc
and
new/python-utils-2.4.0/tests/__pycache__/test_python_utils.cpython-38-pytest-5.3.5.pyc
differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/python-utils-2.3.0/tox.ini
new/python-utils-2.4.0/tox.ini
--- old/python-utils-2.3.0/tox.ini 2018-02-12 00:05:31.000000000 +0100
+++ new/python-utils-2.4.0/tox.ini 2020-03-03 02:01:23.000000000 +0100
@@ -1,25 +1,27 @@
[tox]
-envlist = py27, py33, py34, py35, py36, pypy, flake8, docs
+envlist = py27, py35, py36, py37, py38, py39, pypy, flake8, docs
skip_missing_interpreters = True
[testenv]
basepython =
py27: python2.7
- py34: python3.4
py35: python3.5
py36: python3.6
+ py37: python3.7
+ py38: python3.8
+ py39: python3.9
pypy: pypy
deps = -r{toxinidir}/tests/requirements.txt
-commands = python setup.py pytest {posargs}
+commands = python setup.py test {posargs}
[testenv:flake8]
-basepython = python2.7
+basepython = python3.7
deps = flake8
commands = flake8 --ignore=W391 python_utils {posargs}
[testenv:docs]
-basepython = python2.7
+basepython = python3.7
whitelist_externals =
rm
cd