|
From: <tre...@us...> - 2009-09-06 22:22:40
|
Revision: 271
http://spd.svn.sourceforge.net/spd/?rev=271&view=rev
Author: treibholz
Date: 2009-09-06 21:20:39 +0000 (Sun, 06 Sep 2009)
Log Message:
-----------
simplified the API a little bit
creating the PasswordContainer now automatically calls importPasswordsPlain,
fillSQLite and flushPasswordsPlain (if you don't set autoload=False)
also exportPasswordsPlain now calls dumpSQL alone (if you don't set autoload=False)
Modified Paths:
--------------
trunk/src/spd
trunk/src/spdCore.py
Modified: trunk/src/spd
===================================================================
--- trunk/src/spd 2009-09-06 21:02:57 UTC (rev 270)
+++ trunk/src/spd 2009-09-06 21:20:39 UTC (rev 271)
@@ -48,9 +48,6 @@
# }}}
pc = spdCore.PasswordContainer('~/.spd/config')
-pc.importPasswordsPlain()
-pc.fillSQLite()
-pc.flushPasswordsPlain()
interface = spdCLI.cli()
@@ -58,7 +55,6 @@
if options.add:
pc.addEntry(interface.newEntry(pc.getCollumns()))
- pc.dumpSQLite()
pc.exportPasswordsPlain()
elif options.delete:
@@ -66,16 +62,15 @@
del searchPatterns[0]
del searchPatterns[0]
pc.delEntry(searchPatterns)
- pc.dumpSQLite()
pc.exportPasswordsPlain()
elif options.pwonly:
searchPatterns = sys.argv
del searchPatterns[0]
del searchPatterns[0]
- print pc.findPassword(searchPatterns)['Password'][0]
+ print pc.findPassword(searchPatterns)[pc.passwordField][0]
-else:
+else: # regular search
searchPatterns = sys.argv
del searchPatterns[0]
interface.listOutput(pc.findPassword(searchPatterns))
Modified: trunk/src/spdCore.py
===================================================================
--- trunk/src/spdCore.py 2009-09-06 21:02:57 UTC (rev 270)
+++ trunk/src/spdCore.py 2009-09-06 21:20:39 UTC (rev 271)
@@ -43,11 +43,13 @@
class PasswordContainer(object): # {{{
- # The Constructor
- # creates an internal memory-based SQLite database and declares a
- # a the self.__table dictionary
- # file: string, the config-file
- def __init__(self,file,debug=0): #{{{
+ '''The Constructor
+ creates an internal memory-based SQLite database and declares a
+ a the self.__table dictionary
+ file: string, the config-file
+ debug: if set to true, the database /tmp/spd_debug.db
+ autoload: if set to False, the data is not loaded automatically'''
+ def __init__(self,file,debug=False,autoload=True): #{{{
if not debug:
self.__sql = sqlite3.connect(":memory:")
@@ -92,6 +94,11 @@
self.users=[]
for i in c.items('Users'):
self.users.append(i[1])
+
+ if autoload:
+ self.importPasswordsPlain()
+ self.fillSQLite()
+ self.flushPasswordsPlain()
@@ -161,7 +168,10 @@
#}}}
# write passwordfile
- def exportPasswordsPlain(self): #{{{
+ def exportPasswordsPlain(self,autoload=True): #{{{
+ if autoload:
+ self.dumpSQLite()
+
vcs = self.vcs
encryption = self.encryption
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|