comparison sqlpyPlus.py @ 26:bb3fb24b6f5f

settables ironed out
author devlinjs@FA7CZA6N1254998.wrightpatterson.afmc.ds.af.mil
date Wed, 19 Dec 2007 16:10:01 -0500
parents c99853267a44
children ca6f34be3397
comparison
equal deleted inserted replaced
25:c99853267a44 26:bb3fb24b6f5f
545 print e 545 print e
546 import traceback 546 import traceback
547 traceback.print_exc(file=sys.stdout) 547 traceback.print_exc(file=sys.stdout)
548 self.sqlBuffer.append(self.query) 548 self.sqlBuffer.append(self.query)
549 549
550 def showParam(self, param):
551 param = param.strip().lower()
552 if param in self.settable:
553 val = getattr(self, param)
554 print '%s: %s' % (param, str(getattr(self, param)))
555
556 def do_show(self, arg):
557 'Shows value of a (sqlpython, not ORACLE) parameter'
558 arg = arg.strip().lower()
559 if arg:
560 self.showParam(arg)
561 else:
562 for param in self.settable:
563 self.showParam(param)
564
565 def cast(self, current, new):
566 typ = type(current)
567 if typ == bool:
568 new = new.lower()
569 try:
570 if (new=='on') or (new[0] in ('y','t')):
571 return True
572 return False
573 except TypeError:
574 None
575 try:
576 return typ(new)
577 except:
578 print "Problem setting parameter (now %s) to %s; incorrect type?" % (current, new)
579 return current
580
581 def do_set(self, arg):
582 'Sets a (sqlpython, not ORACLE) parameter'
583 try:
584 paramName, val = arg.split(None, 1)
585 except Exception:
586 self.do_show(arg)
587 return
588 paramName = paramName.lower()
589 try:
590 current = getattr(self, paramName)
591 if callable(current):
592 raise NotSettableError
593 except (AttributeError, NotSettableError):
594 self.fail('set %s' % arg)
595 return
596 val = self.cast(current, val.strip(';'))
597 print paramName, ' - was: ', current
598 setattr(self, paramName.lower(), val)
599 print 'now: ', val
600
601 pullflags = flagReader.FlagSet([flagReader.Flag('full')]) 550 pullflags = flagReader.FlagSet([flagReader.Flag('full')])
602 def do_pull(self, arg): 551 def do_pull(self, arg):
603 """Displays source code. 552 """Displays source code.
604 553
605 --full, -f: get dependent objects as well""" 554 --full, -f: get dependent objects as well"""