Hello community,

here is the log from the commit of package python-oslo.utils for 
openSUSE:Factory checked in at 2018-02-14 10:51:39
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-oslo.utils (Old)
 and      /work/SRC/openSUSE:Factory/.python-oslo.utils.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-oslo.utils"

Wed Feb 14 10:51:39 2018 rev:14 rq:576275 version:3.35.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-oslo.utils/python-oslo.utils.changes      
2018-01-17 21:56:33.672133766 +0100
+++ /work/SRC/openSUSE:Factory/.python-oslo.utils.new/python-oslo.utils.changes 
2018-02-14 10:51:44.937409698 +0100
@@ -1,0 +2,11 @@
+Tue Feb 13 13:36:50 UTC 2018 - dmuel...@suse.com
+
+- add 0001-Fix-breaking-unit-tests-due-to-iso8601-changes.patch
+
+-------------------------------------------------------------------
+Tue Jan 30 15:15:15 UTC 2018 - cloud-de...@suse.de
+
+- update to version 3.35.0
+  - Add a mixed mode parser to string_to_bytes
+
+-------------------------------------------------------------------

Old:
----
  oslo.utils-3.34.0.tar.gz

New:
----
  0001-Fix-breaking-unit-tests-due-to-iso8601-changes.patch
  oslo.utils-3.35.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-oslo.utils.spec ++++++
--- /var/tmp/diff_new_pack.J5q554/_old  2018-02-14 10:51:45.465390696 +0100
+++ /var/tmp/diff_new_pack.J5q554/_new  2018-02-14 10:51:45.469390552 +0100
@@ -17,13 +17,14 @@
 
 
 Name:           python-oslo.utils
-Version:        3.34.0
+Version:        3.35.0
 Release:        0
 Summary:        OpenStack Utils Library
 License:        Apache-2.0
 Group:          Development/Languages/Python
 Url:            https://launchpad.net/oslo.utils
-Source0:        
https://files.pythonhosted.org/packages/source/o/oslo.utils/oslo.utils-3.34.0.tar.gz
+Source0:        
https://files.pythonhosted.org/packages/source/o/oslo.utils/oslo.utils-3.35.0.tar.gz
+Patch1:         0001-Fix-breaking-unit-tests-due-to-iso8601-changes.patch
 BuildRequires:  openstack-macros
 BuildRequires:  python2-Babel
 BuildRequires:  python2-ddt
@@ -85,7 +86,8 @@
 Documentation for OpenStack utils library.
 
 %prep
-%autosetup -p1 -n oslo.utils-3.34.0
+%autosetup -p1 -n oslo.utils-3.35.0
+
 sed -i 's/^warning-is-error.*/warning-is-error = 0/g' setup.cfg
 %py_req_cleanup
 
@@ -100,6 +102,11 @@
 # remove the sphinx-build leftovers
 rm -rf doc/build/html/.{doctrees,buildinfo}
 
+%check
+%{python_expand rm -rf .testrepository
+$python setup.py test
+}
+
 %files %{python_files}
 %license LICENSE
 %doc ChangeLog README.rst

++++++ 0001-Fix-breaking-unit-tests-due-to-iso8601-changes.patch ++++++
>From 010fe3b1023871740b57dbc450f80e6c0c0f6e43 Mon Sep 17 00:00:00 2001
From: "John L. Villalovos" <openstack....@sodarock.com>
Date: Mon, 5 Feb 2018 22:29:38 -0800
Subject: [PATCH] Fix breaking unit tests due to iso8601 changes

The move from iso8601===0.1.11 to iso8601===0.1.12 broke unit
tests in oslo.utils.

iso8601 used to do:
    from datetime import datetime

But now they call datetime.datetime():
    import datetime
    datetime.datetime()

Unfortunately the unit tests that mocked datetime.datetime() are now
mocking the one in iso8601. This causes a failure in the unit tests.

Fix this by using the 'wraps' argument to mock. So that the calls will
get passed through to datetime.datetime. Also changed to using the
decorator style of mock.

In addition Python 3 unit tests were broken due to changing how the
UTC time zone is represented from 'UTC' to 'UTC+00:00'.

