[Python-modules-commits] [pyusb] 01/01: Import pyusb_1.0.0~rc1.orig.tar.gz

Ruben Undheim rubund-guest at moszumanska.debian.org
Sun Mar 6 10:35:10 UTC 2016


This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch upstream
in repository pyusb.

commit 844e7829e83af5abe01ddd609b8a04e66e0c5dc6
Author: Ruben Undheim <ruben.undheim at gmail.com>
Date:   Sun Mar 6 11:05:17 2016 +0100

    Import pyusb_1.0.0~rc1.orig.tar.gz
---
 ACKNOWLEDGEMENTS        |   5 +
 ChangeLog               | 481 ++++++++++++++++++++++++++++++++++++++++++++++++
 PKG-INFO                |  34 +++-
 README.rst              |  13 +-
 docs/faq.rst            |  41 +++++
 docs/tutorial.rst       |  10 +-
 setup.cfg               |   2 +
 setup.py                |  38 +++-
 usb/__init__.py         |   2 +-
 usb/_interop.py         |  71 ++-----
 usb/_objfinalizer.py    | 155 ++++++++++++++++
 usb/backend/__init__.py |   4 +-
 usb/backend/libusb0.py  | 101 +++++++++-
 usb/backend/libusb1.py  | 110 ++++++++---
 usb/backend/openusb.py  |  15 +-
 usb/core.py             | 110 ++++++++---
 usb/legacy.py           |  35 ++--
 usb/util.py             | 125 +++++++++----
 18 files changed, 1183 insertions(+), 169 deletions(-)

diff --git a/ACKNOWLEDGEMENTS b/ACKNOWLEDGEMENTS
index eda3cac..46f4579 100644
--- a/ACKNOWLEDGEMENTS
+++ b/ACKNOWLEDGEMENTS
@@ -25,3 +25,8 @@ Carl Ritson
 Romain Aviolat
 Walker Inman
 Prathmesh Prabhu
