[Nym3-commit] r331 - trunk/nymbaron/Client

jr at conuropsis.org jr at conuropsis.org
Tue Oct 11 21:48:37 CEST 2005


Author: jr
Date: 2005-10-11 21:48:36 +0200 (Tue, 11 Oct 2005)
New Revision: 331

Modified:
   trunk/nymbaron/Client/Config.py
Log:
- add functions to parse a configuration file


Modified: trunk/nymbaron/Client/Config.py
===================================================================
--- trunk/nymbaron/Client/Config.py	2005-10-10 00:06:31 UTC (rev 330)
+++ trunk/nymbaron/Client/Config.py	2005-10-11 19:48:36 UTC (rev 331)
@@ -23,22 +23,19 @@
 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 import os
+import ConfigParser
 
 class Config:
     
-    def __init__(self):
+    def __init__(self, filename = None):
+	#####Default values#####
+	
 	#Tells the client whether he should send the messages he generates
 	# through mixminion or output them on stdout
 	self.DEBUG = False
 	#The path to the directory containing the user accounts
 	self.path = os.environ['HOME']  + '/.nymbaron-account'
 
-	self.pubring_path = self.path + os.sep + "pubring"
-	self.secring_path = self.path + os.sep + "secring"
-
-	#address where surbs point to"""
-	self.defaultAddress = "smtp:nobody at nowhere.net"
-
 	# Required key length (§ 4.3.4)
 	self.idkey_length = 2048
 	self.enckey_length = 2048
@@ -49,5 +46,28 @@
 	# Default number of surbs to request in SURB command
 	self.nb_surb = 42
 
-    def load_from_file(self, filename):
-	pass
+	if filename:
+	    config = ConfigParser.RawConfigParser()
+	    config.read(filename)
+	    
+	    if config.has_section('general'):
+		if config.has_option('general', 'DEBUG'):
+		    self.DEBUG = config.getboolean('general', 'DEBUG')
+		if config.has_option('general', 'path'):
+		    self.path = config.get('general', 'path')
+	    if config.has_section('crypto'):
+		if config.has_option('crypto', 'idkey_length'):
+		    self.idkey_length = config.getint('crypto',
+				'idkey_length')
+		if config.has_option('crypto', 'enckey_length'):
+		    self.enckey_length = config.getint('crypto',
+				'enckey_length')
+	    if config.has_section('command'):
+		if config.has_option('command', 'max_syn'):
+		    self.max_syn = config.getint('command', 'max_syn')
+		if config.has_option('command', 'nb_surb'):
+		    self.nb_surb = config.getint('command', 'nb_surb')
+		    
+	self.pubring_path = self.path + os.sep + "pubring"
+	self.secring_path = self.path + os.sep + "secring"
+



More information about the Nym3-commit mailing list