Closes-Bug: #1747575
Closes-Bug: #1744160
Change-Id: Ia80ffb5e571cc5366bef2bc1a32c457a3c16843d
---
 oslo_utils/tests/test_timeutils.py | 52 ++++++++++++++++++--------------------
 oslo_utils/timeutils.py            |  9 +++++--
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/oslo_utils/tests/test_timeutils.py 
b/oslo_utils/tests/test_timeutils.py
index b1b1f8a..77b1aa1 100644
--- a/oslo_utils/tests/test_timeutils.py
+++ b/oslo_utils/tests/test_timeutils.py
@@ -87,20 +87,18 @@ class TimeUtilsTest(test_base.BaseTestCase):
         t = timeutils.parse_strtime(s)
         self.assertEqual(orig_t, t)
 
-    def _test_is_older_than(self, fn):
-        strptime = datetime.datetime.strptime
-        with mock.patch('datetime.datetime') as datetime_mock:
-            datetime_mock.utcnow.return_value = self.skynet_self_aware_time
-            datetime_mock.strptime = strptime
-            expect_true = timeutils.is_older_than(fn(self.one_minute_before),
-                                                  59)
-            self.assertTrue(expect_true)
-            expect_false = timeutils.is_older_than(fn(self.one_minute_before),
-                                                   60)
-            self.assertFalse(expect_false)
-            expect_false = timeutils.is_older_than(fn(self.one_minute_before),
-                                                   61)
-            self.assertFalse(expect_false)
+    @mock.patch('datetime.datetime', wraps=datetime.datetime)
+    def _test_is_older_than(self, fn, datetime_mock):
+        datetime_mock.utcnow.return_value = self.skynet_self_aware_time
+        expect_true = timeutils.is_older_than(fn(self.one_minute_before),
+                                              59)
+        self.assertTrue(expect_true)
+        expect_false = timeutils.is_older_than(fn(self.one_minute_before),
+                                               60)
+        self.assertFalse(expect_false)
+        expect_false = timeutils.is_older_than(fn(self.one_minute_before),
+                                               61)
+        self.assertFalse(expect_false)
 
     def test_is_older_than_datetime(self):
         self._test_is_older_than(lambda x: x)
@@ -118,20 +116,18 @@ class TimeUtilsTest(test_base.BaseTestCase):
             tzinfo=iso8601.iso8601.FixedOffset(1, 0, 'foo')).replace(
                 hour=7))
 
-    def _test_is_newer_than(self, fn):
-        strptime = datetime.datetime.strptime
-        with mock.patch('datetime.datetime') as datetime_mock:
-            datetime_mock.utcnow.return_value = self.skynet_self_aware_time
-            datetime_mock.strptime = strptime
-            expect_true = timeutils.is_newer_than(fn(self.one_minute_after),
-                                                  59)
-            self.assertTrue(expect_true)
-            expect_false = timeutils.is_newer_than(fn(self.one_minute_after),
-                                                   60)
-            self.assertFalse(expect_false)
-            expect_false = timeutils.is_newer_than(fn(self.one_minute_after),
-                                                   61)
-            self.assertFalse(expect_false)
+    @mock.patch('datetime.datetime', wraps=datetime.datetime)
+    def _test_is_newer_than(self, fn, datetime_mock):
+        datetime_mock.utcnow.return_value = self.skynet_self_aware_time
+        expect_true = timeutils.is_newer_than(fn(self.one_minute_after),
+                                              59)
+        self.assertTrue(expect_true)
+        expect_false = timeutils.is_newer_than(fn(self.one_minute_after),
+                                               60)
+        self.assertFalse(expect_false)
+        expect_false = timeutils.is_newer_than(fn(self.one_minute_after),
+                                               61)
+        self.assertFalse(expect_false)
 
     def test_is_newer_than_datetime(self):
         self._test_is_newer_than(lambda x: x)
diff --git a/oslo_utils/timeutils.py b/oslo_utils/timeutils.py
index d467972..e8eb990 100644
--- a/oslo_utils/timeutils.py
+++ b/oslo_utils/timeutils.py
@@ -55,7 +55,8 @@ def isotime(at=None, subsecond=False):
                      if not subsecond
                      else _ISO8601_TIME_FORMAT_SUBSECOND)
     tz = at.tzinfo.tzname(None) if at.tzinfo else 'UTC'
-    st += ('Z' if tz == 'UTC' else tz)
+    # Need to handle either iso8601 or python UTC format
+    st += ('Z' if tz in ('UTC', 'UTC+00:00') else tz)
     return st
 
 
