Make base.load_device public (so that external modules can use it).
authorW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 17:40:18 +0000 (13:40 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 15 Mar 2012 17:40:18 +0000 (13:40 -0400)
pypiezo/base.py

index c3d5ec17941417ae20fbceb4efca347e4b7964f5..2e59e60f46bec1e5ea95964a4336d9a0d638e12c 100644 (file)
@@ -201,7 +201,7 @@ def get_axis_name(axis_config):
     channel_config = axis_config['channel']
     return channel_config['name']
 
-def _load_device(filename, devices):
+def load_device(filename, devices):
     """Return an open device from `devices` which has a given `filename`.
 
     Sometimes a caller will already have the required `Device`, in
@@ -220,7 +220,7 @@ def _load_device(filename, devices):
     >>> from pycomedi.device import Device
 
     >>> devices = [Device('/dev/comedi0')]
-    >>> device = _load_device(filename='/dev/comedi0', devices=devices)
+    >>> device = load_device(filename='/dev/comedi0', devices=devices)
     >>> device.filename
     '/dev/comedi0'
     >>> device.file is not None
@@ -228,7 +228,7 @@ def _load_device(filename, devices):
     >>> device.close()
 
     >>> devices = []
-    >>> device = _load_device(filename='/dev/comedi0', devices=devices)
+    >>> device = load_device(filename='/dev/comedi0', devices=devices)
     >>> devices == [device]
     True
     >>> device.filename
@@ -239,15 +239,15 @@ def _load_device(filename, devices):
 
     We try and return helpful errors when things go wrong:
 
-    >>> device = _load_device(filename='/dev/comedi0', devices=None)
+    >>> device = load_device(filename='/dev/comedi0', devices=None)
     Traceback (most recent call last):
       ...
     TypeError: 'NoneType' object is not iterable
-    >>> device = _load_device(filename='/dev/comedi0', devices=tuple())
+    >>> device = load_device(filename='/dev/comedi0', devices=tuple())
     Traceback (most recent call last):
       ...
     ValueError: none of the available devices ([]) match /dev/comedi0, and we cannot append to ()
-    >>> device = _load_device(filename='/dev/comediX', devices=[])
+    >>> device = load_device(filename='/dev/comediX', devices=[])
     Traceback (most recent call last):
       ...
     PyComediError: comedi_open (/dev/comediX): No such file or directory (None)
@@ -277,7 +277,7 @@ def _load_device(filename, devices):
 def _load_channel_from_config(channel, devices, subdevice_type):
     c = channel.config  # reduce verbosity
     if not channel.channel:
-        device = _load_device(filename=c['device'], devices=devices)
+        device = load_device(filename=c['device'], devices=devices)
         if c['subdevice'] < 0:
             subdevice = device.find_subdevice_by_type(
                 subdevice_type, factory=StreamingSubdevice)