+André Erdmann
+Jeffrey Nichols
+Deliang Fan
+Matthew Chan
+Maximilian Köhl
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..182876a
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,481 @@
+Author: Wander Lairson Costa
+    Merge pull request #125 from swinman/master
+    
+    make find and find_descriptor easier to understand
+Author: Walker Inman
+    make find and find_descriptor easier to understand
+    
+    all( iter_ ) is more explicit than reduce( lambda x, y:x and y, iter_, True ),
+    especially since reduce is no longer a builtin.  Use all instead of
+    complicated multi-line reduce statement for easier code comprehension.
+    Also, introduce _all interop since all was introduced in 2.5
+
+Author: Wander Lairson Costa
+    Merge pull request #124 from roques/autoclaim
+    
+    ctrl_transfer: claim receiving interface for non-VENDOR transfers
+Author: Wander Lairson Costa
+    Merge pull request #119 from M3gaFr3ak/patch-1
+    
+    Fix OpenUSB link
+Author: Wander Lairson Costa
+    Fix braino in faq doc.
+
+Author: Christian von Roques
+    ctrl_transfer: claim receiving interface for non-VENDOR transfers
+    
+    This matches what the Linux kernel does in check_intf() when called from check_ctrlrecip()
+    https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/core/devio.c
+    and thus helps to prevent annoying warnings from the kernel.
+    
+    The previous code did this for STANDARD type transfers already, but not for CLASS.
+
+Author: wander
+    Added a new FAQ doc.
+
+Author: Leon Loeser
+    Fix OpenUSB link
+    
+    The link for OpenUSB doesn't work. It says "Page not found" on sourceforge. I replaced it with the link to the OpenUSB sourceforge wiki
+Author: Wander Lairson Costa
+    Merge pull request #107 from rabryan/master
+    
+    add virtual com port utility to tools
+Author: Richard Bryan
+    adds a virtual com port utility to tools
+
+Author: Wander Lairson Costa
+    Merge pull request #113 from AlanJAS/master
+    
+    prevent get_device_speed error on libusb1
+Author: Alan Aguiar
+    prevent get_device_speed error on libusb1
+
+Author: Wander Lairson Costa
+    Merge pull request #112 from karlp/pulls/tutorial-config-setting
+    
+    doc: tutorial fix typo in cfg setting
+Author: Karl Palsson
+    doc: tutorial fix typo in cfg setting
+    
+    Clarify the different methods of setting the configuration.
+
+Author: Wander Lairson Costa
+    Give a readable error when a invalid configuration is passed.
+    
+    closes #111.
+
+Author: Wander Lairson Costa
+    Make PyUSB thread safe.
+    
+    We synchronize every ResourceManager method and this should be enough to
+    guarantee library thread safety.
+
+Author: Wander Lairson Costa
+    Merge pull request #109 from AlanJAS/master
+    
+    fix get_device_speed for old libusb versions
+Author: Alan Aguiar
+    fix get_device_speed for old libusb versions
+
+Author: Wander Lairson Costa
+    Update docs to include pip install.
+    
+    closes #82
+    closes #92
+
+Author: Wander Lairson Costa
+    Create a specialized class for "no backend" exception.
+    
+    Now when no backend is found, the exception NoBackendError is raised,
+    allowing the application to handle it properly.
+    
+    closes #95.
+
+Author: Wander Lairson Costa
+    Merge branch 'iso-win32'
+    
+    closes #61.
+
+Author: Wander Lairson Costa
+    Add environment variable to control isochronous tests.
+    
+    Isochronous tests fail in Windows running under VirualBox, so we allow
+    them to be disabled.
+
+Author: Wander Lairson Costa
+    Implement isochronous transfers for libusb-win32.
+    
+    libusb-win32 supports asynchronous isochronous transfers. We check in
+    the libubs0 backend if the isochronous related functions are available
+    and, if so, implement the iso transfer functions.
+
+Author: Wander Lairson Costa
+    Merge pull request #104 from AndreySV/fix-setConfiguration-setAltInterface
+    
+    fix 0.x compatibility issue in functions setConfiguration() and setAltInterface()
+Author: Wander Lairson Costa
+    Merge pull request #105 from jcflack/metadata
+    
+    For discussion anyway, one attempt at some relevant trove classifiers.
+Author: Andrey Skvortsov
+    cleanup code in claimInterface()
+    
+    cleanup code to make argument handling consistent with functions
+    setConfiguration, setAltInterface and detachKernelDriver.
+
+Author: Andrey Skvortsov
+    fixes 0.x compatibility for detachKernelDriver()
+    
+    Argument interface can be interface number or an Interface object, but
+    if interface is Interface object following trace is printed:
+    
+    File "./mp709.py", line 102, in open
+      self.handle.detachKernelDriver(self.intf)
+    File "/home/andrey/tmp/pyusb/usb/legacy.py", line 309, in detachKernelDriver
+      self.dev.detach_kernel_driver(interface)
+    File "/home/andrey/tmp/pyusb/usb/core.py", line 1047, in detach_kernel_driver
+      interface)
+    File "/home/andrey/tmp/pyusb/usb/backend/libusb1.py", line 894, in detach_kernel_driver
+      _check(self.lib.libusb_detach_kernel_driver(dev_handle.handle, intf))
+    ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: wrong type
+    
+    This patch adds code that converts Interface object to interface number.
+
+Author: Andrey Skvortsov
+    fixes 0.x compatibility for setAltInterface()
+    
+    If pyusb-0.x code is used and
+    DeviceHandle.setConfiguration(self.dev.configurations[0])
+    is called, the following trace is printed:
+    
+      self.handle.setAltInterface(self.intf)
+    File "/home/andrey/tmp/pyusb/usb/legacy.py", line 267, in setAltInterface
+      self.dev.set_interface_altsetting(self.__claimed_interface, alternate)
+    File "/home/andrey/tmp/pyusb/usb/core.py", line 872, in set_interface_altsetting
+      self._ctx.managed_set_interface(self, interface, alternate_setting)
+    File "/home/andrey/tmp/pyusb/usb/core.py", line 177, in managed_set_interface
+      self.managed_claim_interface(device, i)
+    File "/home/andrey/tmp/pyusb/usb/core.py", line 147, in managed_claim_interface
+      self.backend.claim_interface(self.handle, i)
+    File "/home/andrey/tmp/pyusb/usb/backend/libusb1.py", line 803, in claim_interface
+      _check(self.lib.libusb_claim_interface(dev_handle.handle, intf))
+    ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: wrong type
+    
+    If legacy function DeviceHandle.setAltInterface(self.intf) is
+    called, function _ResourceManager.managed_set_configuration 'config'
+    parameter's type will be <class 'usb.legacy.Interface' instead of
+    'int'.
+
+Author: Andrey Skvortsov
+    fixes 0.x compatibility for setConfiguration()
+    
+    If pyusb-0.x code is used and
+    DeviceHandle.setConfiguration(self.dev.configurations[0])
+    is called, the following trace is printed:
+    
+    File "./mp709.py", line 109, in open
+      self.handle.setConfiguration(self.dev.configurations[0])
+    File "/home/andrey/tmp/pyusb/usb/legacy.py", line 259, in setConfiguration
+      self.dev.set_configuration(configuration)
+    File "/home/andrey/tmp/pyusb/usb/core.py", line 839, in set_configuration
+      self._ctx.managed_set_configuration(self, configuration)
+    File "/home/andrey/tmp/pyusb/usb/core.py", line 129, in managed_set_configuration
+      self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
+    AttributeError: 'NoneType' object has no attribute 'bConfigurationValue'
+    
+    The problem is here, that in function
+    _ResourceManager.managed_set_configuration(self, device, config)
+    'config' parameter has type 'usb.legacy.Configuration' from legacy code.
+    But the function (managed_set_configuration) expects  types 'usb.core.Configuration' or 'int'.
+    With this patch  managed_set_configuration gets 'int' configuration
+    number from legacy code and util.find_descriptor(device, bConfigurationValue=config)
+    finds and returns corresponding 'usb.core.Configuration' for further
+    handling.
+
+Author: Chapman Flack
+    First crack at some relevant setup.py classifiers.
+
+Author: Wander Lairson Costa
+    Merge pull request #99 from jcflack/strings
+    
+    Handling device strings; making device's LANGID list accessible.
+Author: Chapman Flack
+    Expose device's LANGIDs; suppress missing strings.
+    
+    When a device does not have a certain string (e.g. serial number),
+    it supplies zero as the index for that string. Zero is never the
+    index of a real string, only a signal not to request it. A request
+    for string index zero has a special meaning, to find the list of
+    languages the device strings are offered in. When code requested a
+    string without testing the index for zero, it could get back a bogus
+    string like a Cyrillic Љ character, as a result of trying to interpret
+    the language ID codes as Unicode characters.
+    
+    Now get_string simply returns None if passed an index of zero.
+    
+    At the same time, there was no simple way for calling code to examine
+    the supported language IDs for the device. The spec forbids sending
+    string requests for a language the device does not support, so the
+    supported IDs should be easy for the caller to check. Now there is
+    a langids property on Device.
+    
+    If a device has no strings, the spec also allows it to have no langids
+    list. The device might reply with an empty list, or fail the request
+    with a backend pipe error. The latter is caught in the property accessor
+    on core.Device, rather than in util.get_langids, because of an order
+    constraint between when core imports util and when it defined USBError.
+    
+    The string property accessors on Device normally call get_string once
+    and cache the result, but if the index is zero (so the result is None)
+    they will end up calling get_string every time ... but all it does in
+    that case is if 0 == index: return None so the cost is negligible and
+    the code stays simple.
+
+Author: Wander Lairson Costa
+    Merge pull request #98 from jcflack/housekeeping
+    
+    Conform _interop to the README goal to support 2.4+.
+Author: Chapman Flack
+    Conform _interop to README's goal to support 2.4+.
+    
+    README.rst was saying 2.4+ should be supported but some vestiges from 2.3
+    were in _interop.py.
+    
+    Wherever used (which was only in legacy.py), _sorted and _groupby are
+    now replaced by their native counterparts.
+    
+    http://sourceforge.net/p/pyusb/mailman/message/34078264/
+    Two commits formerly pushed to github, rebased at upstream's request.
+
+Author: Wander Lairson Costa
+    Merge pull request #97 from jcflack/solaris
+    
+    Support the libusb0 that ships in Solaris
+Author: Chapman Flack
+    Add a hardcoded PATH_MAX for Solaris.
+    
+    The preceding commit would make it work in most cases, but perhaps it
+    is best not to rely on pathconf when the value from limits.h is known.
+    In theory, pathconf could return a different value depending on the
+    filesystem where . is, but the fixed value in limits.h will be what
+    libusb was compiled with.
+
+Author: Chapman Flack
+    Avoid hardcoding the index for _PC_PATH_MAX.
+    
+    POSIX explicitly leaves the values of these named constants unspecified.
+    The value 4 is right for linux but wrong for solaris. Who knows what it is
+    in another OS. The result of having the wrong index is the wrong value
+    gets queried, making the ctypes structures the wrong sizes and causing
+    pyusb to fail in perplexing ways.
+    
+    It's better to use the name ('PC_PATH_MAX') and allow Python to use the
+    correct index for the platform.
+
+Author: Wander Lairson Costa
+    Merge pull request #96 from MattHeard/patch-1
+    
+    Fixed minor docstring typo.
+Author: Matt
+    Fixed minor docstring typo
+Author: Wander Lairson Costa
+    Merge pull request #93 from damib/master
+    
+    Claim interface only for standard control transfer requests.
+Author: Damiano Bortolato
+    Claim interface only for standard control transfer requests.
+    
+    wIndex is the interface number to be claimed only for
+    standard request types. For example Silicon Labs cp2103 defines
+    a vendor control transfer to set some GPIO pins though wIndex
+    parameter (se AN571 page 17).
+
+Author: Wander Lairson Costa
+    Add script to setup python test environment.
+
+Author: Wander Lairson Costa
+    Thanks to Maximilian Köhl and Matthew Chan.
+    
+    Maximilian Köhl.: PR #90
+    Matthew Chan: PR #91
+
+Author: Wander Lairson Costa
+    Merge pull request #91 from tuzzer/master
+    
+    util: change tostring() to tobytes() when running with Python 3.2+
+Author: tuzzer
+    util: change tostring() to tobytes() when running with Python 3.2+
+    
+    This removes the DeprecationWarning that warns that tostring() is
+    obsolete when running with Python 3.2+
+
+Author: Wander Lairson Costa
+    Merge pull request #90 from koehlma/master
+    
+    libusb1: fix seg fault when get_device_speed is called
+Author: Maximilian Köhl
+    libusb1: fix seg fault when get_device_speed is called
+
+Author: Wander Lairson Costa
+    core: Fix seg fault when dispose is called after device disconnection.
+    
+    When dispose is called after the device is diconnected,
+    release_interface might fail (see commit 5e9ef1536), then the interface
+    stays in the claimed interfaces set. When the device is destroyed, its
+    __del__ method will call dispose again and, since the interface is
+    still marked as claimed, a new call to release_interface will be made
+    with an invalid device handle, causing a segmentation fault.
+    
+    We fix that by always removing the interface from the claimed set.
+    
+    closes #89.
+
+Author: Wander Lairson Costa
+    Fixed: Add speed property to all backends.
+
+Author: Wander Lairson Costa
+    Thanks to Deliang Fan for PR #88.
+
+Author: Wander Lairson Costa
+    Merge pull request #88 from DeliangFan/speed
+    
+    Support for getting usb device speed
+Author: fandeliang
+    Support for getting usb device speed
+    
+    In some cases, we need to get the usb device speed type to attach
+    it to specific usb controller. Fortunately, it's easy to get usb
+    device speed information with libusb1.0.
+
+Author: Wander Lairson Costa
+    core: Handle exceptions when releasing the interfaces.
+    
+    At object destruction, claimed interfaces are released. If the device
+    is disconnected, the call to release_interface may fail and raise an
+    exception.
+    
+    closes #84.
+
+Author: Wander Lairson Costa
+    libusb1: fix hanging when the device is disconnected in a iso transfer.
+    
+    If the device is disconnected when a isochronous transfer is ongoing,
+    it might raise an exception in the callback and the 'callback done'
+    signaling flag is never set. This causes the program to hang
+    forever.
+    
+    We move the error handling to the caller function, after the callback
+    returns. In this way, the exception is raised in the main thread and
+    client software is notified about the exceptional situation.
+    
+    closes #85.
+
+Author: Wander Lairson Costa
+    Braino.
+
+Author: Wander Lairson Costa
+    Use libusb_strerror when the function is available.
+    
+    libusb_strerror returns a string containing the error message for the
+    given error code. When the function is not available, we fallback to
+    our own internal error code mapping strategy.
+    
+    closes #69.
+
+Author: Wander Lairson Costa
+    Implement "backend" property.
+    
+    The "backend" property returns the backend used by the device.
+    
+    closes #71.
+
+Author: Wander Lairson Costa
+    Merge pull request #80 from 'ecejeff/master'.
+    
+    closes #80.
+
+Author: Wander Lairson Costa
+    Thanks Jeffrey Nichols for the port numbers patch.
+
+Author: Jeffrey Nichols
+    Support for port_numbers hierarchy tuple with libusb1.
+
+Author: Wander Lairson Costa
+    Merge pull request #78 from 'dywisor/master'.
+    
+    closes #66 closes #78.
+
+Author: Wander Lairson Costa
+    Thanks to André Erdmann for #66 fix.
+
+Author: André Erdmann
+    finalize objects before exiting
+    
+    Fixes #66 ("Exception when script using pyusb finishes").
+    
+    See previous commit for details.
+
+Author: André Erdmann
+    add object finalizer class
+    
+    Starting with (C)Python 3.4, the GC features "Safe object finalization" [0],
+    which doesn't work nicely with pyusb's object structure.
+    
+    Required globals / modules may already have been deleted (set to None)
+    when an object's __del__() method gets called [1], which
+    randomly breaks libusb calls etc. when calling sys.exit().
+    
+    Use the atexit module to solve this (indirectly via weakref.finalize()).
+    
+    This commit adds a class that takes care of object finalization.
+    Classes/objects can adopt this functionality by inheriting
+    AutoFinalizedObject and renaming their __del__() method to _finalize_object().
+    
+    Shouldn't break existing use cases, but adds a few layers of indirection.
+    A __del__() call gets processed as follows:
+    
+      __del__() -> finalize() -> [...]
+        -> _do_finalize_object() ->  _finalize_object()
+    
+    All methods in this call chain are provided by AutoFinalizedObject,
+    derived classes should override the no-op _finalize_object() method.
+    
+    The "[...]" part depends on the python version:
+    * <  3.4: <nothing>
+    * >= 3.4: _finalizer() -> _do_finalize_object_ref()
+
+Author: Wander Lairson Costa
+    Merge pull request #75 from jrtomps/docfix
+    
+    Fixes typo in find_class example.
+Author: Jeromy Tompkins
+    Fixes typo in find_class example
+
+Author: Wander Lairson Costa
+    Revert "Use libusb_strerror to translate erro codes to strings."
+    
+    This reverts commit 592e893a01fc4517dd27018dd71c8520c521135c.
+    
+    It causes regressions on systems using old versions of libusb that
+    don't implement libusb_strerror.
+    
+    closes #57 closes #68.
+    
+    Conflicts:
+    	usb/backend/libusb1.py
+
+Author: Wander Lairson Costa
+    Cleanup resources when device handle is deleted. closes #65.
+    
+    Legacy module has no explicity resource cleanup functions, so we free
+    allocated resources in the __del__ method.
+
+Author: Wander Lairson Costa
+    Trace unit tests.
+    
+    Tracing unit tests functions calls makes easier to track what's going
+    on when regression tests fail.
+
+Author: Wander Lairson Costa
+    Update version to release candidate 1.
diff --git a/PKG-INFO b/PKG-INFO
index 1be0f70..b36aca5 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
-Metadata-Version: 1.0
+Metadata-Version: 1.1
 Name: pyusb