@@ -256,7 +257,9 @@ def marshall_now(now=None):
              minute=now.minute, second=now.second,
              microsecond=now.microsecond)
     if now.tzinfo:
-        d['tzname'] = now.tzinfo.tzname(None)
+        # Need to handle either iso8601 or python UTC format
+        tzname = now.tzinfo.tzname(None)
+        d['tzname'] = 'UTC' if tzname == 'UTC+00:00' else tzname
     return d
 
 
@@ -283,6 +286,8 @@ def unmarshall_time(tyme):
                            microsecond=tyme['microsecond'])
     tzname = tyme.get('tzname')
     if tzname:
+        # Need to handle either iso8601 or python UTC format
+        tzname = 'UTC' if tzname == 'UTC+00:00' else tzname
         tzinfo = pytz.timezone(tzname)
         dt = tzinfo.localize(dt)
     return dt
-- 
2.16.1

++++++ oslo.utils-3.34.0.tar.gz -> oslo.utils-3.35.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/oslo.utils-3.34.0/AUTHORS 
new/oslo.utils-3.35.0/AUTHORS
--- old/oslo.utils-3.34.0/AUTHORS       2018-01-08 15:14:46.000000000 +0100
+++ new/oslo.utils-3.35.0/AUTHORS       2018-01-15 22:08:44.000000000 +0100
@@ -53,6 +53,7 @@
 Ghe Rivero <g...@debian.org>
 Guang Yee <guang....@hp.com>
 Hanxi Liu <hanxi....@easystack.cn>
+Ian Wienand <iwien...@redhat.com>
 Ihar Hrachyshka <ihrac...@redhat.com>
 Ildiko <ildiko.van...@ericsson.com>
 Ivan Kolodyazhny <e...@e0ne.info>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/oslo.utils-3.34.0/ChangeLog 
new/oslo.utils-3.35.0/ChangeLog
--- old/oslo.utils-3.34.0/ChangeLog     2018-01-08 15:14:46.000000000 +0100
+++ new/oslo.utils-3.35.0/ChangeLog     2018-01-15 22:08:44.000000000 +0100
@@ -1,6 +1,10 @@
 CHANGES
 =======
 
+3.35.0
+------
+
+
 3.34.0
 ------
 
@@ -35,6 +39,7 @@
 
 * Updated from global requirements
 * Use six.binary\_type to point to the right type
+* Add a mixed mode parser to string\_to\_bytes
 * Updated from global requirements
 * Fix some reST field lists in docstrings
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/oslo.utils-3.34.0/PKG-INFO 
new/oslo.utils-3.35.0/PKG-INFO
--- old/oslo.utils-3.34.0/PKG-INFO      2018-01-08 15:14:46.000000000 +0100
+++ new/oslo.utils-3.35.0/PKG-INFO      2018-01-15 22:08:44.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: oslo.utils
-Version: 3.34.0
+Version: 3.35.0
 Summary: Oslo Utility library
 Home-page: https://docs.openstack.org/oslo.utils/latest/
 Author: OpenStack
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/oslo.utils-3.34.0/oslo.utils.egg-info/PKG-INFO 
new/oslo.utils-3.35.0/oslo.utils.egg-info/PKG-INFO
--- old/oslo.utils-3.34.0/oslo.utils.egg-info/PKG-INFO  2018-01-08 
15:14:46.000000000 +0100
+++ new/oslo.utils-3.35.0/oslo.utils.egg-info/PKG-INFO  2018-01-15 
22:08:44.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: oslo.utils
-Version: 3.34.0
+Version: 3.35.0
 Summary: Oslo Utility library
 Home-page: https://docs.openstack.org/oslo.utils/latest/
 Author: OpenStack
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/oslo.utils-3.34.0/oslo.utils.egg-info/pbr.json 
new/oslo.utils-3.35.0/oslo.utils.egg-info/pbr.json
--- old/oslo.utils-3.34.0/oslo.utils.egg-info/pbr.json  2018-01-08 
15:14:46.000000000 +0100
+++ new/oslo.utils-3.35.0/oslo.utils.egg-info/pbr.json  2018-01-15 
22:08:44.000000000 +0100
@@ -1 +1 @@
-{"git_version": "d9ec025", "is_release": true}
\ No newline at end of file
+{"git_version": "a449545", "is_release": true}
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/oslo.utils-3.34.0/oslo_utils/strutils.py 
new/oslo.utils-3.35.0/oslo_utils/strutils.py
--- old/oslo.utils-3.34.0/oslo_utils/strutils.py        2018-01-08 
15:12:19.000000000 +0100
+++ new/oslo.utils-3.35.0/oslo_utils/strutils.py        2018-01-15 
22:05:53.000000000 +0100
@@ -44,6 +44,7 @@
 UNIT_SYSTEM_INFO = {
     'IEC': (1024, re.compile(r'(^[-+]?\d*\.?\d+)([KMGT]i?)?(b|bit|B)$')),
     'SI': (1000, re.compile(r'(^[-+]?\d*\.?\d+)([kMGT])?(b|bit|B)$')),
+    'mixed': (None, re.compile(r'(^[-+]?\d*\.?\d+)([kKMGT]i?)?(b|bit|B)$')),
 }
 
 TRUE_STRINGS = ('1', 't', 'true', 'on', 'y', 'yes')
