opdate from optparse to argparse PYADAPT-61

update_parser
David 3 years ago
parent dcbbbca020
commit 566d0a2162

@ -221,40 +221,38 @@ def run(name, color=None, imap=False, own_ident=1, leave=False):
if __name__=="__main__":
from optparse import OptionParser
import argparse
optParser = OptionParser()
optParser.description = __doc__
argparser = argparse.ArgumentParser(description= __doc__)
optParser.add_option("-e", "--exec-for", action="store", type="string",
dest="exec_for", help="execute for name of simulated device " +
"(default: name of actual directory)")
optParser.add_option("--color", action="store", type="string",
argparser.add_argument("-e", "--exec-for", action="store", type=str,
dest="exec_for",
help="execute for name of simulated device (default: name of actual directory)")
argparser.add_argument("--color", action="store", type=str,
dest="color", help="print debug output in this color", default=None)
optParser.add_option("--reject", action="store_true", dest="reject",
argparser.add_argument("--reject", action="store_true", dest="reject",
help="reject device group")
optParser.add_option("--accept", action="store_false", dest="reject",
argparser.add_argument("--accept", action="store_false", dest="reject",
help="accept device group (default)")
optParser.add_option("--no-answer", action="store_true", dest="noanswer",
argparser.add_argument("--no-answer", action="store_true", dest="noanswer",
help="do not answer device group handshake")
optParser.add_option("-E", "--end-on", dest="notifications",
argparser.add_argument("-E", "--end-on", dest="notifications",
help="end test on these notifications")
optParser.add_option("-j", "--multi-threaded", action="store_true",
argparser.add_argument("-j", "--multi-threaded", action="store_true",
dest="multithreaded",
help="use multithreaded instead of single threaded implementation")
optParser.add_option("-n", "--noend", action="store_true",
argparser.add_argument("-n", "--noend", action="store_true",
dest="noend", help="do not end")
optParser.add_option("-i", "--imap", action="store_true",
argparser.add_argument("-i", "--imap", action="store_true",
dest="imap",
help="use imap instead of minimail")
optParser.add_option("-o", "--own-identities", type="int", dest="own_ident",
argparser.add_argument("-o", "--own-identities", type=int, dest="own_ident",
help="simulate having OWN_IDENT own identities (1 to 3)", default=1)
optParser.add_option("-L", "--leave-device-group", action="store_true",
argparser.add_argument("-L", "--leave-device-group", action="store_true",
dest="leave",
help="after a successful sync run this to make the device leave the "
"device group again")
help="after a successful sync run this to make the device leave the device group again")
options, args = optParser.parse_args()
options = argparser.parse_args()
if not options.exec_for:
options.exec_for = os.path.basename(os.getcwd())

@ -74,39 +74,38 @@ EINTR = 4
if __name__ == "__main__":
from optparse import OptionParser
import argparse
optParser = OptionParser()
optParser.description = __doc__
optParser.add_option("-c", "--clean", action="store_true", dest="clean",
argparser = argparse.ArgumentParser(description= __doc__)
argparser.add_argument("-c", "--clean", action="store_true", dest="clean",
help="remove all generated files")
optParser.add_option("-b", "--backup", action="store_true", dest="backup",
argparser.add_argument("-b", "--backup", action="store_true", dest="backup",
help="make a backup of all generated files (old backup will be overwritten)")
optParser.add_option("-r", "--restore", action="store_true", dest="restore",
argparser.add_argument("-r", "--restore", action="store_true", dest="restore",
help="restore generated files from backup")
optParser.add_option("-C", "--clean-all", action="store_true", dest="cleanall",
argparser.add_argument("-C", "--clean-all", action="store_true", dest="cleanall",
help="remove all generated files including backup files")
optParser.add_option("-s", "--setup", action="store_true", dest="setup_only",
argparser.add_argument("-s", "--setup", action="store_true", dest="setup_only",
help="setup environment, then stop")
optParser.add_option("-p", "--print", action="store_true", dest="print",
argparser.add_argument("-p", "--print", action="store_true", dest="print",
help="print sync message trace in inbox")
optParser.add_option("-n", "--noend", action="store_true", dest="noend",
argparser.add_argument("-n", "--noend", action="store_true", dest="noend",
help="do not end")
optParser.add_option("-E", "--end-on", dest="notifications",
argparser.add_argument("-E", "--end-on", dest="notifications",
help="end test on these notifications")
optParser.add_option("-3", "--third-device", action="store_true", dest="third",
argparser.add_argument("-3", "--third-device", action="store_true", dest="third",
help="start Pad as third device")
optParser.add_option("-j", "--multi-threaded", action="store_true",
argparser.add_argument("-j", "--multi-threaded", action="store_true",
dest="multithreaded",
help="use multithreaded instead of single threaded implementation")
optParser.add_option("-i", "--imap", action="store_true",
argparser.add_argument("-i", "--imap", action="store_true",
dest="imap",
help="use imap instead of minimail")
optParser.add_option("-A", "--add-account-after-sync", action="store_true",
argparser.add_argument("-A", "--add-account-after-sync", action="store_true",
dest="add_account",
help="after sync add an account")
options, args = optParser.parse_args()
options = argparser.parse_args()
if options.imap:
import miniimap

Loading…
Cancel
Save