Hello community, here is the log from the commit of package python3-pyudev for openSUSE:Factory checked in at 2015-12-23 08:50:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-pyudev (Old) and /work/SRC/openSUSE:Factory/.python3-pyudev.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-pyudev" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-pyudev/python3-pyudev.changes 2015-12-03 13:32:47.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python3-pyudev.new/python3-pyudev.changes 2015-12-23 08:50:42.000000000 +0100 @@ -1,0 +2,11 @@ +Tue Dec 22 01:56:17 UTC 2015 - [email protected] + +- specfile: + * require six + +- update to version 0.18.1: + * Restore raising KeyError by Attributes.as* methods when attribute + not found. + * Explicitly require six module. + +------------------------------------------------------------------- Old: ---- pyudev-0.18.tar.gz New: ---- pyudev-0.18.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-pyudev.spec ++++++ --- /var/tmp/diff_new_pack.bAjkBN/_old 2015-12-23 08:50:42.000000000 +0100 +++ /var/tmp/diff_new_pack.bAjkBN/_new 2015-12-23 08:50:42.000000000 +0100 @@ -17,7 +17,7 @@ Name: python3-pyudev -Version: 0.18 +Version: 0.18.1 Release: 0 Summary: Udev bindings for Python License: LGPL-2.1+ @@ -28,6 +28,8 @@ BuildRequires: python3-Sphinx BuildRequires: python3-devel BuildRequires: python3-setuptools +BuildRequires: python3-six +Requires: python3-six BuildArch: noarch %description ++++++ pyudev-0.18.tar.gz -> pyudev-0.18.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/CHANGES.rst new/pyudev-0.18.1/CHANGES.rst --- old/pyudev-0.18/CHANGES.rst 2015-12-01 15:11:37.000000000 +0100 +++ new/pyudev-0.18.1/CHANGES.rst 2015-12-18 18:27:19.000000000 +0100 @@ -1,3 +1,9 @@ +0.18.1 (Dec 18, 2015) +===================== + +- Restore raising KeyError by Attributes.as* methods when attribute not found. +- Explicitly require six module. + 0.18 (Dec 1, 2015) =================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/PKG-INFO new/pyudev-0.18.1/PKG-INFO --- old/pyudev-0.18/PKG-INFO 2015-12-01 15:21:36.000000000 +0100 +++ new/pyudev-0.18.1/PKG-INFO 2015-12-18 18:28:21.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pyudev -Version: 0.18 +Version: 0.18.1 Summary: A libudev binding Home-page: http://pyudev.readthedocs.org/ Author: Sebastian Wiesner diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/setup.py new/pyudev-0.18.1/setup.py --- old/pyudev-0.18/setup.py 2015-12-01 15:11:37.000000000 +0100 +++ new/pyudev-0.18.1/setup.py 2015-12-18 18:27:19.000000000 +0100 @@ -54,7 +54,10 @@ 'Topic :: Software Development :: Libraries', 'Topic :: System :: Hardware', 'Topic :: System :: Operating System Kernels :: Linux', - ], + ], + install_requires = [ + 'six' + ], package_dir={"": "src"}, packages=setuptools.find_packages("src"), ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/src/pyudev/device/_device.py new/pyudev-0.18.1/src/pyudev/device/_device.py --- old/pyudev-0.18/src/pyudev/device/_device.py 2015-12-01 15:11:37.000000000 +0100 +++ new/pyudev-0.18.1/src/pyudev/device/_device.py 2015-12-18 18:27:19.000000000 +0100 @@ -979,76 +979,86 @@ for attribute, _ in udev_list_iterate(self._libudev, attrs): yield ensure_unicode_string(attribute) - def get(self, attribute, default=None): + def _get(self, attribute): """ Get the given system ``attribute`` for the device. - ``attribute`` is a unicode or byte string containing the name of the - system attribute. - - :param str attribute: the attribute to lookup - :param object default: the default value to return - :returns: the attribute value or None if no value - :rtype: byte string or NoneType - - Returns ``default`` if lookup gets None. + :param attribute: the key for an attribute value + :type attribute: unicode or byte string + :returns: the value corresponding to ``attribute`` + :rtype: an arbitrary sequence of bytes + :raises KeyError: if no value found """ value = self._libudev.udev_device_get_sysattr_value( - self.device, - ensure_byte_string(attribute) + self.device, + ensure_byte_string(attribute) ) - return value if value is not None else default + if value is None: + raise KeyError(attribute) + return value - def asstring(self, attribute): + def get(self, attribute, default=None): """ - Get the given ``atribute`` for the device as unicode string. + Get the given system ``attribute`` for the device. - Depending on the content of the attribute, this may or may not work. - Be prepared to catch :exc:`~exceptions.UnicodeDecodeError`. + :param attribute: the key for an attribute value + :type attribute: unicode or byte string + :param default: a default if no corresponding value found + :type default: a sequence of bytes + :returns: the value corresponding to ``attribute`` or ``default`` + :rtype: object + """ + try: + return self._get(attribute) + except KeyError: + return default - ``attribute`` is a unicode or byte string containing the name of the - attribute. + def asstring(self, attribute): + """ + Get the given ``attribute`` for the device as unicode string. - Return the attribute value as byte string. Raise a - :exc:`~exceptions.KeyError`, if the given attribute is not defined - for this device, or :exc:`~exceptions.UnicodeDecodeError`, if the - content of the attribute cannot be decoded into a unicode string. + :param attribute: the key for an attribute value + :type attribute: unicode or byte string + :returns: the value corresponding to ``attribute``, as unicode + :rtype: unicode + :raises KeyError: if no value found for ``attribute`` + :raises UnicodeDecodeError: if value is not convertible """ - value = self.get(attribute) - return ensure_unicode_string(value if value is not None else str(None)) + return ensure_unicode_string(self._get(attribute)) def asint(self, attribute): """ - Get the given ``attribute`` as integer. - - ``attribute`` is a unicode or byte string containing the name of the - attribute. + Get the given ``attribute`` as an int. - Return the attribute value as integer. Raise a - :exc:`~exceptions.KeyError`, if the given attribute is not defined - for this device, or a :exc:`~exceptions.ValueError`, if the - attribute value cannot be converted to an integer. + :param attribute: the key for an attribute value + :type attribute: unicode or byte string + :returns: the value corresponding to ``attribute``, as an int + :rtype: int + :raises KeyError: if no value found for ``attribute`` + :raises UnicodeDecodeError: if value is not convertible to unicode + :raises ValueError: if unicode value can not be converted to an int """ return int(self.asstring(attribute)) def asbool(self, attribute): """ - Get the given ``attribute`` from this device as boolean. + Get the given ``attribute`` from this device as a bool. + + :param attribute: the key for an attribute value + :type attribute: unicode or byte string + :returns: the value corresponding to ``attribute``, as bool + :rtype: bool + :raises KeyError: if no value found for ``attribute`` + :raises UnicodeDecodeError: if value is not convertible to unicode + :raises ValueError: if unicode value can not be converted to a bool A boolean attribute has either a value of ``'1'`` or of ``'0'``, where ``'1'`` stands for ``True``, and ``'0'`` for ``False``. Any other value causes a :exc:`~exceptions.ValueError` to be raised. - - ``attribute`` is a unicode or byte string containing the name of the - attribute. - - Return ``True``, if the attribute value is ``'1'`` and ``False``, if - the attribute value is ``'0'``. Any other value raises a - :exc:`~exceptions.ValueError`. Raise a :exc:`~exceptions.KeyError`, - if the given attribute is not defined for this device. """ return string_to_bool(self.asstring(attribute)) + class Tags(Iterable, Container): """ A iterable over :class:`Device` tags. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/src/pyudev/version.py new/pyudev-0.18.1/src/pyudev/version.py --- old/pyudev-0.18/src/pyudev/version.py 2015-12-01 15:11:37.000000000 +0100 +++ new/pyudev-0.18.1/src/pyudev/version.py 2015-12-18 18:27:19.000000000 +0100 @@ -25,5 +25,5 @@ .. moduleauthor:: mulhern <[email protected]> """ -__version__ = '0.18' +__version__ = '0.18.1' __version_info__ = tuple(int(x) for x in __version__.split('.')) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/src/pyudev.egg-info/PKG-INFO new/pyudev-0.18.1/src/pyudev.egg-info/PKG-INFO --- old/pyudev-0.18/src/pyudev.egg-info/PKG-INFO 2015-12-01 15:21:26.000000000 +0100 +++ new/pyudev-0.18.1/src/pyudev.egg-info/PKG-INFO 2015-12-18 18:28:15.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pyudev -Version: 0.18 +Version: 0.18.1 Summary: A libudev binding Home-page: http://pyudev.readthedocs.org/ Author: Sebastian Wiesner diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/src/pyudev.egg-info/SOURCES.txt new/pyudev-0.18.1/src/pyudev.egg-info/SOURCES.txt --- old/pyudev-0.18/src/pyudev.egg-info/SOURCES.txt 2015-12-01 15:21:26.000000000 +0100 +++ new/pyudev-0.18.1/src/pyudev.egg-info/SOURCES.txt 2015-12-18 18:28:15.000000000 +0100 @@ -52,6 +52,7 @@ src/pyudev.egg-info/PKG-INFO src/pyudev.egg-info/SOURCES.txt src/pyudev.egg-info/dependency_links.txt +src/pyudev.egg-info/requires.txt src/pyudev.egg-info/top_level.txt src/pyudev/device/__init__.py src/pyudev/device/_device.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/src/pyudev.egg-info/requires.txt new/pyudev-0.18.1/src/pyudev.egg-info/requires.txt --- old/pyudev-0.18/src/pyudev.egg-info/requires.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/pyudev-0.18.1/src/pyudev.egg-info/requires.txt 2015-12-18 18:28:15.000000000 +0100 @@ -0,0 +1 @@ +six diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/tests/_device_tests/_attributes_tests.py new/pyudev-0.18.1/tests/_device_tests/_attributes_tests.py --- old/pyudev-0.18/tests/_device_tests/_attributes_tests.py 2015-12-01 15:11:37.000000000 +0100 +++ new/pyudev-0.18.1/tests/_device_tests/_attributes_tests.py 2015-12-18 18:27:19.000000000 +0100 @@ -79,7 +79,31 @@ settings=Settings(max_examples=5) ) def test_getitem_nonexisting(self, a_device): - assert a_device.attributes.get('a non-existing attribute') is None + """ + Test behavior when corresponding value is non-existant. + """ + not_key = "a non-existing attribute" + assert a_device.attributes.get(not_key) is None + with pytest.raises(KeyError): + a_device.attributes.asstring(not_key) + with pytest.raises(KeyError): + a_device.attributes.asint(not_key) + with pytest.raises(KeyError): + a_device.attributes.asbool(not_key) + + @given( + strategies.sampled_from(_DEVICES), + settings=Settings(max_examples=5) + ) + def test_non_iterable(self, a_device): + """ + Test that the attributes object can not be iterated over. + """ + # pylint: disable=pointless-statement + with pytest.raises(TypeError): + 'key' in a_device.attributes + with pytest.raises(TypeError): + a_device.attributes['key'] @given( _CONTEXT_STRATEGY, @@ -89,8 +113,7 @@ def test_asstring(self, a_context, device_datum): device = Device.from_path(a_context, device_datum.device_path) for key, value in self.non_volatile_items(device_datum.attributes): - assert is_unicode_string( - device.attributes.asstring(key)) + assert is_unicode_string(device.attributes.asstring(key)) assert device.attributes.asstring(key) == value @given( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyudev-0.18/tests/test_monitor.py new/pyudev-0.18.1/tests/test_monitor.py --- old/pyudev-0.18/tests/test_monitor.py 2015-12-01 15:11:37.000000000 +0100 +++ new/pyudev-0.18.1/tests/test_monitor.py 2015-12-18 18:27:19.000000000 +0100 @@ -313,8 +313,17 @@ def make_observer(self, monitor, use_deprecated=False): if use_deprecated: - self.observer = pytest.deprecated_call( - MonitorObserver, monitor, event_handler=self.event_handler) + if pytest.__version__ == '2.8.4': + self.observer = MonitorObserver( + monitor, + event_handler=self.event_handler + ) + else: + self.observer = pytest.deprecated_call( + MonitorObserver, + monitor, + event_handler=self.event_handler + ) else: self.observer = MonitorObserver(monitor, callback=self.callback) return self.observer
