diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-08-02 23:47:04 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-08-02 23:47:04 +0000 |
commit | c5d8b5cc3ad36f495dbd2dc0b6fdc054bb19ef3c (patch) | |
tree | c071a49b17e4b10e6990fa0f6bb08e4784baf3a4 /serial/__init__.py | |
parent | ee5852753d8f3974585b987a5403f299dcb417b6 (diff) | |
download | pyserial-c5d8b5cc3ad36f495dbd2dc0b6fdc054bb19ef3c.tar.gz |
fix issue with unwanted keyword parameter
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@276 f19166aa-fa4f-0410-85c2-fa1106f25c8a
Diffstat (limited to 'serial/__init__.py')
-rw-r--r-- | serial/__init__.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/serial/__init__.py b/serial/__init__.py index 8e47180..0ffe95d 100644 --- a/serial/__init__.py +++ b/serial/__init__.py @@ -25,16 +25,22 @@ else: raise Exception("Sorry: no implementation for your platform ('%s') available" % os.name) -def serial_class_for_url(url, do_not_open=False, *args, **kwargs): +def serial_class_for_url(url, *args, **kwargs): """Get a native or a RFC2217 implementation of the Serial class, depending - on port/url. The port is not opened when do_not_open is true, by default it is.""" + on port/url. The port is not opened when the keyword parameter + 'do_not_open' is true, by default it is.""" + # check remove extra parameter to not confuse the Serial class + do_open = 'do_not_open' not in kwargs or not kwargs['do_not_open'] + if 'do_not_open' in kwargs: del kwargs['do_not_open'] + # check port type and get class if url.lower().startswith('rfc2217://'): import rfc2217 # late import, so that users that don't use it don't have to load it klass = rfc2217.Serial # RFC2217 implementation else: klass = Serial # 'native' implementation + # instantiate and open when desired instance = klass(None, *args, **kwargs) instance.port = url - if not do_not_open: + if do_open: instance.open() return instance |