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

jr at komite.net jr at komite.net
Mon Jan 3 01:20:44 CET 2005


Author: jr
Date: 2005-01-03 01:20:43 +0100 (Mon, 03 Jan 2005)
New Revision: 152

Modified:
   trunk/nym3/Client/testcurses.py
Log:
- beginning of the account_tab, used for displaying a user
nym accounts


Modified: trunk/nym3/Client/testcurses.py
===================================================================
--- trunk/nym3/Client/testcurses.py	2005-01-02 23:08:59 UTC (rev 151)
+++ trunk/nym3/Client/testcurses.py	2005-01-03 00:20:43 UTC (rev 152)
@@ -160,6 +160,68 @@
 	deleteC.fromData(delete_list)
 	return str(getC) + str(deleteC)
 
+class Account_tab:
+    """The class that contains the tab holding one user accounts
+    """
+    
+    def __init__(self, base):
+	os.chdir(base)
+	kr = base + os.sep + 'keyring'
+	kr_exists = False
+	try:
+	    self.key_ring = pickle.load()
+	except pickle.UnPicklingError:
+	    self.key_ring = None
+	try:
+	    os.chdir("pending")
+	except:
+	    pass
+	else:
+	    #treat pending messages
+	    os.chdir('..')
+	
+	files = os.listdir(os.getcwd())
+	def is_useful_dir(f):
+	    try:
+		if stat.IS_DIR(os.stat(f)[stat.ST_MODE]):
+		    #has f the good format
+		    return True
+	    except:
+		pass
+	    return False
+
+	files = filter(is_useful_dir, files)
+	self.attr = {}
+	for d in files:
+	    self.attr[d] = False
+	if self.key_ring != None:
+	    #set the attributes of usable files to True
+	    pass
+	self.tab = attr.keys()
+	self.tab.sort()
+	
+    def size(self):
+	"""return the size of the table"""
+	return len(self.tab)
+
+    def line(self, i):
+	"""return the content of the line i"""
+	flag = ''
+	if self.attr[self.tab[i]]:
+	    flag += 'U'
+	else:
+	    flag += ' '
+	return flag + ' ' + self.tab[i], 1
+    
+    def get_actions(self):
+	return {
+		ord('\n'): self.idle,
+		ord(' '): self.idle,
+		}
+    
+    def idle(self):
+	pass
+	
 class Pager:
     """ this class takes care of the display of a message in a pager.
     It does the approptiate display in a provided window"""



More information about the Nym3-commit mailing list