Hello community,

here is the log from the commit of package python-distro for openSUSE:Factory 
checked in at 2018-01-01 22:35:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-distro (Old)
 and      /work/SRC/openSUSE:Factory/.python-distro.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-distro"

Mon Jan  1 22:35:36 2018 rev:3 rq:560908 version:1.2.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-distro/python-distro.changes      
2017-12-11 18:56:26.238749318 +0100
+++ /work/SRC/openSUSE:Factory/.python-distro.new/python-distro.changes 
2018-01-01 22:35:42.618384733 +0100
@@ -1,0 +2,6 @@
+Sun Dec 24 19:11:15 UTC 2017 - sebix+novell....@sebix.at
+
+- update to version 1.2.0:
+ * Explicitly set Python versions for flake8 tests.
+
+-------------------------------------------------------------------

Old:
----
  distro-1.1.0.tar.gz

New:
----
  distro-1.2.0.tar.gz

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

Other differences:
------------------
++++++ python-distro.spec ++++++
--- /var/tmp/diff_new_pack.A8p7Wt/_old  2018-01-01 22:35:43.678030946 +0100
+++ /var/tmp/diff_new_pack.A8p7Wt/_new  2018-01-01 22:35:43.682029611 +0100
@@ -13,22 +13,23 @@
 # published by the Open Source Initiative.
 
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
+#
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %{!?license: %global license %doc}
 %bcond_without test
 Name:           python-distro
-Version:        1.1.0
+Version:        1.2.0
 Release:        0
-License:        Apache-2.0
 Summary:        Linux Distribution - a Linux OS platform information API
-Url:            https://github.com/nir0s/distro
+License:        Apache-2.0
 Group:          Development/Languages/Python
+Url:            https://github.com/nir0s/distro
 Source:         
https://files.pythonhosted.org/packages/source/d/distro/distro-%{version}.tar.gz
-BuildRequires:  python-rpm-macros
 BuildRequires:  %{python_module devel}
 BuildRequires:  %{python_module setuptools}
+BuildRequires:  python-rpm-macros
 # SECTION test
 %if %{with test}
 BuildRequires:  %{python_module pytest}