-Version: 1.0.0b2
+Version: 1.0.0rc1
 Summary: Python USB access module
 Home-page: http://pyusb.sourceforge.net
 Author: Wander Lairson Costa
@@ -13,3 +13,33 @@ Description:
         (currently, libusb 0.1.x, libusb 1.x, and OpenUSB).
         
 Platform: UNKNOWN
+Classifier: Development Status :: 4 - Beta
+Classifier: Intended Audience :: Developers
+Classifier: Intended Audience :: Information Technology
+Classifier: Intended Audience :: Manufacturing
+Classifier: Intended Audience :: Science/Research
+Classifier: Intended Audience :: System Administrators
+Classifier: Intended Audience :: Telecommunications Industry
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Natural Language :: English
+Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Microsoft :: Windows :: Windows Vista
+Classifier: Operating System :: Microsoft :: Windows :: Windows 7
+Classifier: Operating System :: POSIX :: BSD :: FreeBSD
+Classifier: Operating System :: POSIX :: BSD :: NetBSD
+Classifier: Operating System :: POSIX :: BSD :: OpenBSD
+Classifier: Operating System :: POSIX :: Linux
+Classifier: Operating System :: POSIX :: SunOS/Solaris
+Classifier: Programming Language :: Python :: 2.4
+Classifier: Programming Language :: Python :: 2.5
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: IronPython
+Classifier: Programming Language :: Python :: Implementation :: Jython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
+Classifier: Topic :: Software Development :: Libraries
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Topic :: System :: Hardware :: Hardware Drivers
diff --git a/README.rst b/README.rst
index 26a6315..6e2ba5a 100644
--- a/README.rst
+++ b/README.rst
@@ -56,6 +56,14 @@ with the command::
 
 Run it as root from within the same directory as this README file.
 
