in tools/edit-list.py [0:0]
def __init__(self):
parser = argparse.ArgumentParser(description='Command line options.')
# Cannot have both source and mid as input
source_group = parser.add_mutually_exclusive_group()
source_group.add_argument('--source', dest='source', type=str,
help='Source list to edit')
source_group.add_argument('--mid', dest='mid', type=str,
help='Source Message-ID to edit')
parser.add_argument('--rename', dest='target', type=str,
help='(optional) new list ID')
parser.add_argument('--desc', dest='desc', type=str,
help='(optional) new list description')
parser.add_argument('--obfuscate', dest='obfuscate', type=str,
help='Things to obfuscate in body, if any')
# private and public are mutually exclusive
privacy_group = parser.add_mutually_exclusive_group()
privacy_group.add_argument('--private', dest='private', action='store_true',
help='Make all emails in list private')
privacy_group.add_argument('--public', dest='public', action='store_true',
help='Make all emails in list public')
parser.add_argument('--delete', dest='delete', action='store_true',
help='Delete emails from this list')
parser.add_argument('--wildcard', dest='glob', action='store_true',
help='Allow wildcards in --source')
parser.add_argument('--debug', dest='debug', action='store_true',
help='Debug output - very noisy!')
parser.add_argument('--notag', dest='notag', action='store_true',
help='List IDs do not have <> in them')
parser.add_argument('--test', dest='test', action='store_true',
help='Only test for occurrences, do not run the chosen action (dry run)')
args = parser.parse_args()
self.sourceLID = args.source
self.targetLID = args.target
self.desc = args.desc
self.makePrivate = args.private
self.makePublic = args.public
self.deleteEmails = args.delete
self.wildcard = args.glob
self.debug = args.debug
self.notag = args.notag
self.mid = args.mid
self.obfuscate = args.obfuscate
self.dryrun = args.test
self.privacyChange = self.makePrivate or self.makePublic
self.otherChange = self.targetLID or self.desc or self.obfuscate
self.anyChange = self.privacyChange or self.otherChange
if not self.sourceLID and not self.mid:
print("No source list ID specified!")
parser.print_help()
sys.exit(-1)
if not (self.anyChange or self.deleteEmails):
print("Nothing to do! No target list ID or action specified")
parser.print_help()
sys.exit(-1)
if self.desc and not self.sourceLID:
print("No source list ID specified for description!")
parser.print_help()
sys.exit(-1)
if self.anyChange and self.deleteEmails:
print("Cannot both change and delete emails in the same run")
parser.print_help()
sys.exit(-1)
# TODO does it make sense to allow --rename with --mid?
# i.e. rename the list for a single mid?
if self.sourceLID:
self.sourceLID = ("%s" if self.notag else "<%s>") % self.sourceLID.replace("@", ".").strip("<>")
if self.targetLID:
self.targetLID = "<%s>" % self.targetLID.replace("@", ".").strip("<>")