From: <Z3...@us...> - 2011-01-17 22:35:41
|
Revision: 332 http://spd.svn.sourceforge.net/spd/?rev=332&view=rev Author: Z3po Date: 2011-01-17 22:35:35 +0000 (Mon, 17 Jan 2011) Log Message: ----------- improved argument handling 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 2011-01-16 19:48:31 UTC (rev 331) +++ branches/spd-ng/src/spdCLI.py 2011-01-17 22:35:35 UTC (rev 332) @@ -23,11 +23,16 @@ exit(2) # }}} - def printPasswords(self,passdict,pwonly=False): # {{{ + def printPasswords(self,passdict,args=None): # {{{ """Print the passwords out of a dictionary. # passdict: the dictionary full of passwords""" __keylength = {} + pwonly = False + if args is not None: + if 'pwonly' in args: + pwonly = args['pwonly'] + if type(passdict).__name__ != 'NoneType' and len(passdict) != 0: if pwonly: if len(passdict['__ID']) > 1: @@ -212,18 +217,18 @@ self.__outmode = 'line' if options.addEntry: - return ["addEntry", args] + return ["addEntry", { 'args' : args }] elif options.deleteEntry: - return ["deleteEntry", [ options.byid, args]] + return ["deleteEntry", { 'byid' : options.byid, 'args' : args }] elif options.editEntry: - return ["editEntry", [ options.byid, args]] + return ["editEntry", { 'byid' : options.byid, 'args' : args }] elif options.deleteColumn: - return ["deleteColumn", args] + return ["deleteColumn", { 'args' : args }] elif options.addColumn: - return ["addColumn", args] + return ["addColumn", { 'args' : args }] - return ["printPasswords", [ options.byid, options.pwonly, args]] + return ["printPasswords", { 'byid' : options.byid, 'pwonly' : options.pwonly, 'args' : args }] # }}} # }}} Modified: branches/spd-ng/src/spdInterface.py =================================================================== --- branches/spd-ng/src/spdInterface.py 2011-01-16 19:48:31 UTC (rev 331) +++ branches/spd-ng/src/spdInterface.py 2011-01-17 22:35:35 UTC (rev 332) @@ -105,7 +105,13 @@ print the results in CLIENTMODE. # searchlist: optional string or list of keywords to search for.""" - byid, searchString = args + if 'byid' in args: + byid = args['byid'] + + if 'args' in args: + searchString = args['args'] + else: + searchString = '%' if type(searchString).__name__ == 'list': searchlist = searchString @@ -114,19 +120,18 @@ if len(searchlist) == 0: searchlist = ['%',] + passdict = self.__core.searchEntry(searchlist,byid) return passdict # }}} def printPasswords(self,args): # {{{ - byid, pwonly, keywords = args - passdict = self.__findPasswords([ byid, keywords ]) - self.__client.printPasswords(passdict, pwonly) + passdict = self.__findPasswords(args) + self.__client.printPasswords(passdict, args) # }}} def deleteEntry(self, args): # {{{ - byid, searchString = args __passdict = self.__findPasswords(args) if len(__passdict) == 0: @@ -146,7 +151,11 @@ self.__ErrorHandler('editEntry','no matches for ' + str(args[1]) + 'found') # }}} - def deleteColumn(self,columns): # {{{ + def deleteColumn(self,args): # {{{ + if 'args' in args: + columns = args['args'] + else: + columns = [] for column in columns: if column in self.__core.getColumns(showid=False): self.__core.delColumn(column) @@ -154,7 +163,12 @@ self.__ErrorHandler('deleteColumn','column ' + column + ' is not part of the passwordfile') # }}} - def addColumn(self,columns): # {{{ + def addColumn(self,args): # {{{ + if 'args' in args: + columns = args['args'] + else: + columns = [] + for column in columns: self.__core.addColumn(column) # }}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |