move argument parsing out into a separate function
authorCameron Patrick <[email protected]>
Sun, 1 Aug 2004 05:39:59 +0000 (05:39 +0000)
committerCameron Patrick <[email protected]>
Sun, 1 Aug 2004 05:39:59 +0000 (05:39 +0000)
sql-edition/servers/VendServer.py

index dd9739d..de763f2 100755 (executable)
@@ -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)

UCC git Repository :: git.ucc.asn.au