@@ -164,7 +165,7 @@
 def string_to_bytes(text, unit_system='IEC', return_int=False):
     """Converts a string into an float representation of bytes.
 
-    The units supported for IEC ::
+    The units supported for IEC / mixed::
 
         Kb(it), Kib(it), Mb(it), Mib(it), Gb(it), Gib(it), Tb(it), Tib(it)
         KB, KiB, MB, MiB, GB, GiB, TB, TiB
@@ -174,7 +175,17 @@
         kb(it), Mb(it), Gb(it), Tb(it)
         kB, MB, GB, TB
 
-    Note that the SI unit system does not support capital letter 'K'
+    SI units are interpreted as power-of-ten (e.g. 1kb = 1000b).  Note
+    that the SI unit system does not support capital letter 'K'
+
+    IEC units are interpreted as power-of-two (e.g. 1MiB = 1MB =
+    1024b)
+
+    Mixed units interpret the "i" to mean IEC, and no "i" to mean SI
+    (e.g. 1kb = 1000b, 1kib == 1024b).  Additionaly, mixed units
+    interpret 'K' as power-of-ten.  This mode is not particuarly
+    useful for new code, but can help with compatability for parsers
+    such as GNU parted.
 
     :param text: String input for bytes size conversion.
     :param unit_system: Unit system for byte size conversion.
@@ -195,9 +206,22 @@
         unit_prefix = match.group(2)
         if match.group(3) in ['b', 'bit']:
             magnitude /= 8
+
+        # In the mixed matcher, IEC units (with a trailing 'i') are
+        # interpreted as power-of-two, others as power-of-ten
+        if unit_system == 'mixed':
+            if unit_prefix and not unit_prefix.endswith('i'):
+                # For maximum compatability in mixed mode, we understand
+                # "K" (which is not strict SI) as "k"
+                if unit_prefix.startswith == 'K':
+                    unit_prefix = 'k'
+                base = 1000
+            else:
+                base = 1024
     else:
         msg = _('Invalid string format: %s') % text
         raise ValueError(msg)
+
     if not unit_prefix:
         res = magnitude
     else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/oslo.utils-3.34.0/oslo_utils/tests/test_strutils.py 
new/oslo.utils-3.35.0/oslo_utils/tests/test_strutils.py
--- old/oslo.utils-3.34.0/oslo_utils/tests/test_strutils.py     2018-01-08 
15:12:02.000000000 +0100
+++ new/oslo.utils-3.35.0/oslo_utils/tests/test_strutils.py     2018-01-15 
22:05:53.000000000 +0100
@@ -187,6 +187,7 @@
     _unit_system = [
         ('si', dict(unit_system='SI')),
         ('iec', dict(unit_system='IEC')),
+        ('mixed', dict(unit_system='mixed')),
         ('invalid_unit_system', dict(unit_system='KKK', assert_error=True)),
     ]
 
@@ -259,6 +260,14 @@
                     res = getattr(units, unit_prefix)
                 else:
                     res = getattr(units, '%si' % unit_prefix)
+            elif unit_system == 'mixed':
+                # Note: this will return 'i' units as power-of-two,
+                # and other units as power-of-ten.  Additionally, for
+                # compatability a "K" is interpreted as "k" in mixed
+                # mode
+                if unit_prefix == 'K':
+                    unit_prefix = 'k'
+                res = getattr(units, unit_prefix)
             return res
 
         text = ''.join([self.sign, self.magnitude, self.unit_prefix,


Reply via email to