|
From: <tre...@us...> - 2009-09-06 15:35:45
|
Revision: 269
http://spd.svn.sourceforge.net/spd/?rev=269&view=rev
Author: treibholz
Date: 2009-09-06 15:35:32 +0000 (Sun, 06 Sep 2009)
Log Message:
-----------
removed the class config.
PasswordContainer now gets the configuration by its constructor.
Modified Paths:
--------------
trunk/src/spd
trunk/src/spdCore.py
Modified: trunk/src/spd
===================================================================
--- trunk/src/spd 2009-09-05 11:05:52 UTC (rev 268)
+++ trunk/src/spd 2009-09-06 15:35:32 UTC (rev 269)
@@ -47,9 +47,8 @@
(options, args) = parser.parse_args()
# }}}
-config = spdCore.config('~/.spd/config')
-pc = spdCore.PasswordContainer()
-pc.importPasswordsPlain(config.file,"\t",config.encryption,config.vcs)
+pc = spdCore.PasswordContainer('~/.spd/config')
+pc.importPasswordsPlain()
pc.fillSQLite()
pc.flushPasswordsPlain()
@@ -61,13 +60,13 @@
pc.addEntry(interface.newEntry(pc.getCollumns()))
pc.recipients = config.users
pc.dumpSQLite()
- pc.exportPasswordsPlain(config.file,"\t",config.encryption,config.vcs)
+ pc.exportPasswordsPlain()
elif options.delete:
pc.delEntry(options.delete)
pc.recipients = config.users
pc.dumpSQLite()
- pc.exportPasswordsPlain(config.file,"\t",config.encryption,config.vcs)
+ pc.exportPasswordsPlain()
elif options.pwonly:
searchPatterns = sys.argv
Modified: trunk/src/spdCore.py
===================================================================
--- trunk/src/spdCore.py 2009-09-05 11:05:52 UTC (rev 268)
+++ trunk/src/spdCore.py 2009-09-06 15:35:32 UTC (rev 269)
@@ -46,21 +46,61 @@
# The Constructor
# creates an internal memory-based SQLite database and declares a
# a the self.__table dictionary
- def __init__(self): #{{{
+ # file: string, the config-file
+ def __init__(self,file): #{{{
+
self.__sql = sqlite3.connect(":memory:")
self.__table = {}
- self.passwordField = "Password"
+ # read the config
+ file = os.path.expanduser(file)
+ c = ConfigParser.RawConfigParser()
+
+ if os.access(file,os.F_OK):
+ c.read(file)
+ else: # generate the config if not there # {{{
+ c.add_section('Main')
+ c.set('Main','file','~/.spd/spd_data.gpg')
+ c.set('Main','passwordField','Password')
+ c.set('Main','encryption','GnuPG')
+ c.set('Main','vcs','none')
+
+ c.add_section('Users')
+ c.set('Users', 'User1', "Klaus Umbach")
+ c.set('Users', 'User2', "Klaus Windows")
+
+ c.add_section('Colors')
+ c.set('Colors','passwordFG','brightblue')
+ c.set('Colors','passwordBG','blue')
+ configfile = open(file, 'wb')
+ c.write(configfile)
+ # }}}
+
+ # set the configuration variables
+ self.file = os.path.expanduser(c.get('Main','file'))
+ self.encryption = c.get('Main','encryption')
+ self.passwordField = c.get('Main', 'passwordField')
+ self.separator = '\t'
+
+ self.vcs = c.get('Main','vcs')
+
+
+ self.users=[]
+ for i in c.items('Users'):
+ self.users.append(i[1])
+
+
+
#}}}
- # Read what-ever-separated passwordfile
- # file: string
- # separator: string
- # encryption: string
- # currently either "GnuPG" or "none"
- # vcs: string
- # currently either "SVN" or "none"
- def importPasswordsPlain(self,file,separator,encryption,vcs): #{{{
+ # read passwordfile
+ def importPasswordsPlain(self): #{{{
+ vcs = self.vcs
+ encryption = self.encryption
+ file = self.file
+ separator = self.separator
+
+
if (vcs == "svn"):
svn = pysvn.Client()
svn.update(file)
@@ -116,14 +156,15 @@
return True
#}}}
- # write as what-ever-separated passwordfile
- # file: string
- # separator: string
- # encryption: string
- # currently either "GnuPG" or "none"
- # vcs: string
- # currently either "SVN" or "none"
- def exportPasswordsPlain(self,file,separator,encryption,vcs): #{{{
+ # write passwordfile
+ def exportPasswordsPlain(self): #{{{
+ vcs = self.vcs
+ encryption = self.encryption
+
+ file = self.file
+ separator = self.separator
+
+
if (encryption == "GnuPG"):
fobj = GPGFile()
fobj.open(file,"w",self.recipients)
@@ -350,50 +391,5 @@
# }}}
-class config(object): # {{{
-
- def __init__(self,file): # {{{
-
- file = os.path.expanduser(file)
-
- c = ConfigParser.RawConfigParser()
-
- if os.access(file,os.F_OK):
- c.read(file)
- else:
- c.add_section('Main')
- c.set('Main','file','~/.spd/spd_data.gpg')
- c.set('Main','passwordField','Password')
- c.set('Main','encryption','GnuPG')
- c.set('Main','vcs','none')
-
- c.add_section('Users')
- c.set('Users', 'User1', "Klaus Umbach")
- c.set('Users', 'User2', "Klaus Windows")
-
- c.add_section('Colors')
- c.set('Colors','passwordFG','brightblue')
- c.set('Colors','passwordBG','blue')
- configfile = open(file, 'wb')
- c.write(configfile)
-
- # set the configuration variables
- self.file = os.path.expanduser(c.get('Main','file'))
- self.encryption = c.get('Main','encryption')
-
- self.vcs = c.get('Main','vcs')
-
-
- self.users=[]
- for i in c.items('Users'):
- self.users.append(i[1])
-
-
- # }}}
-
-
-
-# }}}
-
# EOF
# vim:foldmethod=marker:tabstop=3:autoindent
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|