[Nym3-commit] r232 - trunk/nym3/Client
jr at conuropsis.org
jr at conuropsis.org
Wed May 4 14:29:59 CEST 2005
Author: jr
Date: 2005-05-04 14:29:58 +0200 (Wed, 04 May 2005)
New Revision: 232
Modified:
trunk/nym3/Client/Main.py
Log:
Add export command
Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py 2005-05-04 11:52:04 UTC (rev 231)
+++ trunk/nym3/Client/Main.py 2005-05-04 12:29:58 UTC (rev 232)
@@ -389,6 +389,27 @@
index += len(midlist)
assert count == len(mbox.keys())
+def export(ui, config, nickname, output = None, args = [])
+ account = get_account_from_nickname(ui, config, nickname,
+ "No nickname given, abort\nUse -n <nickname>")
+ output_f = sys.stdout
+ if output != None:
+ try:
+ output_f = open(output, "w")
+ except IOError:
+ ui.display("Unable to write in output file, abort")
+ sys.exit(1)
+ for hmid in args:
+ mid = binascii.unhexlify(hmid)
+ if mbox.has_key(mid):
+ output_f.write(mbox[mid])
+ else:
+ ui.display("%s: no email relative to that mid" % hmid)
+ if output_f != sys.stdout:
+ output_f.close()
+ else:
+ sys.stdout.flush()
+
def main(args):
if len(args) < 2:
print "Usage: WRITEME"
@@ -528,6 +549,20 @@
list_mbox(ui, config, options.nickname)
sys.exit(0)
+ if args[1] == "export":
+ parser = OptionParser()
+ parser.add_option("-n", "--nickname", action = "store",
+ dest = "nickname", help = "The nickname "
+ "of the account whose emails to request")
+ parser.add_option("-o", "--output", action = "store",
+ dest = "output", help = "The file to export the " +
+ "message to, stdout if omitted")
+ (options, args) = parser.parse_args(args[2:])
+ ui = CLI()
+ config = Config.Config()
+ export(ui, config, options.nickname, options.output, args)
+ sys.exit(0)
+
if __name__ == '__main__':
main(sys.argv)
sys.exit(0)
More information about the Nym3-commit
mailing list