From: <Z3...@us...> - 2010-06-27 11:51:54
|
Revision: 295 http://spd.svn.sourceforge.net/spd/?rev=295&view=rev Author: Z3po Date: 2010-06-27 11:51:48 +0000 (Sun, 27 Jun 2010) Log Message: ----------- added functionality to add key (collumn) to passfile Modified Paths: -------------- trunk/src/spd-cli trunk/src/spdCore.py Modified: trunk/src/spd-cli =================================================================== --- trunk/src/spd-cli 2010-06-27 10:17:05 UTC (rev 294) +++ trunk/src/spd-cli 2010-06-27 11:51:48 UTC (rev 295) @@ -52,6 +52,13 @@ default=False, help = "Add an Entry") +parser.add_option( "--add-key", + metavar="Keyword", + dest = "addkey", + default=False, + help = "Add a Keyword") + + parser.add_option( "-p", "--password-only", action="store_true", dest = "pwonly", @@ -74,9 +81,6 @@ dest = "passfile", help = "do not use the confgured passfile but the one given here") - - - (options, args) = parser.parse_args() # }}} @@ -90,6 +94,10 @@ pc.addEntry(interface.newEntry(pc.getCollumns())) pc.exportPasswordsPlain() +elif options.addkey: + pc.addCollumn(options.addkey) + pc.exportPasswordsPlain() + elif options.delete: searchPatterns = args del searchPatterns[0] @@ -116,7 +124,6 @@ else: # regular search searchPatterns = args - print str(searchPatterns) + "\n\n" if options.localStore: try: del searchPatterns[searchPatterns.index('-l')] Modified: trunk/src/spdCore.py =================================================================== --- trunk/src/spdCore.py 2010-06-27 10:17:05 UTC (rev 294) +++ trunk/src/spdCore.py 2010-06-27 11:51:48 UTC (rev 295) @@ -209,7 +209,10 @@ count=0 for collumns in self.__table: # now we are writing the data count += 1 - fobj.write(self.__table[collumns][i]) # <- here + if not self.__table[collumns][1]: + fobj.write('') # <- here + else: + fobj.write(self.__table[collumns][i]) # <- and here if (count == len(self.__table)): # write \n if last collumn fobj.write('\n') else: # otherwise write the separator @@ -259,9 +262,15 @@ def dumpSQLite(self): #{{{ """dump SQLite in self.__table""" + # First get Collumns of SQL Database...maybe they are changed + cursor = self.__sql.cursor() + cursor.execute("PRAGMA TABLE_INFO(passwords)") + for row in cursor: + if row[1] != "__ID": + self.__table[str(row[1])] = [] + # quite easy, eh? :-) self.__table = self.findPassword("%",output='noID') - #}}} def findPassword(self,patterns,output='table'): #{{{ @@ -374,7 +383,7 @@ """add a collumn to passfile name: name of new collumn""" cursor = self.__sql.cursor() - + query = "ALTER TABLE passwords ADD `" + name + "` TEXT" cursor.execute(query) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |