diff options
Diffstat (limited to 'serial/tools/list_ports.py')
-rw-r--r-- | serial/tools/list_ports.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/serial/tools/list_ports.py b/serial/tools/list_ports.py index c5896c5..3b32b92 100644 --- a/serial/tools/list_ports.py +++ b/serial/tools/list_ports.py @@ -17,23 +17,24 @@ Additionally a grep function is supplied that can be used to search for ports based on their descriptions or hardware ID. """ -import sys, os, re +import sys +import os +import re # chose an implementation, depending on os #~ if sys.platform == 'cli': #~ else: -import os -# chose an implementation, depending on os -if os.name == 'nt': #sys.platform == 'win32': - from serial.tools.list_ports_windows import * +if os.name == 'nt': # sys.platform == 'win32': + from serial.tools.list_ports_windows import comports elif os.name == 'posix': - from serial.tools.list_ports_posix import * + from serial.tools.list_ports_posix import comports #~ elif os.name == 'java': else: raise ImportError("Sorry: no implementation for your platform ('%s') available" % (os.name,)) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + def grep(regexp): """\ Search for ports using a regular expression. Port name, description and @@ -52,21 +53,23 @@ def main(): parser = argparse.ArgumentParser(description='Serial port enumeration') - parser.add_argument('regexp', + parser.add_argument( + 'regexp', nargs='?', help='only show ports that match this regex') - parser.add_argument('-v', '--verbose', + parser.add_argument( + '-v', '--verbose', action='store_true', help='show more messages') - parser.add_argument('-q', '--quiet', + parser.add_argument( + '-q', '--quiet', action='store_true', help='suppress all messages') args = parser.parse_args() - hits = 0 # get iteraror w/ or w/o filter if args.regexp: |