+You can also use `pip <https://docs.python.org/3/installing/>`_ to
+install PyUSB::
+
+    $ sudo pip install pyusb --pre
+
+Just bear in mind that you still follow to procedure to install the
+libusb library.
+
 Installing PyUSB on Windows
 ===========================
 
@@ -69,8 +77,9 @@ the Python install directory to your PATH environment variable or
 give the complete path to the Python interpreter.
 
 Remember that you need libusb (1.0 or 0.1) or OpenUSB running on your
-system. For Windows users, libusb 1.0 is still experimental, so it is
-recommended libusb-win32 package. Check the libusb website for updates
+system. For Windows users, libusb 0.1 is provided through
+`libusb-win32 <http://libubs-win32.sourceforge.net>`_
+package. Check the libusb website for updates
 (http://www.libusb.org).
 
 Reporting bugs/Submitting patches
diff --git a/docs/faq.rst b/docs/faq.rst
new file mode 100644
index 0000000..9dbff30
--- /dev/null
+++ b/docs/faq.rst
@@ -0,0 +1,41 @@
+FAQ
+===
+
+How do I fix "No backend available" errors?
+-------------------------------------------
+
+Generally, there are four possible causes for this problem:
+
+1. You didn't install libusb library.
+2. Your libusb library isn't in the standard shared library paths.
+3. Your libusb version is too old.
+4. Your PyUSB version is too old.
+
+To debug what's wrong, run the following script in your environment::
+
+    import os
+    os.environ['PYUSB_DEBUG'] = 'debug'
+    import usb.core
+    usb.core.find()
+
+This will print debug messages to the console. If you still have problems
+to figure out what's going on, please ask for help in the mailing list,
+providing the debug output.
+
+How do I enforce a backend?
+---------------------------
+
+Here is an example for the *libusb1* backend::
+
+    >>> import usb.core
+    >>> from usb.backend import libusb1
+    >>> be = libusb1.get_backend()
+    >>> dev = usb.core.find(backend=be)
+
+How can I pass the libusb library path to the backend?
+------------------------------------------------------
+
+Check the *Specify libraries by hand* section in the tutorial_.
+
+.. _tutorial: https://github.com/walac/pyusb/docs/tutorial.rst
+
diff --git a/docs/tutorial.rst b/docs/tutorial.rst
index 1d6be1d..47e298e 100644
--- a/docs/tutorial.rst
+++ b/docs/tutorial.rst
@@ -205,7 +205,7 @@ First, let's give a look on the final code to find all printers connected::
 
             return False
 
-    printers = usb.core.find(find_all=1, custom_match=find_all(7))
+    printers = usb.core.find(find_all=1, custom_match=find_class(7))
 
 The ``custom_match`` parameter accepts any callable object that receives the
 device object. It must return true for a matching device, and false for a
@@ -325,9 +325,13 @@ descriptor with its `bConfigurationValue` field equals to 5 [#]_, the following
 calls below will work equally::
 
     >>> dev.set_configuration(5)
+    # or
     >>> dev.set_configuration() # we assume the configuration 5 is the first one
-    >>> cfg = util.find_descriptor(dev, bConfiguration=5)
+    # or
+    >>> cfg = util.find_descriptor(dev, bConfigurationValue=5)
     >>> cfg.set()
+    # or
+    >>> cfg = util.find_descriptor(dev, bConfigurationValue=5)
     >>> dev.set_configuration(cfg)
 
 Wow! You can use a ``Configuration`` object as a parameter to
@@ -589,7 +593,7 @@ Subscribe instructions can be found at the PyUSB_ website.
        no choice.
 
 .. _libusb: http://www.libusb.org
-.. _OpenUSB: http://openusb.wiki.sourceforge.net
+.. _OpenUSB: http://sourceforge.net/p/openusb/wiki/Home/
 .. _USB: http://www.usb.org
 .. _PyUSB: http://pyusb.wiki.sourceforge.net
 .. _Python: http://www.python.org
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..5aef279
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[metadata]
+description-file = README.rst
diff --git a/setup.py b/setup.py
index 1ac5b8c..f2c8b8d 100755
--- a/setup.py
+++ b/setup.py
@@ -48,6 +48,42 @@ PyUSB offers easy USB devices communication in Python.
 It should work without additional code in any environment with
 Python >= 2.4, ctypes and an pre-built usb backend library
 (currently, libusb 0.1.x, libusb 1.x, and OpenUSB).
-"""
+""",
+    classifiers=[
+        'Development Status :: 4 - Beta',
+        'Intended Audience :: Developers',
+        'Intended Audience :: Information Technology',
+        'Intended Audience :: Manufacturing', # USB automation, or mfg USB devs
+        'Intended Audience :: Science/Research', # interface with instruments
+        'Intended Audience :: System Administrators', # integrate strange devs
+        'Intended Audience :: Telecommunications Industry', # telecomm devs
+        'License :: OSI Approved :: BSD License',
+        'Natural Language :: English',
+        # try to union the OSes that can build any of the backend libraries...
+        'Operating System :: MacOS :: MacOS X',
+        'Operating System :: Microsoft :: Windows :: Windows Vista',
+        'Operating System :: Microsoft :: Windows :: Windows 7',
+        'Operating System :: POSIX :: BSD :: FreeBSD',
+        'Operating System :: POSIX :: BSD :: NetBSD',
+        'Operating System :: POSIX :: BSD :: OpenBSD',
+        'Operating System :: POSIX :: Linux',
+        'Operating System :: POSIX :: SunOS/Solaris',
+        'Programming Language :: Python :: 2.4',
+        'Programming Language :: Python :: 2.5',
+        'Programming Language :: Python :: 2.6',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3',
+        # source(CPython,Jython,IronPython,PyPy): "The Long Term" section of
+        # http://ojs.pythonpapers.org/index.php/tpp/article/viewFile/23/23
+        'Programming Language :: Python :: Implementation :: CPython',
+        'Programming Language :: Python :: Implementation :: IronPython',
+        'Programming Language :: Python :: Implementation :: Jython',
+        'Programming Language :: Python :: Implementation :: PyPy',
+        'Topic :: Scientific/Engineering :' \
+            ': Interface Engine/Protocol Translator',
+        'Topic :: Software Development :: Libraries',
+        'Topic :: Software Development :: Libraries :: Python Modules',
+        'Topic :: System :: Hardware :: Hardware Drivers'
+    ]
 )
 
diff --git a/usb/__init__.py b/usb/__init__.py
index 85f09ef..432a507 100644
--- a/usb/__init__.py
+++ b/usb/__init__.py
@@ -46,7 +46,7 @@ import os
 __author__ = 'Wander Lairson Costa'
 
 # Use Semantic Versioning, http://semver.org/
-version_info = (1, 0, 0, 'b2')
+version_info = (1, 0, 0, 'rc1')
 __version__ = '%d.%d.%d%s' % version_info
 
 __all__ = ['legacy', 'control', 'core', 'backend', 'util', 'libloader']
diff --git a/usb/_interop.py b/usb/_interop.py
index 6287bac..cf7d80c 100644
--- a/usb/_interop.py
+++ b/usb/_interop.py
@@ -34,10 +34,10 @@
 import sys
 import array
 
-__all__ = ['_reduce', '_set', '_next', '_groupby', '_sorted', '_update_wrapper']
+__all__ = ['_reduce', '_set', '_next', '_update_wrapper']
 
-# we support Python >= 2.3
-assert sys.hexversion >= 0x020300f0
+# we support Python >= 2.4
+assert sys.hexversion >= 0x020400f0
 
 # On Python 3, reduce became a functools module function
 try:
@@ -46,6 +46,12 @@ try:
 except (ImportError, AttributeError):
     _reduce = reduce
 
+# all, introduced in Python 2.5
+try:
+    _all = all
+except NameError:
+    _all = lambda iter_ : _reduce( lambda x, y: x and y, iter_, True )
+
 # we only have the builtin set type since 2.5 version
 try:
     _set = set
@@ -61,58 +67,7 @@ def _next(iter):
     except NameError:
         return iter.next()
 
-# groupby is available only since 2.4 version
-try:
-    import itertools
-    _groupby = itertools.groupby
-except (ImportError, AttributeError):
-    # stolen from Python docs
-    class _groupby(object):
-        # [k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D A B
-        # [list(g) for k, g in groupby('AAAABBBCCD')] --> AAAA BBB CC D
-        def __init__(self, iterable, key=None):
-            if key is None:
-                key = lambda x: x
-            self.keyfunc = key
-            self.it = iter(iterable)
-            self.tgtkey = self.currkey = self.currvalue = object()
-        def __iter__(self):
-            return self
-        def next(self):
-            while self.currkey == self.tgtkey:
-                self.currvalue = _next(self.it)    # Exit on StopIteration
-                self.currkey = self.keyfunc(self.currvalue)
-            self.tgtkey = self.currkey
-            return (self.currkey, self._grouper(self.tgtkey))
-        def _grouper(self, tgtkey):
-            while self.currkey == tgtkey:
-                yield self.currvalue
-                self.currvalue = _next(self.it)    # Exit on StopIteration
-                self.currkey = self.keyfunc(self.currvalue)
-
-# builtin sorted function is only availale since 2.4 version
-try:
-    _sorted = sorted
-except NameError:
-    def _sorted(l, key=None, reverse=False):
-        # sort function on Python 2.3 does not
-        # support 'key' parameter
-        class KeyToCmp(object):
-            def __init__(self, K):
-                self.key = K
-            def __call__(self, x, y):
-                kx = self.key(x)
-                ky = self.key(y)
-                if kx < ky:
-                    return reverse and 1 or -1
-                elif kx > ky:
-                    return reverse and -1 or 1
-                else:
-                    return 0
-        tmp = list(l)
-        tmp.sort(KeyToCmp(key))
-        return tmp
-
+# functools appeared in 2.5
 try:
     import functools
     _update_wrapper = functools.update_wrapper
@@ -123,6 +78,9 @@ except (ImportError, AttributeError):
         wrapper.__doc__ = wrapped.__doc__
         wrapper.__dict__ = wrapped.__dict__
 
+# this is used (as of May 2015) twice in core, once in backend/openusb, and in
+# some unit test code. It would probably be clearer if written in terms of some
+# definite 3.2+ API (bytearrays?) with a fallback provided for 2.4+.
 def as_array(data=None):
     if data is None:
         return array.array('B')
@@ -136,6 +94,5 @@ def as_array(data=None):
         # When you pass a unicode string or a character sequence,
         # you get a TypeError if the first parameter does not match
         a = array.array('B')
-        a.fromstring(data)
+        a.fromstring(data) # deprecated since 3.2
         return a
-
diff --git a/usb/_objfinalizer.py b/usb/_objfinalizer.py
new file mode 100644
index 0000000..de88769
--- /dev/null
+++ b/usb/_objfinalizer.py
@@ -0,0 +1,155 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2014 André Erdmann
+#
+# The following terms apply to all files associated
+# with the software unless explicitly disclaimed in individual files.
+#
+# The authors hereby grant permission to use, copy, modify, distribute,
+# and license this software and its documentation for any purpose, provided
+# that existing copyright notices are retained in all copies and that this
+# notice is included verbatim in any distributions. No written agreement,
+# license, or royalty fee is required for any of the authorized uses.
+# Modifications to this software may be copyrighted by their authors
+# and need not follow the licensing terms described here, provided that
+# the new terms are clearly indicated on the first page of each file where
+# they apply.
+#
+# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
+# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
+# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
+# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
+# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+# MODIFICATIONS.
+
+import sys
+
+__all__ = ['AutoFinalizedObject']
+
+
+class _AutoFinalizedObjectBase(object):
+    """
+    Base class for objects that get automatically
+    finalized on delete or at exit.
+    """
+
+    def _finalize_object(self):
+        """Actually finalizes the object (frees allocated resources etc.).
+
+        Returns: None
+
+        Derived classes should implement this.
+        """
+        pass
+
+    def __new__(cls, *args, **kwargs):
+        """Creates a new object instance and adds the private finalizer
+        attributes to it.
+
+        Returns: new object instance
+
+        Arguments:
+        * *args, **kwargs -- ignored
+        """
+        instance = super(_AutoFinalizedObjectBase, cls).__new__(cls)
+        instance._finalize_called = False
+        return instance
+
+    def _do_finalize_object(self):
+        """Helper method that finalizes the object if not already done.
+
+        Returns: None
+        """
+        if not self._finalize_called: # race-free?
+            self._finalize_called = True
+            self._finalize_object()
+
+    def finalize(self):
+        """Finalizes the object if not already done.
+
+        Returns: None
+        """
+        # this is the "public" finalize method
+        raise NotImplementedError(
+            "finalize() must be implemented by AutoFinalizedObject."
+        )
+
+    def __del__(self):
+        self.finalize()
+
+
+if sys.hexversion >= 0x3040000:
+    # python >= 3.4: use weakref.finalize
+    import weakref
+
+    def _do_finalize_object_ref(obj_ref):
+        """Helper function for weakref.finalize() that dereferences a weakref
+        to an object and calls its _do_finalize_object() method if the object
+        is still alive. Does nothing otherwise.
+
+        Returns: None (implicit)
+
+        Arguments:
+        * obj_ref -- weakref to an object
+        """
+        obj = obj_ref()
+        if obj is not None:
+            # else object disappeared
+            obj._do_finalize_object()
+
+
+    class AutoFinalizedObject(_AutoFinalizedObjectBase):
+
+        def __new__(cls, *args, **kwargs):
+            """Creates a new object instance and adds the private finalizer
+            attributes to it.
+
+            Returns: new object instance
+
+            Arguments:
+            * *args, **kwargs -- passed to the parent instance creator
+                                 (which ignores them)
+            """
+            # Note:   Do not pass a (hard) reference to instance to the
+            #         finalizer as func/args/kwargs, it'd keep the object
+            #         alive until the program terminates.
+            #         A weak reference is fine.
+            #
+            # Note 2: When using weakrefs and not calling finalize() in
+            #         __del__, the object may already have disappeared
+            #         when weakref.finalize() kicks in.
+            #         Make sure that _finalizer() gets called,
+            #         i.e. keep __del__() from the base class.
... 1077 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pyusb.git



More information about the Python-modules-commits mailing list