++++++ distro-1.1.0.tar.gz -> distro-1.2.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/distro-1.1.0/CHANGES new/distro-1.2.0/CHANGES
--- old/distro-1.1.0/CHANGES    2017-10-11 19:51:17.000000000 +0200
+++ new/distro-1.2.0/CHANGES    2017-12-24 19:07:50.000000000 +0100
@@ -1,6 +1,20 @@
-**1.0.5 (unreleased)**
+**1.2.0 (2017.12.24)**
+
+* Lazily load parsers to speed up import time.
+* Don't raise import error on non-linux os.
+* Decode stdout of shell sys.getfilesystemencoding().
+* Explicitly set Python versions for flake8 tests.
+
+
+**1.1.0 (2017.11.28)**
+
+Note: This version removes official support for Python 2.6. If you need a 
version that is tested on Python 2.6, please use `distro<=1.0.4`.
+
+In addition:
+
+* Add tests for MandrivaLinux, CloudLinux 5,6,7
+* Modify MANIFEST to include resources for tests and docs in source tarballs 
(https://github.com/nir0s/distro/pull/189/files#diff-97c91a104c431d0c365565d3ac03ac13)
 
-* Include resources needed for tests and docs in source tarballs
 
 **1.0.4 (2017.04.01)**
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/distro-1.1.0/PKG-INFO new/distro-1.2.0/PKG-INFO
--- old/distro-1.1.0/PKG-INFO   2017-11-28 10:07:43.000000000 +0100
+++ new/distro-1.2.0/PKG-INFO   2017-12-24 19:08:15.000000000 +0100
@@ -1,12 +1,11 @@
 Metadata-Version: 1.1
 Name: distro
-Version: 1.1.0
+Version: 1.2.0
 Summary: Linux Distribution - a Linux OS platform information API
 Home-page: https://github.com/nir0s/distro
 Author: Nir Cohen
 Author-email: nir...@gmail.com
 License: Apache License, Version 2.0
-Description-Content-Type: UNKNOWN
 Description: Distro - a Linux OS platform information API
         ============================================
         
@@ -21,7 +20,6 @@
 Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/distro-1.1.0/README.md new/distro-1.2.0/README.md
--- old/distro-1.1.0/README.md  2017-11-28 09:58:45.000000000 +0100
+++ new/distro-1.2.0/README.md  2017-12-04 08:00:09.000000000 +0100
@@ -91,7 +91,7 @@
 
 ## Python and Distribution Support
 
-`distro` is supported and tested on Python 2.7, 3.3+ and PyPy and on
+`distro` is supported and tested on Python 2.7, 3.4+ and PyPy and on
 any Linux distribution that provides one or more of the data sources
 covered.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/distro-1.1.0/distro.egg-info/PKG-INFO 
new/distro-1.2.0/distro.egg-info/PKG-INFO
--- old/distro-1.1.0/distro.egg-info/PKG-INFO   2017-11-28 10:07:43.000000000 
+0100
+++ new/distro-1.2.0/distro.egg-info/PKG-INFO   2017-12-24 19:08:15.000000000 
+0100
@@ -1,12 +1,11 @@
 Metadata-Version: 1.1
 Name: distro
-Version: 1.1.0
+Version: 1.2.0
 Summary: Linux Distribution - a Linux OS platform information API
 Home-page: https://github.com/nir0s/distro
 Author: Nir Cohen
 Author-email: nir...@gmail.com
 License: Apache License, Version 2.0
-Description-Content-Type: UNKNOWN
 Description: Distro - a Linux OS platform information API
         ============================================
         
@@ -21,7 +20,6 @@
 Classifier: Programming Language :: Python :: 2
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/distro-1.1.0/distro.py new/distro-1.2.0/distro.py
--- old/distro-1.1.0/distro.py  2017-10-11 19:28:18.000000000 +0200
+++ new/distro-1.2.0/distro.py  2017-12-24 17:29:31.000000000 +0100
@@ -38,9 +38,6 @@
 import subprocess
 
 
-if not sys.platform.startswith('linux'):
-    raise ImportError('Unsupported platform: {0}'.format(sys.platform))
-
 _UNIXCONFDIR = os.environ.get('UNIXCONFDIR', '/etc')
 _OS_RELEASE_BASENAME = 'os-release'
 
@@ -511,6 +508,21 @@
     return _distro.distro_release_attr(attribute)
 
 
+class cached_property(object):
+    """A version of @property which caches the value.  On access, it calls the
+    underlying function and sets the value in `__dict__` so future accesses
+    will not re-call the property.
+    """
+    def __init__(self, f):
+        self._fname = f.__name__
+        self._f = f
+
+    def __get__(self, obj, owner):
+        assert obj is not None, 'call {} on an instance'.format(self._fname)
+        ret = obj.__dict__[self._fname] = self._f(obj)
+        return ret
+
+
 class LinuxDistribution(object):
     """
     Provides information about a Linux distribution.
@@ -576,6 +588,9 @@
           `distro release file`_ that is actually used as a data source. The
           empty string if no distro release file is used as a data source.
 
+        * ``include_lsb`` (bool): The result of the ``include_lsb`` parameter.
+          This controls whether the lsb information will be loaded.
+
         Raises:
 
         * :py:exc:`IOError`: Some I/O issue with an os-release file or distro
@@ -591,26 +606,20 @@
         self.os_release_file = os_release_file or \
             os.path.join(_UNIXCONFDIR, _OS_RELEASE_BASENAME)
         self.distro_release_file = distro_release_file or ''  # updated later
-        self._os_release_info = self._get_os_release_info()
-        self._lsb_release_info = self._get_lsb_release_info() \
-            if include_lsb else {}
-        self._distro_release_info = self._get_distro_release_info()
+        self.include_lsb = include_lsb
 
     def __repr__(self):
         """Return repr of all info
         """
         return \
             "LinuxDistribution(" \
-            "os_release_file={0!r}, " \
-            "distro_release_file={1!r}, " \
-            "_os_release_info={2!r}, " \
-            "_lsb_release_info={3!r}, " \
-            "_distro_release_info={4!r})".format(
-                self.os_release_file,
-                self.distro_release_file,
-                self._os_release_info,
-                self._lsb_release_info,
-                self._distro_release_info)
+            "os_release_file={self.os_release_file!r}, " \
+            "distro_release_file={self.distro_release_file!r}, " \
+            "include_lsb={self.include_lsb!r}, " \
+            "_os_release_info={self._os_release_info!r}, " \
+            "_lsb_release_info={self._lsb_release_info!r}, " \
+            "_distro_release_info={self._distro_release_info!r})".format(
+                self=self)
 
     def linux_distribution(self, full_distribution_name=True):
         """
@@ -835,7 +844,8 @@
         """
         return self._distro_release_info.get(attribute, '')
 
-    def _get_os_release_info(self):
+    @cached_property
+    def _os_release_info(self):
         """
         Get the information items from the specified os-release file.
 
@@ -907,34 +917,24 @@
                 pass
         return props
 
-    def _get_lsb_release_info(self):
+    @cached_property
+    def _lsb_release_info(self):
         """
         Get the information items from the lsb_release command output.
 
         Returns:
             A dictionary containing all information items.
         """
-        cmd = 'lsb_release -a'
-        process = subprocess.Popen(
-            cmd,
-            shell=True,
-            stdout=subprocess.PIPE,
-            stderr=subprocess.PIPE)
-        stdout, stderr = process.communicate()
-        stdout, stderr = stdout.decode('utf-8'), stderr.decode('utf-8')
-        code = process.returncode
-        if code == 0:
-            content = stdout.splitlines()
-            return self._parse_lsb_release_content(content)
-        elif code == 127:  # Command not found
+        if not self.include_lsb:
             return {}
-        else:
-            if sys.version_info[:2] >= (3, 5):
-                raise subprocess.CalledProcessError(code, cmd, stdout, stderr)
-            elif sys.version_info[:2] >= (2, 7):
-                raise subprocess.CalledProcessError(code, cmd, stdout)
-            elif sys.version_info[:2] == (2, 6):
-                raise subprocess.CalledProcessError(code, cmd)
+        with open(os.devnull, 'w') as devnull:
+            try:
+                cmd = ('lsb_release', '-a')
+                stdout = subprocess.check_output(cmd, stderr=devnull)
+            except OSError:  # Command not found
+                return {}
+        content = stdout.decode(sys.getfilesystemencoding()).splitlines()
+        return self._parse_lsb_release_content(content)
 
     @staticmethod
     def _parse_lsb_release_content(lines):
@@ -952,7 +952,6 @@
         """
         props = {}
         for line in lines:
-            line = line.decode('utf-8') if isinstance(line, bytes) else line
             kv = line.strip('\n').split(':', 1)
             if len(kv) != 2:
                 # Ignore lines without colon.
@@ -961,7 +960,8 @@
             props.update({k.replace(' ', '_').lower(): v.strip()})
         return props
 
-    def _get_distro_release_info(self):
+    @cached_property
+    def _distro_release_info(self):
         """
         Get the information items from the specified distro release file.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/distro-1.1.0/docs/index.rst 
new/distro-1.2.0/docs/index.rst
--- old/distro-1.1.0/docs/index.rst     2017-11-28 09:58:45.000000000 +0100
+++ new/distro-1.2.0/docs/index.rst     2017-12-24 17:26:22.000000000 +0100
@@ -20,11 +20,11 @@
 Compatibility
 =============
 
-The ``distro`` package is supported on Python 2.7, 3.3+ and PyPy, and on
+The ``distro`` package is supported on Python 2.7, 3.4+ and PyPy, and on
 any Linux distribution that provides one or more of the `data sources`_
 used by this package.
 
-This package is tested on Python 2.7, 3.3+ and PyPy, with test data that
+This package is tested on Python 2.7, 3.4+ and PyPy, with test data that
 mimics the exact behavior of the data sources of
 `a number of Linux distributions 
<https://github.com/nir0s/distro/tree/master/tests/resources/distros>`_.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/distro-1.1.0/setup.py new/distro-1.2.0/setup.py
--- old/distro-1.1.0/setup.py   2017-11-28 10:04:03.000000000 +0100
+++ new/distro-1.2.0/setup.py   2017-12-24 17:29:50.000000000 +0100
@@ -18,7 +18,7 @@
 
 # The following version is parsed by other parts of this package.
 # Don't change the format of the line, or the variable name.
-package_version = "1.1.0"
+package_version = "1.2.0"
 
 here = os.path.abspath(os.path.dirname(__file__))
 
@@ -53,7 +53,6 @@
         'Programming Language :: Python :: 2',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/distro-1.1.0/tests/test_distro.py 
new/distro-1.2.0/tests/test_distro.py
--- old/distro-1.1.0/tests/test_distro.py       2017-10-11 19:28:18.000000000 
+0200
+++ new/distro-1.2.0/tests/test_distro.py       2017-12-24 17:26:25.000000000 
+0100
@@ -397,7 +397,6 @@
 
     def setup_method(self, test_method):
         super(TestLSBRelease, self).setup_method(test_method)
-        self.test_method_name = test_method.__name__
         dist = test_method.__name__.split('_')[1]
         self._setup_for_distro(os.path.join(DISTROS_DIR, dist))
         self.distro = distro.LinuxDistribution(True, 'non', 'non')
@@ -502,38 +501,13 @@
         }
         self._test_outcome(desired_outcome)
 
