| | #!/usr/bin/env python |
---|
| | # xlslu.py - Match Strings In XLS Spreadsheets |
---|
| | # xlslu.py - Simple Excel Spreadsheet String Search |
---|
| | # Embed the source control ID string for use by program |
---|
| | |
---|
| | CVSID='$Id: xlslu.py,v 1.201 $' |
---|
| | # Copyright (c) 2013-2020 TundraWare Inc. |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| | # Program Information |
---|
| | ##### |
---|
| | |
---|
| | PROGNAME = "xlslu.py" |
---|
| | PROGENV = "xlslu".upper() |
---|
| | VERSION = CVSID.split()[2] |
---|
| | VERSION = "1.201" |
---|
| | PROGVER = PROGNAME + " " + VERSION + " - Match Strings In XLS Spreadsheets" |
---|
| | |
---|
| | |
---|
| | ##### |
---|
| |
---|
| | "usage: " + PROGNAME + " [-%s]" % optionslist + " file.xls string string string ...", |
---|
| | " where,", |
---|
| | " -a require all strings to be present (AND matching)", |
---|
| | " -h print this help information", |
---|
| | " -v print detailed version information", |
---|
| | " -v print version information", |
---|
| | " file.xls name of spreadsheet file to read", |
---|
| | " string ... list of strings that will trigger a match", |
---|
| | ] |
---|
| | |
---|
| |
---|
| | |
---|
| | # Command line processing - Process any options set in the |
---|
| | # environment first, and then those given on the command line |
---|
| | |
---|
| | OPTIONS = sys.argv[1:] |
---|
| | # They at least have to provide a filename |
---|
| | # Does not catch the case where they provide an option but no filename |
---|
| | |
---|
| | if len(sys.argv) < 2: |
---|
| | Usage() |
---|
| | sys.exit(1) |
---|
| | |
---|
| | else: |
---|
| | OPTIONS = sys.argv[1:] |
---|
| | |
---|
| | envopt = os.getenv(PROGENV) |
---|
| | if envopt: |
---|
| | OPTIONS = envopt.split() + OPTIONS |
---|
| | |
---|
| |
---|
| | |
---|
| | except getopt.GetoptError as cli_errors: |
---|
| | |
---|
| | (errmsg, badarg) = cli_errors.args |
---|
| | |
---|
| | ErrorMsg(eBADARG % errmsg) |
---|
| | sys.exit(1) |
---|
| | |
---|
| | for opt, val in opts: |
---|
| |
---|
| | Usage() |
---|
| | sys.exit(0) |
---|
| | |
---|
| | if opt == "-v": |
---|
| | PrintStdout(CVSID) |
---|
| | PrintStdout(PROGVER) |
---|
| | sys.exit(0) |
---|
| | |
---|
| | SPREADSHEET = args[0] |
---|
| | MATCHSTRINGS = args[1:] |
---|
| |
---|
| | |