From: Cameron Patrick Date: Sun, 1 Aug 2004 05:39:59 +0000 (+0000) Subject: move argument parsing out into a separate function X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=afdb3b71c8da860389ba075d22a3b55f05b57e01;p=zanchey%2Fdispense2.git move argument parsing out into a separate function --- diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index dd9739d..de763f2 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -379,8 +379,7 @@ def connect_to_vend(options, DBServer, DBName, DBUser, DBPassword, ServiceName, return rfh, wfh -if __name__ == '__main__': - import ConfigParser +def parse_args(): from optparse import OptionParser op = OptionParser(usage="%prog [OPTION]...") @@ -393,6 +392,13 @@ if __name__ == '__main__': if len(args) != 0: op.error('extra command line arguments: ' + ' '.join(args)) + return options + +if __name__ == '__main__': + import ConfigParser + + options = parse_args() + try: cp = ConfigParser.ConfigParser() cp.read(options.config_file)