|
From: <Z3...@us...> - 2011-06-27 20:31:29
|
Revision: 336
http://spd.svn.sourceforge.net/spd/?rev=336&view=rev
Author: Z3po
Date: 2011-06-27 20:31:22 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
beginning to restructure the whole spd stuff
Modified Paths:
--------------
branches/spd-ng/src/spd
branches/spd-ng/src/spdCore.py
Added Paths:
-----------
branches/spd-ng/src/spdCLI.py
branches/spd-ng/src/spdInterface/
branches/spd-ng/src/spdInterface/__init__.py
branches/spd-ng/src/spdStore/
branches/spd-ng/src/spdStore/__init__.py
Removed Paths:
-------------
branches/spd-ng/src/spdCLI.py
branches/spd-ng/src/spdInterface.py
branches/spd-ng/src/spdStore.py
Modified: branches/spd-ng/src/spd
===================================================================
--- branches/spd-ng/src/spd 2011-04-14 19:51:29 UTC (rev 335)
+++ branches/spd-ng/src/spd 2011-06-27 20:31:22 UTC (rev 336)
@@ -2,5 +2,6 @@
import spdInterface
+
Interface = spdInterface.Interface()
Interface.main()
Deleted: branches/spd-ng/src/spdCLI.py
===================================================================
--- branches/spd-ng/src/spdCLI.py 2011-04-14 19:51:29 UTC (rev 335)
+++ branches/spd-ng/src/spdCLI.py 2011-06-27 20:31:22 UTC (rev 336)
@@ -1,261 +0,0 @@
-#!/usr/bin/python
-
-from optparse import OptionParser, OptionGroup
-from sys import stdout
-from re import sub, search
-
-__version__ = '0.3-alpha'
-
-
-class Cli(object): # {{{
- """This is the Cli Module.
- Resistance is futile"""
- __outmode = None
- __version__ = '0.3-alpha'
- _passwordfield = 'Password'
-
- 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,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:
- self.__ErrorHandler('printPasswords', 'pwonly selected but more than one result returned')
- else:
- print passdict[self._passwordfield][0]
-
- elif self.__outmode == 'line':
- length = 0
- for key in passdict.keys():
- if length < len(key):
- length = len(key)
- print ""
- for i in range(0,len(passdict.values()[0])):
- print "__ID".ljust(length) + ':' + str(passdict["__ID"][i])
- for key in passdict:
- if key == '__ID':
- continue
- if type(passdict[key][i]).__name__ != 'NoneType':
- print key.ljust(length) + ': ' + sub('\n','\n ' + ' '.ljust(length),passdict[key][i])
- else:
- print key.ljust(length) + ': '
- print ""
- elif self.__outmode == 'wide':
- 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 search('\n',str(value)):
- for partvalue in value.split('\n'):
- if len(str(partvalue)) > __keylength[key]:
- __keylength[key] = len(str(partvalue))
- else:
- if len(str(value)) > __keylength[key]:
- __keylength[key] = len(str(value))
-
- for key in passdict:
- stdout.write(key.ljust(__keylength[key]) + '|')
- 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] = ''
- __count = 0
- for line in str(passdict[key][i]).split('\n'):
- if __count > 0:
- stdout.write('\n' + __space)
- stdout.write(line.ljust(__keylength[key]) + '|')
- __count += 1
- __space = __space + ''.ljust(__keylength[key],'>') + '>'
- stdout.write('\n')
- else:
- self.__ErrorHandler('printPasswords', 'output mode unknown')
- else:
- print "No Results found"
- # }}}
-
- def editEntry(self,__passdict): # {{{
- __count = len(__passdict['__ID'])
- for i in range(0, __count):
- print '---------------------------'
- print 'Changing Entry with ID: ' + str(__passdict['__ID'][i]) + '\nENTER for no changes.'
- for __column in __passdict:
- __input = ''
- if __column != '__ID':
- if __passdict[__column][i] is None:
- __passdict[__column][i] = ''
- __input = raw_input(__column + ' (' + str(__passdict[__column][i]) + '): ')
- if search('^"""',__input):
- tempinput = sub('^"""','',__input) + '\n'
- __input = raw_input(' '.ljust(len(__column),'>') + ':')
- while not search('"""$',__input):
- tempinput = tempinput + __input + '\n'
- __input = raw_input(' '.ljust(len(__column),'>') + ':')
- tempinput = tempinput + sub('"""$','',__input)
- __passdict[__column][i] = tempinput
- elif __input != '':
- __passdict[__column][i] = __input
- return __passdict
- # }}}
-
- def deleteEntry(self,__passdict): # {{{
- __count = len(__passdict['__ID'])
- __ids = []
- print '\n---------------------------'
- for i in range(0, __count):
- __input = None
- while __input != 'y' and __input != 'n':
- __input = raw_input('Delete Entry with ID ' + str(__passdict['__ID'][i]) + ' (y|n)?')
- if __input == 'y':
- __ids.append(__passdict['__ID'][i])
- return __ids
- # }}}
-
- def createEntry(self,columns): # {{{
- Entry = {}
- print "Adding a new Entry to our passfile"
- for column in columns:
- value = raw_input(column + ': ')
- if search('^"""',value):
- tempval = sub('^"""','',value) + '\n'
- value = raw_input(column + ': ')
- while not search('"""$',value):
- tempval = tempval + value + '\n'
- value = raw_input(column + ': ')
- tempval = tempval + sub('"""$','',value)
- value = tempval
- Entry.update({ column : value })
- return Entry
- # }}}
-
- def parseArgs(self,version): # {{{
- parser = OptionParser( "%prog [Options] [Keywords]",
- description = "SPD - Simple Password Displayer - CLI",
- version = """spdCore """ + version +
- """\nspdCLI """ + self.__version__,
- epilog = """With no parameters it will print out everything!
- Please report Bugs or Feature Request at http://spd.sourceforge.net""")
-
- parser.add_option( "-a", "--add",
- action="store_true",
- dest = "addEntry",
- default=False,
- help = "Add an Entry")
-
- parser.add_option( "-e", "--edit",
- action = "store_true",
- dest ="editEntry",
- help ="Edit given Entries (IDs)")
-
- parser.add_option( "-d", "--delete",
- action = "store_true",
- dest ="deleteEntry",
- default = False,
- help ="Delete given Entries")
-
- group = OptionGroup(parser, "Input Manipulation")
-
- group.add_option( "--id",
- action="store_true",
- dest ="byid",
- default=False,
- help ="Handle Input given as ID(s)")
-
- parser.add_option_group(group)
-
- group = OptionGroup(parser, "Output Manipulation")
-
- group.add_option( "-w", "--wide",
- action="store_true",
- dest = "widemode",
- default=False,
- help = "print output in wide mode (means as a table)")
-
-
- group.add_option( "-p", "--password-only",
- action="store_true",
- dest = "pwonly",
- default=False,
- help = "print Password only of first match, usefull for piping (e.g. in rdesktop)")
-
- parser.add_option_group(group)
-
-
- #parser.add_option( "-l", "--local",
- # action="store_true",
- # dest = "localStore",
- # default=False,
- # help = "do not operate on the configured RCS, only use the local password container")
- #
- #parser.add_option( "--passfile",
- # dest = "passfile",
- # help = "do not use the confgured passfile but the one given here")
-
- group = OptionGroup(parser, "Columns Manipulation")
-
- group.add_option( "--add-columns",
- action="store_true",
- dest = "addColumn",
- default=False,
- help = "Add given Column(s)")
-
- group.add_option( "--delete-columns",
- action = "store_true",
- dest ="deleteColumn",
- default = False,
- help ="Delete Columns given")
-
- parser.add_option_group(group)
-
- (options, args) = parser.parse_args()
-
- if options.widemode:
- self.__outmode = 'wide'
- else:
- self.__outmode = 'line'
-
- if options.addEntry:
- return ["addEntry", { 'args' : args }]
- elif options.deleteEntry:
- return ["deleteEntry", { 'byid' : options.byid, 'args' : args }]
- elif options.editEntry:
- return ["editEntry", { 'byid' : options.byid, 'args' : args }]
-
- elif options.deleteColumn:
- return ["deleteColumn", { 'args' : args }]
- elif options.addColumn:
- return ["addColumn", { 'args' : args }]
-
- return ["printPasswords", { 'byid' : options.byid, 'pwonly' : options.pwonly, 'args' : args }]
- # }}}
-
-# }}}
-
-# EOF
-# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3
Added: branches/spd-ng/src/spdCLI.py
===================================================================
--- branches/spd-ng/src/spdCLI.py (rev 0)
+++ branches/spd-ng/src/spdCLI.py 2011-06-27 20:31:22 UTC (rev 336)
@@ -0,0 +1,261 @@
+#!/usr/bin/python
+
+from optparse import OptionParser, OptionGroup
+from sys import stdout
+from re import sub, search
+
+__version__ = '0.3-alpha'
+
+
+class Cli(object): # {{{
+ """This is the Cli Module.
+ Resistance is futile"""
+ __outmode = None
+ __version__ = '0.3-alpha'
+ _passwordfield = 'Password'
+
+ 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,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:
+ self.__ErrorHandler('printPasswords', 'pwonly selected but more than one result returned')
+ else:
+ print passdict[self._passwordfield][0]
+
+ elif self.__outmode == 'line':
+ length = 0
+ for key in passdict.keys():
+ if length < len(key):
+ length = len(key)
+ print ""
+ for i in range(0,len(passdict.values()[0])):
+ print "__ID".ljust(length) + ':' + str(passdict["__ID"][i])
+ for key in passdict:
+ if key == '__ID':
+ continue
+ if type(passdict[key][i]).__name__ != 'NoneType':
+ print key.ljust(length) + ': ' + sub('\n','\n ' + ' '.ljust(length),passdict[key][i])
+ else:
+ print key.ljust(length) + ': '
+ print ""
+ elif self.__outmode == 'wide':
+ 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 search('\n',str(value)):
+ for partvalue in value.split('\n'):
+ if len(str(partvalue)) > __keylength[key]:
+ __keylength[key] = len(str(partvalue))
+ else:
+ if len(str(value)) > __keylength[key]:
+ __keylength[key] = len(str(value))
+
+ for key in passdict:
+ stdout.write(key.ljust(__keylength[key]) + '|')
+ 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] = ''
+ __count = 0
+ for line in str(passdict[key][i]).split('\n'):
+ if __count > 0:
+ stdout.write('\n' + __space)
+ stdout.write(line.ljust(__keylength[key]) + '|')
+ __count += 1
+ __space = __space + ''.ljust(__keylength[key],'>') + '>'
+ stdout.write('\n')
+ else:
+ self.__ErrorHandler('printPasswords', 'output mode unknown')
+ else:
+ print "No Results found"
+ # }}}
+
+ def editEntry(self,__passdict): # {{{
+ __count = len(__passdict['__ID'])
+ for i in range(0, __count):
+ print '---------------------------'
+ print 'Changing Entry with ID: ' + str(__passdict['__ID'][i]) + '\nENTER for no changes.'
+ for __column in __passdict:
+ __input = ''
+ if __column != '__ID':
+ if __passdict[__column][i] is None:
+ __passdict[__column][i] = ''
+ __input = raw_input(__column + ' (' + str(__passdict[__column][i]) + '): ')
+ if search('^"""',__input):
+ tempinput = sub('^"""','',__input) + '\n'
+ __input = raw_input(' '.ljust(len(__column),'>') + ':')
+ while not search('"""$',__input):
+ tempinput = tempinput + __input + '\n'
+ __input = raw_input(' '.ljust(len(__column),'>') + ':')
+ tempinput = tempinput + sub('"""$','',__input)
+ __passdict[__column][i] = tempinput
+ elif __input != '':
+ __passdict[__column][i] = __input
+ return __passdict
+ # }}}
+
+ def deleteEntry(self,__passdict): # {{{
+ __count = len(__passdict['__ID'])
+ __ids = []
+ print '\n---------------------------'
+ for i in range(0, __count):
+ __input = None
+ while __input != 'y' and __input != 'n':
+ __input = raw_input('Delete Entry with ID ' + str(__passdict['__ID'][i]) + ' (y|n)?')
+ if __input == 'y':
+ __ids.append(__passdict['__ID'][i])
+ return __ids
+ # }}}
+
+ def createEntry(self,columns): # {{{
+ Entry = {}
+ print "Adding a new Entry to our passfile"
+ for column in columns:
+ value = raw_input(column + ': ')
+ if search('^"""',value):
+ tempval = sub('^"""','',value) + '\n'
+ value = raw_input(column + ': ')
+ while not search('"""$',value):
+ tempval = tempval + value + '\n'
+ value = raw_input(column + ': ')
+ tempval = tempval + sub('"""$','',value)
+ value = tempval
+ Entry.update({ column : value })
+ return Entry
+ # }}}
+
+ def parseArgs(self,version): # {{{
+ parser = OptionParser( "%prog [Options] [Keywords]",
+ description = "SPD - Simple Password Displayer - CLI",
+ version = """spdCore """ + version +
+ """\nspdCLI """ + self.__version__,
+ epilog = """With no parameters it will print out everything!
+ Please report Bugs or Feature Request at http://spd.sourceforge.net""")
+
+ parser.add_option( "-a", "--add",
+ action="store_true",
+ dest = "addEntry",
+ default=False,
+ help = "Add an Entry")
+
+ parser.add_option( "-e", "--edit",
+ action = "store_true",
+ dest ="editEntry",
+ help ="Edit given Entries (IDs)")
+
+ parser.add_option( "-d", "--delete",
+ action = "store_true",
+ dest ="deleteEntry",
+ default = False,
+ help ="Delete given Entries")
+
+ group = OptionGroup(parser, "Input Manipulation")
+
+ group.add_option( "--id",
+ action="store_true",
+ dest ="byid",
+ default=False,
+ help ="Handle Input given as ID(s)")
+
+ parser.add_option_group(group)
+
+ group = OptionGroup(parser, "Output Manipulation")
+
+ group.add_option( "-w", "--wide",
+ action="store_true",
+ dest = "widemode",
+ default=False,
+ help = "print output in wide mode (means as a table)")
+
+
+ group.add_option( "-p", "--password-only",
+ action="store_true",
+ dest = "pwonly",
+ default=False,
+ help = "print Password only of first match, usefull for piping (e.g. in rdesktop)")
+
+ parser.add_option_group(group)
+
+
+ #parser.add_option( "-l", "--local",
+ # action="store_true",
+ # dest = "localStore",
+ # default=False,
+ # help = "do not operate on the configured RCS, only use the local password container")
+ #
+ #parser.add_option( "--passfile",
+ # dest = "passfile",
+ # help = "do not use the confgured passfile but the one given here")
+
+ group = OptionGroup(parser, "Columns Manipulation")
+
+ group.add_option( "--add-columns",
+ action="store_true",
+ dest = "addColumn",
+ default=False,
+ help = "Add given Column(s)")
+
+ group.add_option( "--delete-columns",
+ action = "store_true",
+ dest ="deleteColumn",
+ default = False,
+ help ="Delete Columns given")
+
+ parser.add_option_group(group)
+
+ (options, args) = parser.parse_args()
+
+ if options.widemode:
+ self.__outmode = 'wide'
+ else:
+ self.__outmode = 'line'
+
+ if options.addEntry:
+ return ["addEntry", { 'args' : args }]
+ elif options.deleteEntry:
+ return ["deleteEntry", { 'byid' : options.byid, 'args' : args }]
+ elif options.editEntry:
+ return ["editEntry", { 'byid' : options.byid, 'args' : args }]
+
+ elif options.deleteColumn:
+ return ["deleteColumn", { 'args' : args }]
+ elif options.addColumn:
+ return ["addColumn", { 'args' : args }]
+
+ return ["printPasswords", { 'byid' : options.byid, 'pwonly' : options.pwonly, 'args' : args }]
+ # }}}
+
+# }}}
+
+# EOF
+# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3
Modified: branches/spd-ng/src/spdCore.py
===================================================================
--- branches/spd-ng/src/spdCore.py 2011-04-14 19:51:29 UTC (rev 335)
+++ branches/spd-ng/src/spdCore.py 2011-06-27 20:31:22 UTC (rev 336)
@@ -7,7 +7,10 @@
import sqlite3
import re
+import random
+import string
#import spdConfig
+import spdStore
__version__ = '0.3-alpha'
@@ -172,6 +175,20 @@
""")
self.db.commit()
# }}}a
+
+ def makepass(self,size=16): # {{{
+ chars = []
+ chars.extend([i for i in string.ascii_letters])
+ chars.extend([i for i in string.digits])
+ chars.extend([i for i in '\'"!@#$%&*()-_=+[{}]~^,<.>;:/?'])
+
+ passwd = ''
+
+ for i in range(size):
+ passwd += random.choice(chars)
+
+ return passwd
+ # }}}
# EOF
# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3
Copied: branches/spd-ng/src/spdInterface/__init__.py (from rev 335, branches/spd-ng/src/spdInterface.py)
===================================================================
--- branches/spd-ng/src/spdInterface/__init__.py (rev 0)
+++ branches/spd-ng/src/spdInterface/__init__.py 2011-06-27 20:31:22 UTC (rev 336)
@@ -0,0 +1,201 @@
+'''spdInterface Module.
+
+The Modules handles all the exchange between user and spdCore.
+Usage:
+ import spdInterface
+ Interface = spdInterface.Interface()
+ Interface.main()
+
+or force a clientmode with:
+ Interface = spdInterface.Interface('CLI')
+
+if building your own interface, name it spd"whatever" and pass "whatever"
+to the Interface Class. The Module must be in pythons include path.'''
+
+from sys import exit
+import os
+import string
+
+try:
+ import spdConfig
+ import spdDefaults
+ import spdCore
+except ImportError:
+ print '##### ERROR #####'
+ print 'spdInterface: spd not installed. Missing Modules.'
+ exit(2)
+
+__version__ = '0.3-alpha'
+
+class Interface(object): # {{{
+ """The Interface Module.
+ Interface between client and Core."""
+ __spddir = os.path.expanduser('~/.spd/')
+ __version = None
+ __client = None
+ __core = None
+
+ def __init__(self,clientmode=False): # {{{
+ """init procedure"""
+
+ initcheck = self.__startupCheck()
+
+ self.__version = initcheck['version']
+
+ if not clientmode:
+ clientmode = initcheck['clientmode']
+
+ try:
+ __tempclient = __import__('spd' + clientmode)
+ except ImportError:
+ self.__ErrorHandler('__init__', 'clientmode ' + clientmode + ' not available!')
+ else:
+ self.__client = __tempclient.Cli()
+ del __tempclient
+
+ if 'passwordfield' in initcheck:
+ self.__client._passwordfield = initcheck['passwordfield']
+
+ del initcheck
+
+ self.__core = spdCore.Core(ConfigSection='Main')
+ # }}}
+
+ def __ErrorHandler(self,function,message): # {{{
+ """ErrorHandler of the Interface Module.
+ # message: means the \'Exception\' to throw"""
+ print "################################################"
+ print "spdInterface ErrorHandler."
+ print "ERRORFUNCTION: " + function
+ print "ERRORMESSAGE: " + message
+ print "################################################"
+ exit(2)
+ # }}}
+
+ def __startupCheck(self): # {{{
+ """Do initial checks"""
+ __initargs = {}
+
+ if not os.access(self.__spddir, os.F_OK):
+ try:
+ os.mkdir(self.__spddir)
+ except Exception, e:
+ self.__ErrorHandler('__startupCheck','Could not create ' + self.__spddir + ' Exception: ' + str(e))
+
+ __config = spdConfig.Config()
+
+ reval, __initargs['version'] = __config.getConfigVersion(raw=True)
+
+ if reval > 0 and reval < 64:
+ spdDefaults.createDefaultConfig(__config)
+ return self.__startupCheck()
+ elif reval == 64:
+ print 'ConfigVersion not found...setting Default one\n'
+ __input = raw_input('Press any key')
+ __config.setConfigVersion('0.3-alpha')
+ __initargs.update({ 'version' : __config.getConfigVersion() })
+
+ reval, __initargs['clientmode'] = __config.getClientmode(raw=True)
+
+ if reval > 0:
+ print 'Clientmode not found...setting it to CLI\n'
+ __input = raw_input('Press any key')
+ __config.setClientmode('CLI')
+ __initargs.update({ 'clientmode' : __config.getClientmode() })
+
+ reval, __passwordfield = __config.getPasswordfield(raw=True)
+
+ if reval == 0:
+ __initargs.update({ 'passwordfield' : __passwordfield })
+
+ return(__initargs)
+ # }}}
+
+ def __findPasswords(self,args): # {{{
+ """Find the passwords by searchlist/searchstring handed.
+ print the results in CLIENTMODE.
+ # searchlist: optional string or list of keywords to search for."""
+
+ if 'byid' in args:
+ byid = args['byid']
+
+ if 'args' in args:
+ searchString = args['args']
+ else:
+ searchString = '%'
+
+ if type(searchString).__name__ == 'list':
+ searchlist = searchString
+ else:
+ searchlist = string.split(searchString)
+
+ if len(searchlist) == 0:
+ searchlist = ['%',]
+
+ passdict = self.__core.searchEntry(searchlist,byid)
+
+ return passdict
+ # }}}
+
+ def printPasswords(self,args): # {{{
+ passdict = self.__findPasswords(args)
+ self.__client.printPasswords(passdict, args)
+ # }}}
+
+ def deleteEntry(self, args): # {{{
+ __passdict = self.__findPasswords(args)
+
+ if len(__passdict) == 0:
+ self.__ErrorHandler('deleteEntry','No matches found')
+
+ self.__client.printPasswords(__passdict)
+ ids = self.__client.deleteEntry(__passdict)
+ self.__core.delEntry(ids)
+ # }}}
+
+ def editEntry(self,args): # {{{
+ __passdict = self.__findPasswords(args)
+ if len(__passdict) > 0:
+ __newpassdict = self.__client.editEntry(__passdict)
+ self.__core.editEntry(__newpassdict)
+ else:
+ self.__ErrorHandler('editEntry','no matches for ' + str(args["args"]) + 'found')
+ # }}}
+
+ 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)
+ else:
+ self.__ErrorHandler('deleteColumn','column ' + column + ' is not part of the passwordfile')
+ # }}}
+
+ def addColumn(self,args): # {{{
+ if 'args' in args:
+ columns = args['args']
+ else:
+ columns = []
+
+ for column in columns:
+ self.__core.addColumn(column)
+ # }}}
+
+ def addEntry(self, args): # {{{
+ Entry = self.__client.createEntry(self.__core.getColumns(showid=False))
+ self.__core.addEntry(Entry)
+ # }}}
+
+ def main(self): # {{{
+ function, args = self.__client.parseArgs(self.__version)
+ getattr(self, function)(args)
+ # }}}
+
+# }}}
+
+
+# EOF
+# vim:foldmethod=marker:tabstop=3:autoindent:noexpandtab:shiftwidth=3
Deleted: branches/spd-ng/src/spdInterface.py
===================================================================
--- branches/spd-ng/src/spdInterface.py 2011-04-14 19:51:29 UTC (rev 335)
+++ branches/spd-ng/src/spdInterface.py 2011-06-27 20:31:22 UTC (rev 336)
@@ -1,199 +0,0 @@
-'''spdInterface Module.
-
-The Modules handles all the exchange between user and spdCore.
-Usage:
- import spdInterface
- Interface = spdInterface.Interface()
- Interface.main()
-
-or force a clientmode with:
- Interface = spdInterface.Interface('CLI')
-
-if building your own interface, name it spd"whatever" and pass "whatever"
-to the Interface Class. The Module must be in pythons include path.'''
-
-from sys import exit
-import os
-import string
-try:
- import spdConfig
- import spdDefaults
- import spdCore
-except ImportError:
- print 'spd not installed. Missing Modules.'
- exit(2)
-
-__version__ = '0.3-alpha'
-
-class Interface(object): # {{{
- """The Interface Module.
- Interface between client and Core."""
- __spddir = os.path.expanduser('~/.spd/')
- __version = None
- __client = None
- __core = None
-
- def __init__(self,clientmode=False): # {{{
- """init procedure"""
-
- initcheck = self.__startupCheck()
-
- self.__version = initcheck['version']
-
- if not clientmode:
- clientmode = initcheck['clientmode']
-
- try:
- __tempclient = __import__('spd' + clientmode)
- except ImportError:
- self.__ErrorHandler('__init__', 'clientmode ' + clientmode + ' not available!')
- else:
- self.__client = __tempclient.Cli()
- del __tempclient
-
- if 'passwordfield' in initcheck:
- self.__client._passwordfield = initcheck['passwordfield']
-
- del initcheck
-
- self.__core = spdCore.Core(ConfigSection='Main')
- # }}}
-
- def __ErrorHandler(self,function,message): # {{{
- """ErrorHandler of the Interface Module.
- # message: means the \'Exception\' to throw"""
- print "################################################"
- print "spdInterface ErrorHandler."
- print "ERRORFUNCTION: " + function
- print "ERRORMESSAGE: " + message
- print "################################################"
- exit(2)
- # }}}
-
- def __startupCheck(self): # {{{
- """Do initial checks"""
- __initargs = {}
-
- if not os.access(self.__spddir, os.F_OK):
- try:
- os.mkdir(self.__spddir)
- except Exception, e:
- self.__ErrorHandler('__startupCheck','Could not create ' + self.__spddir + ' Exception: ' + str(e))
-
- __config = spdConfig.Config()
-
- reval, __initargs['version'] = __config.getConfigVersion(raw=True)
-
- if reval > 0 and reval < 64:
- spdDefaults.createDefaultConfig(__config)
- return self.__startupCheck()
- elif reval == 64:
- print 'ConfigVersion not found...setting Default one\n'
- __input = raw_input('Press any key')
- __config.setConfigVersion('0.3-alpha')
- __initargs.update({ 'version' : __config.getConfigVersion() })
-
- reval, __initargs['clientmode'] = __config.getClientmode(raw=True)
-
- if reval > 0:
- print 'Clientmode not found...setting it to CLI\n'
- __input = raw_input('Press any key')
- __config.setClientmode('CLI')
- __initargs.update({ 'clientmode' : __config.getClientmode() })
-
- reval, __passwordfield = __config.getPasswordfield(raw=True)
-
- if reval == 0:
- __initargs.update({ 'passwordfield' : __passwordfield })
-
- return(__initargs)
- # }}}
-
- def __findPasswords(self,args): # {{{
- """Find the passwords by searchlist/searchstring handed.
- print the results in CLIENTMODE.
- # searchlist: optional string or list of keywords to search for."""
-
- if 'byid' in args:
- byid = args['byid']
-
- if 'args' in args:
- searchString = args['args']
- else:
- searchString = '%'
-
- if type(searchString).__name__ == 'list':
- searchlist = searchString
- else:
- searchlist = string.split(searchString)
-
- if len(searchlist) == 0:
- searchlist = ['%',]
-
- passdict = self.__core.searchEntry(searchlist,byid)
-
- return passdict
- # }}}
-
- def printPasswords(self,args): # {{{
- passdict = self.__findPasswords(args)
- self.__client.printPasswords(passdict, args)
- # }}}
-
- def deleteEntry(self, args): # {{{
- __passdict = self.__findPasswords(args)
-
- if len(__passdict) == 0:
- self.__ErrorHandler('deleteEntry','No matches found')
-
- self.__client.printPasswords(__passdict)
- ids = self.__client.deleteEntry(__passdict)
- self.__core.delEntry(ids)
- # }}}
-
- def editEntry(self,args): # {{{
- __passdict = self.__findPasswords(args)
- if len(__passdict) > 0:
- __newpassdict = self.__client.editEntry(__passdict)
- self.__core.editEntry(__newpassdict)
- else:
- self.__ErrorHandler('editEntry','no matches for ' + str(args["args"]) + 'found')
- # }}}
-
- 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)
- else:
- self.__ErrorHandler('deleteColumn','column ' + column + ' is not part of the passwordfile')
- # }}}
-
- def addColumn(self,args): # {{{
- if 'args' in args:
- columns = args['args']
- else:
- columns = []
-
- for column in columns:
- self.__core.addColumn(column)
- # }}}
-
- def addEntry(self, args): # {{{
- Entry = self.__client.createEntry(self.__core.getColumns(showid=False))
- self.__core.addEntry(Entry)
- # }}}
-
- def main(self): # {{{
- function, args = self.__client.parseArgs(self.__version)
- getattr(self, function)(args)
- # }}}
-
-# }}}
-
-
-# EOF
-# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3
Added: branches/spd-ng/src/spdStore/__init__.py
===================================================================
--- branches/spd-ng/src/spdStore/__init__.py (rev 0)
+++ branches/spd-ng/src/spdStore/__init__.py 2011-06-27 20:31:22 UTC (rev 336)
@@ -0,0 +1,10 @@
+'''spdStore Module
+
+This Module takes Care of the storage Engine used by SPD.
+Currently Implemented Storage Types are
+- plain
+- gpg
+Call the Store() Class with supplying the used storage type'''
+
+# EOF
+# vim:foldmethod=marker:tabstop=3:autoindent:shiftwidth=3
Deleted: branches/spd-ng/src/spdStore.py
===================================================================
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|