# HG changeset patch # User catherine@cordelia # Date 1243546276 14400 # Node ID 9960bece1e883b5faeed4c0b817b613fb330def8 # Parent c86177642f75a93cf1effcf67ae13f8dbd08580b added defaultdict backport diff -r c86177642f75 -r 9960bece1e88 setup.py --- a/setup.py Thu Apr 30 08:48:06 2009 -0400 +++ b/setup.py Thu May 28 17:31:16 2009 -0400 @@ -9,7 +9,7 @@ Operating System :: OS Independent""".splitlines() setup(name="sqlpython", - version="1.6.5", + version="1.6.5.1", description="Command-line interface to Oracle", long_description="Customizable alternative to Oracle's SQL*PLUS command-line interface", author="Luca Canali", diff -r c86177642f75 -r 9960bece1e88 sqlpython/defaultdict.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sqlpython/defaultdict.py Thu May 28 17:31:16 2009 -0400 @@ -0,0 +1,42 @@ +# implements collections.defaultdict +# Will be unnecessary once Python 2.4 support is dropped +# Thanks to Jason Kirtland for recipe +# http://code.activestate.com/recipes/523034/ + +try: + from collections import defaultdict +except: + class defaultdict(dict): + def __init__(self, default_factory=None, *a, **kw): + if (default_factory is not None and + not hasattr(default_factory, '__call__')): + raise TypeError('first argument must be callable') + dict.__init__(self, *a, **kw) + self.default_factory = default_factory + def __getitem__(self, key): + try: + return dict.__getitem__(self, key) + except KeyError: + return self.__missing__(key) + def __missing__(self, key): + if self.default_factory is None: + raise KeyError(key) + self[key] = value = self.default_factory() + return value + def __reduce__(self): + if self.default_factory is None: + args = tuple() + else: + args = self.default_factory, + return type(self), args, None, None, self.items() + def copy(self): + return self.__copy__() + def __copy__(self): + return type(self)(self.default_factory, self) + def __deepcopy__(self, memo): + import copy + return type(self)(self.default_factory, + copy.deepcopy(self.items())) + def __repr__(self): + return 'defaultdict(%s, %s)' % (self.default_factory, + dict.__repr__(self)) diff -r c86177642f75 -r 9960bece1e88 sqlpython/metadata.py --- a/sqlpython/metadata.py Thu Apr 30 08:48:06 2009 -0400 +++ b/sqlpython/metadata.py Thu May 28 17:31:16 2009 -0400 @@ -1,4 +1,4 @@ -from collections import defaultdict +from defaultdict import defaultdict metaqueries = defaultdict(defaultdict) diff -r c86177642f75 -r 9960bece1e88 sqlpython/mysqlpy.py --- a/sqlpython/mysqlpy.py Thu Apr 30 08:48:06 2009 -0400 +++ b/sqlpython/mysqlpy.py Thu May 28 17:31:16 2009 -0400 @@ -1,5 +1,5 @@ #!/usr/bin/python -# MySqlPy V1.6.5 +# MySqlPy V1.6.5.1 # Author: Luca.Canali@cern.ch # # @@ -14,9 +14,9 @@ class mysqlpy(sqlpyPlus): ''' -MySqlPy V1.6.5 - 'sqlplus in python' +MySqlPy V1.6.5.1 - 'sqlplus in python' Author: Luca.Canali@cern.ch -Rev: 1.6.5, 29-Apr-09 +Rev: 1.6.5.1, 1-May-09 Companion of SqlPython, a python module that reproduces Oracle's command line within python and sqlpyPlus. Major contributions by Catherine Devlin, http://catherinedevlin.blogspot.com @@ -50,6 +50,11 @@ SQL> exit ''' + ''' + def do_greet(self, arg): + print 'Hello, ' + arg + ''' + def __init__(self): sqlpyPlus.__init__(self) self.maxtselctrows = 10 @@ -183,14 +188,9 @@ try: if sys.argv[1][0] != '@': connectstring = sys.argv.pop(1) - try: # attach AS SYSDBA or AS SYSOPER if present - for connectmode in my.connection_modes.keys(): - if connectmode.search(' %s %s' % tuple(sys.argv[1:3])): - for i in (1,2): - connectstring += ' ' + sys.argv.pop(1) - break - except TypeError: - pass + if len(sys.argv) >= 3 and sys.argv[1].lower() == 'as': # attach AS SYSDBA or AS SYSOPER if present + for i in (1,2): + connectstring += ' ' + sys.argv.pop(1) my.do_connect(connectstring) for arg in sys.argv[1:]: if my.onecmd(arg + '\n') == my._STOP_AND_EXIT: @@ -211,4 +211,4 @@ sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() unittest.main() else: - run() \ No newline at end of file + run() diff -r c86177642f75 -r 9960bece1e88 sqlpython/output_templates.py --- a/sqlpython/output_templates.py Thu Apr 30 08:48:06 2009 -0400 +++ b/sqlpython/output_templates.py Thu May 28 17:31:16 2009 -0400 @@ -68,7 +68,8 @@ ${','.join('"%s"' % val for val in row)}{% end %}"""), '\\C': genshi.template.NewTextTemplate(""" -{% for row in rows %}${','.join('"%s"' % val for val in row)}{% end %}""") +{% for row in rows %} +${','.join('"%s"' % val for val in row)}{% end %}""") } diff -r c86177642f75 -r 9960bece1e88 sqlpython/plothandler.py --- a/sqlpython/plothandler.py Thu Apr 30 08:48:06 2009 -0400 +++ b/sqlpython/plothandler.py Thu May 28 17:31:16 2009 -0400 @@ -86,7 +86,7 @@ except ImportError: class Plot(object): def __init__(self, *args, **kwargs): - raise ImportError, 'Must install python-matplotlib and pytyon-numpy to draw plots' + raise ImportError, 'Must install python-tk, python-matplotlib, and python-numpy to draw plots' except Exception, e: class Plot(object): diff -r c86177642f75 -r 9960bece1e88 sqlpython/sqlpyPlus.py --- a/sqlpython/sqlpyPlus.py Thu Apr 30 08:48:06 2009 -0400 +++ b/sqlpython/sqlpyPlus.py Thu May 28 17:31:16 2009 -0400 @@ -797,7 +797,7 @@ flagless_argpieces = [a for a in argpieces if not a.startswith('-')] for (kwd, shortcut) in (('ind', '\\di'), ('schema', '\\dn'), ('tablesp', '\\db'), ('trig', '\\dt'), ('view', '\\dv'), ('cons', '\\dc'), - ('comm', '\\dm'), ('ref', 'ref')): + ('comm', '\\dd'), ('ref', 'ref')): if flagless_argpieces[0].lower().startswith(kwd): return self._show_shortcut(shortcut, argpieces) try: @@ -1351,8 +1351,11 @@ sortdirection = (hasattr(opts, 'reverse') and opts.reverse and 'DESC') or 'ASC' orderby = 'object_type %s, object_name %s' % (sortdirection, sortdirection) if hasattr(opts, 'timesort') and opts.timesort: - orderby = 'last_ddl_time %s, %s' % ( - ('ASC' if hasattr(opts, 'reverse') and opts.reverse else 'DESC'), orderby) + if hasattr(opts, 'reverse') and opts.reverse: + direction = 'DESC' + else: + direction = 'ASC' + orderby = 'last_ddl_time %s, %s' % (direction, orderby) clauses['orderby'] = orderby statement = ''' SELECT object_type || '/' || %(owner)s object_name AS name %(moreColumns)s @@ -1457,7 +1460,7 @@ self._execute("SELECT column_name FROM all_cons_columns WHERE owner = :remote_owner AND constraint_name = :remote_constraint_name ORDER BY position", {'remote_constraint_name': remote_constraint_name, 'remote_owner': remote_owner}) result.append(' (%s)\n' % (",".join(col[0] for col in self.curs.fetchall()))) - self.poutputs('\n'.join(result) + "\n") + self.poutput('\n'.join(result) + "\n") def _test(): import doctest diff -r c86177642f75 -r 9960bece1e88 sqlpython/sqlpython.py --- a/sqlpython/sqlpython.py Thu Apr 30 08:48:06 2009 -0400 +++ b/sqlpython/sqlpython.py Thu May 28 17:31:16 2009 -0400 @@ -1,7 +1,7 @@ # -# SqlPython V1.6.5 +# SqlPython V1.6.5.1 # Author: Luca.Canali@cern.ch, Apr 2006 -# Rev 29-Apr-09 +# Rev 1-May-09 # # A python module to reproduce Oracle's command line 'sqlplus-like' within python # Intended to allow easy customizations and extentions @@ -10,7 +10,7 @@ import cmd2,getpass,binascii,cx_Oracle,re,os import sqlpyPlus, sqlalchemy, pyparsing -__version__ = '1.6.5' +__version__ = '1.6.5.1' class Parser(object): comment_def = "--" + ~ ('-' + pyparsing.CaselessKeyword('begin')) + pyparsing.ZeroOrMore(pyparsing.CharsNotIn("\n"))