[Nym3-commit] r146 - trunk/nym3/Client

laurent at komite.net laurent at komite.net
Wed Dec 29 00:19:09 CET 2004


Author: laurent
Date: 2004-12-29 00:19:08 +0100 (Wed, 29 Dec 2004)
New Revision: 146

Modified:
   trunk/nym3/Client/testcurses.py
Log:
use flags in the format.


Modified: trunk/nym3/Client/testcurses.py
===================================================================
--- trunk/nym3/Client/testcurses.py	2004-12-28 21:45:16 UTC (rev 145)
+++ trunk/nym3/Client/testcurses.py	2004-12-28 23:19:08 UTC (rev 146)
@@ -64,7 +64,6 @@
     
     def __init__(self):
 	self.synlist = [syn1, syn2] # TODO: testing only
-	pass
 
     def view(self, i):
 	"""Display the requested synopsis"""
@@ -81,6 +80,11 @@
     def size(self):
 	return len(self.synlist)
 
+    def format(self, s, l):
+	ret = s[:l]
+	if len(ret) < l: ret = ret + ' ' * (l - len(s))
+	return ret
+
     def line(self, i):
 	"""Ugly print current entry as a line"""
 	# TODO: we need to draw this better.
@@ -89,8 +93,19 @@
 	assert(i < len(self.synlist))
 	syn = self.synlist[i]
 	sfrom, sdate, subject = self.extract(syn, 'From', 'Date', 'Subject')
-	return "%s %s %s" % (sdate, sfrom, subject)
+	sfrom = self.format(sfrom, 10)
+	sdate = self.format(sdate, 20)
+	subject = self.format(subject, 20)
+	if syn['read_status'] == 'unread': flags = 'N'
+	else: flags = " "
+	if syn['fetch_status'] == 'fetch': flags += 'F'
+	elif syn['fetch_status'] == 'fetch_asked': flags += 'f'
+	elif syn['fetch_status'] == 'delete': flags += 'D'
+	elif syn['fetch_status'] == 'delete_asked': flags += 'd'
+	else: flags += ' '
 
+	return "%s %s %s %s" % (flags, sdate, sfrom, subject)
+
     def extract(self, syn, *h):
 	"""Get most important header of a mail"""
 	#TODO: this is not RFC2822-compliant



More information about the Nym3-commit mailing list