From: W. Trevor King Date: Thu, 15 Mar 2012 17:40:18 +0000 (-0400) Subject: Make base.load_device public (so that external modules can use it). X-Git-Tag: 0.7~19 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3aa15d051967e138052b94db581a10e9f0d34d21;p=pypiezo.git Make base.load_device public (so that external modules can use it). --- diff --git a/pypiezo/base.py b/pypiezo/base.py index c3d5ec1..2e59e60 100644 --- a/pypiezo/base.py +++ b/pypiezo/base.py @@ -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)