-    def _test_lsb_release_error_level(self, errnum):
-
+    @pytest.mark.parametrize('errnum', ('001', '002', '126', '130', '255'))
+    def test_lsb_release_error_level(self, errnum):
         self._setup_for_distro(os.path.join(
             TESTDISTROS, 'lsb', 'lsb_rc{0}'.format(errnum)))
-        try:
-            distro.LinuxDistribution(True, 'non', 'non')  # NOQA
-        except Exception as _exc:
-            exc = _exc
-        else:
-            exc = None
-        assert isinstance(exc, subprocess.CalledProcessError)
-        assert exc.returncode == int(errnum)
-
-    def test_lsb_release_rc001(self):
-        errnum = self.test_method_name[-3:]
-        self._test_lsb_release_error_level(errnum)
-
-    def test_lsb_release_rc002(self):
-        errnum = self.test_method_name[-3:]
-        self._test_lsb_release_error_level(errnum)
-
-    def test_lsb_release_rc126(self):
-        errnum = self.test_method_name[-3:]
-        self._test_lsb_release_error_level(errnum)
-
-    def test_lsb_release_rc130(self):
-        errnum = self.test_method_name[-3:]
-        self._test_lsb_release_error_level(errnum)
-
-    def test_lsb_release_rc255(self):
-        errnum = self.test_method_name[-3:]
-        self._test_lsb_release_error_level(errnum)
+        with pytest.raises(subprocess.CalledProcessError) as excinfo:
+            distro.LinuxDistribution(True, 'non', 'non')._lsb_release_info
+        assert excinfo.value.returncode == int(errnum)
 
 
 @pytest.mark.skipif(not IS_LINUX, reason='Irrelevant on non-linux')


Reply via email to