|
From: <Z3...@us...> - 2010-12-25 11:25:51
|
Revision: 325
http://spd.svn.sourceforge.net/spd/?rev=325&view=rev
Author: Z3po
Date: 2010-12-25 11:25:43 +0000 (Sat, 25 Dec 2010)
Log Message:
-----------
introducing --wide mode
Modified Paths:
--------------
branches/spd-ng/src/spdCLI.py
branches/spd-ng/src/test.db
Modified: branches/spd-ng/src/spdCLI.py
===================================================================
--- branches/spd-ng/src/spdCLI.py 2010-12-25 00:35:22 UTC (rev 324)
+++ branches/spd-ng/src/spdCLI.py 2010-12-25 11:25:43 UTC (rev 325)
@@ -1,6 +1,8 @@
#!/usr/bin/python
from optparse import OptionParser
+import sys
+import re
class Cli(object): # {{{
"""This is the Cli Module.
@@ -8,12 +10,25 @@
__outmode = None
+ def __ErrorHandler(self,function,message): # {{{
+ """ErrorHandler of the Client Module.
+ # function: the function which throws the error
+ # message: means the \'Exception\' to throw"""
+ print "################################################"
+ print "spdCli ErrorHandler."
+ print "ERRORFUNCTION: " + function
+ print "ERRORMESSAGE: " + message
+ print "################################################"
+ exit(2)
+ # }}}
+
def printPasswords(self,passdict): # {{{
"""Print the passwords out of a dictionary.
# passdict: the dictionary full of passwords"""
+ __keylength = {}
if type(passdict).__name__ != 'NoneType' and len(passdict) != 0:
- if self.__outmode == 'lines':
+ if self.__outmode == 'line':
length = 0
for key in passdict.keys():
if length < len(key):
@@ -30,7 +45,32 @@
print key.ljust(length) + ': '
print ""
elif self.__outmode == 'wide':
- print 'NOT YET IMPLEMENTED...SORRY'
+ for key in passdict:
+ __keylength.update({ key : 0 })
+
+ if len(key) > __keylength[key]:
+ __keylength[key] = len(key)
+ for value in passdict[key]:
+ if value is not None:
+ if len(str(value)) > __keylength[key]:
+ __keylength[key] = len(str(value))
+
+ for key in passdict:
+ sys.stdout.write(key.ljust(__keylength[key]) + '|')
+ sys.stdout.write('\n')
+
+ __entries = len(passdict.values()[0])
+
+ for i in range(0,__entries):
+ __space = ''
+ for key in passdict:
+ if passdict[key][i] is None:
+ passdict[key][i] = ''
+ sys.stdout.write(re.sub('\n','\n' + __space,str(passdict[key][i]).ljust(__keylength[key])) + '|')
+ __space = __space + ''.ljust(__keylength[key]) + ' '
+ sys.stdout.write('\n')
+ else:
+ self.__ErrorHandler('printPasswords', 'output mode unknown')
else:
print "No Results found"
# }}}
@@ -45,7 +85,6 @@
# }}}
def parseArgs(self,version): # {{{
- __ouput="lines"
parser = OptionParser( "%prog [Options] [Keywords]",
description = "SPD - Simple Password Displayer - CLI",
version = "SPD " + version,
@@ -119,15 +158,11 @@
elif options.widemode:
self.__outmode = 'wide'
else:
- self.__outmode = 'lines'
+ self.__outmode = 'line'
return ["printPasswords", args]
# }}}
- def main(self,options,args): # {{{
- pass
- # }}}
-
# }}}
# EOF
Modified: branches/spd-ng/src/test.db
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|