From: <z3...@us...> - 2010-09-15 20:01:39
|
Revision: 317 http://spd.svn.sourceforge.net/spd/?rev=317&view=rev Author: z3po Date: 2010-09-15 20:01:33 +0000 (Wed, 15 Sep 2010) Log Message: ----------- included --delete-id and --delete Modified Paths: -------------- branches/spd-ng/src/spdCLI.py branches/spd-ng/src/spdInterface.py Modified: branches/spd-ng/src/spdCLI.py =================================================================== --- branches/spd-ng/src/spdCLI.py 2010-09-12 21:29:23 UTC (rev 316) +++ branches/spd-ng/src/spdCLI.py 2010-09-15 20:01:33 UTC (rev 317) @@ -4,7 +4,7 @@ class Cli(object): # {{{ """This is the Cli Module. - Resistance is Futile""" + Resistance is futile""" output = "normal" @@ -33,13 +33,6 @@ print "No Results found" # }}} - def findPasswordsInteractive(self): # {{{ - """Create the searchString interactively""" - - searchstring = raw_input("Please give your Searchstrings separated by whitespace") - return searchstring - # }}} - def createEntry(self,columns): # {{{ Entry = {} print "Adding a new Entry to our passfile" @@ -56,21 +49,23 @@ epilog = """With no parameters it will print out everything! Please report Bugs or Feature Request at http://spd.sourceforge.net""") - #parser.add_option( "-d", "--delete", - # metavar="Keywords", - # dest ="delete", - # help ="Entries to delete") - # + parser.add_option( "-d", "--delete", + action = "store_true", + dest ="delete", + default = False, + help ="Entries to delete") + #parser.add_option( "-e", "--edit", # metavar="ID", # dest ="edit", # help ="ID to edit") # - #parser.add_option( "-i", "--delete-id", - # metavar="ID", - # dest ="deleteID", - # help ="ID to delete") - # + parser.add_option( "-i", "--delete-id", + action = "store_true", + dest ="deleteID", + default = False, + help ="ID(s) to delete") + #parser.add_option( "--id", # dest ="id", # help ="Show Password by ID") @@ -114,8 +109,12 @@ if options.add: Entry = self.createEntry(columns) return ["addEntry", Entry] + elif options.delete: + return ["deleteEntry", args] + elif options.deleteID: + return ["deleteID", args] - return ["findPasswords", args] + return ["printPasswords", args] # }}} def main(self,options,args): # {{{ Modified: branches/spd-ng/src/spdInterface.py =================================================================== --- branches/spd-ng/src/spdInterface.py 2010-09-12 21:29:23 UTC (rev 316) +++ branches/spd-ng/src/spdInterface.py 2010-09-15 20:01:33 UTC (rev 317) @@ -35,8 +35,8 @@ # }}} def findPasswords(self,searchString='%'): # {{{ - """Find the passwords by searchlist handed. - print the results in output format. + """Find the passwords by searchlist/searchstring handed. + print the results in CLIENTMODE. # searchlist: optional string or list of keywords to search for.""" if type(searchString).__name__ == 'list': @@ -47,9 +47,30 @@ if len(searchlist) == 0: searchlist = ['%',] passdict = self.core.searchEntry(searchlist) + return passdict + # }}} + + def printPasswords(self,searchString='%'): # {{{ + passdict = self.findPasswords(searchString) self.client.printPasswords(passdict) # }}} + def deleteID(self,ids): # {{{ + if type(ids).__name__ != 'list': + if type(ids).__name__ == 'int': + ids = str(ids) + ids = string.split(ids) + for id in ids: + self.core.delEntry(id) + # }}} + + def deleteEntry(self,searchString): # {{{ + passdict = self.findPasswords(searchString) + print str(passdict) + for id in passdict["__ID"]: + self.core.delEntry(id) + # }}} + def addEntry(self,Entry): # {{{ self.core.addEntry(Entry) # }}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |