You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fwi...@us...> - 2009-08-10 17:32:56
|
Revision: 6649 http://jython.svn.sourceforge.net/jython/?rev=6649&view=rev Author: fwierzbicki Date: 2009-08-10 17:32:50 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindents. Modified Paths: -------------- trunk/jython/Lib/test/regrtest.py trunk/jython/Lib/test/test_java_list_delegate.py trunk/jython/Lib/test/test_jy_internals.py trunk/jython/Lib/test/test_timeit.py Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2009-08-10 17:24:15 UTC (rev 6648) +++ trunk/jython/Lib/test/regrtest.py 2009-08-10 17:32:50 UTC (rev 6649) @@ -1577,7 +1577,7 @@ print >>f," ]" finally: f.close() - + if __name__ == '__main__': # Remove regrtest.py's own directory from the module search path. This # prevents relative imports from working, and relative imports will screw Modified: trunk/jython/Lib/test/test_java_list_delegate.py =================================================================== --- trunk/jython/Lib/test/test_java_list_delegate.py 2009-08-10 17:24:15 UTC (rev 6648) +++ trunk/jython/Lib/test/test_java_list_delegate.py 2009-08-10 17:32:50 UTC (rev 6649) @@ -9,10 +9,10 @@ def _perform_op(self, value, op_func): """ Perform an operation - + value - the value to operate on op_func - the function that applies the operation to value - + Returns: the result of calling op_func, OR the exception that was raised in op_func """ @@ -20,7 +20,7 @@ return op_func(value) except Exception, e: return type(e) - + def check_list(self, control, results, initial): for result in results: try: @@ -34,48 +34,48 @@ def _list_op_test(self, initial_value, op_func, check_value): """ Tests a list operation - + Ensures that performing an operation on: - a python list - a java.util.List instance - + givens the same result in both cases """ lists = [list(initial_value), ArrayList(initial_value), Vector(initial_value)] - + results = [self._perform_op(l, op_func) for l in lists] self.check_list(lists[0], lists[1:], initial_value) if check_value or not isinstance(results[0], list): for r in results[1:]: - self.assertEquals(results[0], r) + self.assertEquals(results[0], r) else: self.check_list(results[0], results[1:], initial_value) - + def test_get_integer(self): initial_value = range(0, 5) - + for i in xrange(-7, 7): self._list_op_test(initial_value, lambda xs: xs[i], True) def test_set_integer(self): initial_value = range(0, 5) - + def make_op_func(index): def _f(xs): xs[index] = 100 return _f - + for i in xrange(-7, 7): self._list_op_test(initial_value, make_op_func(i), True) def test_set_slice(self): initial_value = range(0, 10) - + def make_op_func(i, j, k, v): def _f(xs): xs[i:j:k] = v return _f - + for i in xrange(-12, 12): for j in xrange(-12, 12): for k in xrange(-12, 12): @@ -86,44 +86,44 @@ def test_del_integer(self): initial_value = range(0,5) - + def make_op_func(index): def _f(xs): del xs[index] return _f - + for i in xrange(-7, 7): self._list_op_test(initial_value, make_op_func(i), True) def test_del_slice(self): initial_value = range(0,10) - + def make_op_func(i, j, k): def _f(xs): del xs[i:j:k] return _f - + for i in xrange(-12, 12): for j in xrange(-12, 12): for k in xrange(-12, 12): self._list_op_test(initial_value, make_op_func(i, j, k), True) - + def test_len(self): jlist = ArrayList() jlist.addAll(range(0, 10)) - + self.assert_(len(jlist) == 10) - + def test_iter(self): jlist = ArrayList() jlist.addAll(range(0, 10)) - + i = iter(jlist) - + x = list(i) - + self.assert_(x == range(0, 10)) - + def test_override_len(self): class MyList (ArrayList): def __len__(self): @@ -131,20 +131,20 @@ m = MyList() m.addAll(range(0,10)) - + self.assert_(len(m) == 11) def test_override_iter(self): class MyList (ArrayList): def __iter__(self): return iter(self.subList(0, self.size() - 1)); - - + + m = MyList() m.addAll(range(0,10)) i = iter(m) x = list(i) - + self.assert_(x == range(0, 9)) def test_override_getsetdelitem(self): @@ -155,21 +155,21 @@ def __setitem__(self, key, value): return self.set(key, value * 2); - + def __delitem__(self, key): self.add(84) m = MyList() m.addAll(range(0,10)) - + self.assert_(m[1] == 2) self.assert_(m.get(1) == 1) - + m[0] = 3 self.assert_(m.get(0) == 6) self.assert_(m[0] == 12) - + del m[0] self.assert_(m.size() == 11) self.assert_(m.get(10) == 84) Modified: trunk/jython/Lib/test/test_jy_internals.py =================================================================== --- trunk/jython/Lib/test/test_jy_internals.py 2009-08-10 17:24:15 UTC (rev 6648) +++ trunk/jython/Lib/test/test_jy_internals.py 2009-08-10 17:32:50 UTC (rev 6649) @@ -97,9 +97,9 @@ assert e[0] == 0 for d in range(8): - for y in [0,255]: - assert float((v+d)*256+y) == sdv(((v+d)*256+y)*256, e) - assert e[0] == 1 + for y in [0,255]: + assert float((v+d)*256+y) == sdv(((v+d)*256+y)*256, e) + assert e[0] == 1 class ExtraMathTests(unittest.TestCase): def test_epsilon(self): @@ -198,7 +198,7 @@ self = frame.f_locals[frame.f_code.co_varnames[0]] myclass = self.__class__ if type(myclass) == ClassType: - classname = myclass.__name__ + classname = myclass.__name__ else: classname = None @@ -210,14 +210,14 @@ assert (g[0] == "__main__" or g[0] == "test.test_jy_internals") self.assertEquals(g[1], None) self.assertEquals(g[2], "foo") - + class Bar: def baz(self): g = getinfo() assert (g[0] == "__main__" or g[0] == "test.test_jy_internals") assert (g[1] == "Bar") assert (g[2] == "baz") - + g = getinfo() assert (g[0] == "__main__" or g[0] == "test.test_jy_internals") self.assertEquals(g[1], None) @@ -253,4 +253,3 @@ if __name__ == "__main__": test_main() - Modified: trunk/jython/Lib/test/test_timeit.py =================================================================== --- trunk/jython/Lib/test/test_timeit.py 2009-08-10 17:24:15 UTC (rev 6648) +++ trunk/jython/Lib/test/test_timeit.py 2009-08-10 17:32:50 UTC (rev 6649) @@ -7,7 +7,7 @@ # module in the regrtest class TestTimeit(unittest.TestCase): - + def test_oct(self): timing = timeit.Timer('for i in xrange(10): oct(i)', 'gc.enable()').timeit(number=10000) self.assertTrue(timing > 0.) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:24:31
|
Revision: 6648 http://jython.svn.sourceforge.net/jython/?rev=6648&view=rev Author: fwierzbicki Date: 2009-08-10 17:24:15 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindent. Modified Paths: -------------- trunk/jython/Lib/test/test_metaclass_support/simpleclass.py Modified: trunk/jython/Lib/test/test_metaclass_support/simpleclass.py =================================================================== --- trunk/jython/Lib/test/test_metaclass_support/simpleclass.py 2009-08-10 17:23:22 UTC (rev 6647) +++ trunk/jython/Lib/test/test_metaclass_support/simpleclass.py 2009-08-10 17:24:15 UTC (rev 6648) @@ -1,4 +1,3 @@ from metaclass import NoOpMetaClass class TestClass(object): __metaclass__ = NoOpMetaClass - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:23:32
|
Revision: 6647 http://jython.svn.sourceforge.net/jython/?rev=6647&view=rev Author: fwierzbicki Date: 2009-08-10 17:23:22 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Large reindents, mainly 8 space -> 4 space indents. Modified Paths: -------------- trunk/jython/Lib/test/zxjdbc/dbextstest.py trunk/jython/Lib/test/zxjdbc/jndi.py trunk/jython/Lib/test/zxjdbc/runner.py trunk/jython/Lib/test/zxjdbc/sptest.py trunk/jython/Lib/test/zxjdbc/zxtest.py Modified: trunk/jython/Lib/test/zxjdbc/dbextstest.py =================================================================== --- trunk/jython/Lib/test/zxjdbc/dbextstest.py 2009-08-10 17:22:46 UTC (rev 6646) +++ trunk/jython/Lib/test/zxjdbc/dbextstest.py 2009-08-10 17:23:22 UTC (rev 6647) @@ -10,257 +10,257 @@ class dbextsTestCase(runner.SQLTestCase): - def setUp(self): - template = """ - [default] - name=dbexts_test + def setUp(self): + template = """ + [default] + name=dbexts_test - [jdbc] - name=dbexts_test - url=%s - user=%s - pwd=%s - driver=%s - """ + [jdbc] + name=dbexts_test + url=%s + user=%s + pwd=%s + driver=%s + """ - args = {} - for arg in self.factory.arguments: - args[arg[0]] = arg[1] + args = {} + for arg in self.factory.arguments: + args[arg[0]] = arg[1] - template = template % (args["url"], args["usr"], args["pwd"], args["driver"]) - if hasattr(self, "datahandler"): - template += "\tdatahandler=%s" % (self.datahandler.__name__) - template = os.linesep.join(template.split()) + template = template % (args["url"], args["usr"], args["pwd"], args["driver"]) + if hasattr(self, "datahandler"): + template += "\tdatahandler=%s" % (self.datahandler.__name__) + template = os.linesep.join(template.split()) - try: - fp = open(tempfile.mktemp(), "w") - fp.write(template) - fp.close() - self.db = dbexts.dbexts(cfg=fp.name) - self.db.verbose = 0 - for table in ("one", "two"): - try: self.db.raw("drop table %s" % (table)) - except: pass - self.db.raw("create table one (a int, b int, c varchar(32))") - self.db.raw("create table two (a int, b int, c varchar(32))") - finally: - try: - os.remove(fp.name) - except: - pass + try: + fp = open(tempfile.mktemp(), "w") + fp.write(template) + fp.close() + self.db = dbexts.dbexts(cfg=fp.name) + self.db.verbose = 0 + for table in ("one", "two"): + try: self.db.raw("drop table %s" % (table)) + except: pass + self.db.raw("create table one (a int, b int, c varchar(32))") + self.db.raw("create table two (a int, b int, c varchar(32))") + finally: + try: + os.remove(fp.name) + except: + pass - def tearDown(self): - self.db.raw("drop table one") - self.db.raw("drop table two") - self.db.close() + def tearDown(self): + self.db.raw("drop table one") + self.db.raw("drop table two") + self.db.close() - def testChoose(self): - """testing choose()""" - r = dbexts.choose(1, 4, 5) - assert r == 4, "choose failed, expected 4, got %d" % r + def testChoose(self): + """testing choose()""" + r = dbexts.choose(1, 4, 5) + assert r == 4, "choose failed, expected 4, got %d" % r - def _insertInto(self, table, num): - for i in range(0, num): - self.db.raw("insert into %s (a, b, c) values (?, ?, ?)" % (table), [(i, random()*100+i, "%s" % (random()*100+i))]) + def _insertInto(self, table, num): + for i in range(0, num): + self.db.raw("insert into %s (a, b, c) values (?, ?, ?)" % (table), [(i, random()*100+i, "%s" % (random()*100+i))]) - def testSqlFailure(self): - """testing isql with sql exception""" - try: - self.db.isql("select * from __garbage__") - self.fail("expected SQL exception") - except: - pass + def testSqlFailure(self): + """testing isql with sql exception""" + try: + self.db.isql("select * from __garbage__") + self.fail("expected SQL exception") + except: + pass - def testSqlFailureWithBeginCommit(self): - """testing failure with begin/commit""" - failed = 0 - c = self.db.begin() - try: - try: - c.execute("select * from __garbage__") - except: - failed = 1 - finally: - self.db.commit(c) + def testSqlFailureWithBeginCommit(self): + """testing failure with begin/commit""" + failed = 0 + c = self.db.begin() + try: + try: + c.execute("select * from __garbage__") + except: + failed = 1 + finally: + self.db.commit(c) - if not failed: - self.fail("expected SQL exception") + if not failed: + self.fail("expected SQL exception") - def testSqlWithBeginCommit(self): - """testing begin/commit""" - self._insertInto("two", 30) - c = self.db.begin() - c.execute("select * from two") - f = c.fetchall() - c.close() - self.db.commit() - assert len(f) == 30, "expected [30], got [%d]" % (len(f)) + def testSqlWithBeginCommit(self): + """testing begin/commit""" + self._insertInto("two", 30) + c = self.db.begin() + c.execute("select * from two") + f = c.fetchall() + c.close() + self.db.commit() + assert len(f) == 30, "expected [30], got [%d]" % (len(f)) - def testQueryMultipleReturnSets(self): - """testing multiple return sets""" - self._insertInto("two", 30) - h, r = self.db.raw("select * from two where a = ?", [(0,), (3,)]) - assert len(r) == 2, "expected [2], got [%d]" % (len(r)) + def testQueryMultipleReturnSets(self): + """testing multiple return sets""" + self._insertInto("two", 30) + h, r = self.db.raw("select * from two where a = ?", [(0,), (3,)]) + assert len(r) == 2, "expected [2], got [%d]" % (len(r)) - def testUpdateCount(self): - """testing update count""" + def testUpdateCount(self): + """testing update count""" - self._insertInto("one", 45) - self.db.raw("delete from one where a > ?", [(12,)]) - self.assertEquals(32, self.db.updatecount) + self._insertInto("one", 45) + self.db.raw("delete from one where a > ?", [(12,)]) + self.assertEquals(32, self.db.updatecount) - def testQueryWithMaxRows(self): - """testing query with max rows""" + def testQueryWithMaxRows(self): + """testing query with max rows""" - self._insertInto("one", 45) - self.db.raw("select * from one", maxrows=3) - self.assertEquals(3, len(self.db.results)) - self.db.raw("select * from one where a > ?", [(12,)], maxrows=3) - self.assertEquals(3, len(self.db.results)) + self._insertInto("one", 45) + self.db.raw("select * from one", maxrows=3) + self.assertEquals(3, len(self.db.results)) + self.db.raw("select * from one where a > ?", [(12,)], maxrows=3) + self.assertEquals(3, len(self.db.results)) - def testBulkcopy(self): - """testing bcp""" + def testBulkcopy(self): + """testing bcp""" - self._insertInto("two", 3) + self._insertInto("two", 3) - bcp = self.db.bulkcopy("dbexts_test", "two", include=['a']) - assert len(bcp.columns) == 1, "one column should be specified, [%d] found" % (len(bcp.columns)) + bcp = self.db.bulkcopy("dbexts_test", "two", include=['a']) + assert len(bcp.columns) == 1, "one column should be specified, [%d] found" % (len(bcp.columns)) - bcp = self.db.bulkcopy("dbexts_test", "two", include=['a', 'b', 'c'], exclude=['a']) - assert len(bcp.columns) == 2, "expected two columns, found [%d]" % (len(bcp.columns)) - a = filter(lambda x, c=bcp.columns: x in c, ['b', 'c']) - assert a, "expecting ['b', 'c'], found %s" % (str(a)) + bcp = self.db.bulkcopy("dbexts_test", "two", include=['a', 'b', 'c'], exclude=['a']) + assert len(bcp.columns) == 2, "expected two columns, found [%d]" % (len(bcp.columns)) + a = filter(lambda x, c=bcp.columns: x in c, ['b', 'c']) + assert a, "expecting ['b', 'c'], found %s" % (str(a)) - class _executor: - def __init__(self, table, cols): - self.cols = cols - if cols: - self.sql = "insert into %s (%s) values (%s)" % (table, ",".join(self.cols), ",".join(("?",) * len(self.cols))) - else: - self.sql = "insert into %s values (%%s)" % (table) - def execute(self, db, rows, bindings): - assert len(rows) > 0, "must have at least one row" - if self.cols: - sql = self.sql - else: - sql = self.sql % (",".join(("?",) * len(rows[0]))) + class _executor: + def __init__(self, table, cols): + self.cols = cols + if cols: + self.sql = "insert into %s (%s) values (%s)" % (table, ",".join(self.cols), ",".join(("?",) * len(self.cols))) + else: + self.sql = "insert into %s values (%%s)" % (table) + def execute(self, db, rows, bindings): + assert len(rows) > 0, "must have at least one row" + if self.cols: + sql = self.sql + else: + sql = self.sql % (",".join(("?",) * len(rows[0]))) - bcp = self.db.bulkcopy("dbexts_test", "two", include=['a'], executor=_executor) - done = bcp.transfer(self.db) - assert done == 3, "expecting three rows to be handled but not inserted, found [%d]" % (done) + bcp = self.db.bulkcopy("dbexts_test", "two", include=['a'], executor=_executor) + done = bcp.transfer(self.db) + assert done == 3, "expecting three rows to be handled but not inserted, found [%d]" % (done) - bcp = self.db.bulkcopy("dbexts_test", "two", include=['a']) - done = bcp.transfer(self.db) - assert done == 3, "expecting three rows to be inserted, found [%d]" % (done) + bcp = self.db.bulkcopy("dbexts_test", "two", include=['a']) + done = bcp.transfer(self.db) + assert done == 3, "expecting three rows to be inserted, found [%d]" % (done) - bcp = self.db.bulkcopy("dbexts_test", "two", include=['a']) - bcp.rowxfer([200]) - bcp.rowxfer([201]) - bcp.rowxfer([202]) - bcp.rowxfer([203]) - done = bcp.batch() - assert done == 4, "expecting four rows to be inserted, found [%d]" % (done) - bcp.rowxfer([300]) - bcp.rowxfer([401]) - bcp.rowxfer([502]) - bcp.rowxfer([603]) - done = bcp.batch() - assert done == 4, "expecting four rows to be inserted, found [%d]" % (done) - bcp.rowxfer([205]) - bcp.rowxfer([210]) - done = bcp.done() - assert done == 2, "expecting two rows to be inserted, found [%d]" % (done) - assert bcp.total == 10, "expecting 10 rows to be inserted, found [%d]" % (bcp.total) + bcp = self.db.bulkcopy("dbexts_test", "two", include=['a']) + bcp.rowxfer([200]) + bcp.rowxfer([201]) + bcp.rowxfer([202]) + bcp.rowxfer([203]) + done = bcp.batch() + assert done == 4, "expecting four rows to be inserted, found [%d]" % (done) + bcp.rowxfer([300]) + bcp.rowxfer([401]) + bcp.rowxfer([502]) + bcp.rowxfer([603]) + done = bcp.batch() + assert done == 4, "expecting four rows to be inserted, found [%d]" % (done) + bcp.rowxfer([205]) + bcp.rowxfer([210]) + done = bcp.done() + assert done == 2, "expecting two rows to be inserted, found [%d]" % (done) + assert bcp.total == 10, "expecting 10 rows to be inserted, found [%d]" % (bcp.total) - bcp = self.db.bulkcopy("dbexts_test", "two", include=['a']) - done = bcp.transfer(self.db) - assert done == 16, "expecting sixteen rows to be inserted, found [%d]" % (done) + bcp = self.db.bulkcopy("dbexts_test", "two", include=['a']) + done = bcp.transfer(self.db) + assert done == 16, "expecting sixteen rows to be inserted, found [%d]" % (done) - def testTable(self): - """testing dbexts.table(tabname)""" - self.db.table("one") - assert self.db.results is not None, "results were None" - self.assertEquals(3, len(self.db.results)) - self.db.table() - found = 0 - for a in self.db.results: - if a[2].lower() in ("one", "two"): found += 1 - self.assertEquals(2, found) + def testTable(self): + """testing dbexts.table(tabname)""" + self.db.table("one") + assert self.db.results is not None, "results were None" + self.assertEquals(3, len(self.db.results)) + self.db.table() + found = 0 + for a in self.db.results: + if a[2].lower() in ("one", "two"): found += 1 + self.assertEquals(2, found) - def testOut(self): - """testing dbexts.out""" - self.db.verbose = 1 - fp = open(tempfile.mktemp(), "w") - try: - self.db.out = fp - self.db.raw("insert into one (a, b) values (?, ?)", [(1, 2), (3, 4)]) - self.db.isql("select * from one") - self.db.verbose = 0 - fp.close() - fp = open(fp.name, "r") - data = fp.read() - assert len(data), "expected file to contain output" - finally: - fp.close() - os.remove(fp.name) + def testOut(self): + """testing dbexts.out""" + self.db.verbose = 1 + fp = open(tempfile.mktemp(), "w") + try: + self.db.out = fp + self.db.raw("insert into one (a, b) values (?, ?)", [(1, 2), (3, 4)]) + self.db.isql("select * from one") + self.db.verbose = 0 + fp.close() + fp = open(fp.name, "r") + data = fp.read() + assert len(data), "expected file to contain output" + finally: + fp.close() + os.remove(fp.name) - def testResultSetWrapper(self): - """testing result set wrapper""" - from dbexts import ResultSet - self._insertInto("two", 30) - h, r = self.db.raw("select * from two where a in (?, ?, ?, ?) order by a", [(12,15,17,8)]) - assert len(r) == 4, "expected [4], got [%d]" % (len(r)) - rs = ResultSet(map(lambda x: x[0], h), r) - assert len(rs[0]) == 3, "expected [3], got [%d]" % (len(rs[0])) - assert rs[0]['a'] == 8, "expected [8], got [%s]" % (rs[0]['a']) - assert rs[0]['A'] == 8, "expected [8], got [%s]" % (rs[0]['A']) - assert len(rs[0]['b':]) == 2, "expected [2], got [%s]" % (len(rs[0]['b':])) - assert len(rs[0]['a':'b']) == 1, "expected [1], got [%s]" % (len(rs[0]['a':'b'])) + def testResultSetWrapper(self): + """testing result set wrapper""" + from dbexts import ResultSet + self._insertInto("two", 30) + h, r = self.db.raw("select * from two where a in (?, ?, ?, ?) order by a", [(12,15,17,8)]) + assert len(r) == 4, "expected [4], got [%d]" % (len(r)) + rs = ResultSet(map(lambda x: x[0], h), r) + assert len(rs[0]) == 3, "expected [3], got [%d]" % (len(rs[0])) + assert rs[0]['a'] == 8, "expected [8], got [%s]" % (rs[0]['a']) + assert rs[0]['A'] == 8, "expected [8], got [%s]" % (rs[0]['A']) + assert len(rs[0]['b':]) == 2, "expected [2], got [%s]" % (len(rs[0]['b':])) + assert len(rs[0]['a':'b']) == 1, "expected [1], got [%s]" % (len(rs[0]['a':'b'])) - def testMultipleResultSetConcatentation(self): - """testing multiple result sets with some resulting in None""" - self._insertInto("two", 30) - # first is non None - h, r = self.db.raw("select * from two where a = ?", [(12,),(8001,),(15,),(17,),(8,),(9001,)]) - assert len(r) == 4, "expected [4], got [%d]" % (len(r)) - # first is None - h, r = self.db.raw("select * from two where a = ?", [(1200,),(8001,),(15,),(17,),(8,),(9001,)]) - assert len(r) == 3, "expected [3], got [%d]" % (len(r)) + def testMultipleResultSetConcatentation(self): + """testing multiple result sets with some resulting in None""" + self._insertInto("two", 30) + # first is non None + h, r = self.db.raw("select * from two where a = ?", [(12,),(8001,),(15,),(17,),(8,),(9001,)]) + assert len(r) == 4, "expected [4], got [%d]" % (len(r)) + # first is None + h, r = self.db.raw("select * from two where a = ?", [(1200,),(8001,),(15,),(17,),(8,),(9001,)]) + assert len(r) == 3, "expected [3], got [%d]" % (len(r)) - def testBulkcopyWithDynamicColumns(self): - """testing bcp with dynamic column names""" + def testBulkcopyWithDynamicColumns(self): + """testing bcp with dynamic column names""" - self.testBulkcopy() + self.testBulkcopy() - bcp = self.db.bulkcopy("dbexts_test", "two", exclude=['a']) - assert len(bcp.columns) == 2, "expected two columns, found [%d]" % (len(bcp.columns)) - a = filter(lambda x, c=bcp.columns: x in c, ['b', 'c']) - assert a == ['b', 'c'], "expecting ['b', 'c'], found %s" % (str(a)) + bcp = self.db.bulkcopy("dbexts_test", "two", exclude=['a']) + assert len(bcp.columns) == 2, "expected two columns, found [%d]" % (len(bcp.columns)) + a = filter(lambda x, c=bcp.columns: x in c, ['b', 'c']) + assert a == ['b', 'c'], "expecting ['b', 'c'], found %s" % (str(a)) - bcp = self.db.bulkcopy("dbexts_test", "two") - done = bcp.transfer(self.db) - assert done == 32, "expecting thirty two rows to be inserted, found [%d]" % (done) + bcp = self.db.bulkcopy("dbexts_test", "two") + done = bcp.transfer(self.db) + assert done == 32, "expecting thirty two rows to be inserted, found [%d]" % (done) - def testAutocommit(self): - """testing the autocommit functionality""" - for u in (0, 1): - self.db.autocommit = u - try: - self.db.isql("select * from one") - except Exception, e: - fail("failed autocommit query with u=[%d], v=[%d]" % (u, v)) - for v in (0, 1): - self.db.db.autocommit = v - try: - self.db.isql("select * from one") - except Exception, e: - self.fail("failed autocommit query with u=[%d], v=[%d]" % (u, v)) + def testAutocommit(self): + """testing the autocommit functionality""" + for u in (0, 1): + self.db.autocommit = u + try: + self.db.isql("select * from one") + except Exception, e: + fail("failed autocommit query with u=[%d], v=[%d]" % (u, v)) + for v in (0, 1): + self.db.db.autocommit = v + try: + self.db.isql("select * from one") + except Exception, e: + self.fail("failed autocommit query with u=[%d], v=[%d]" % (u, v)) - def testPrepare(self): - """testing the handling of a prepared statement""" - self._insertInto("one", 10) - p = self.db.prepare("select * from one") - self.db.isql(p) - self.db.isql(p) - p.close() - assert p.closed + def testPrepare(self): + """testing the handling of a prepared statement""" + self._insertInto("one", 10) + p = self.db.prepare("select * from one") + self.db.isql(p) + self.db.isql(p) + p.close() + assert p.closed Modified: trunk/jython/Lib/test/zxjdbc/jndi.py =================================================================== --- trunk/jython/Lib/test/zxjdbc/jndi.py 2009-08-10 17:22:46 UTC (rev 6646) +++ trunk/jython/Lib/test/zxjdbc/jndi.py 2009-08-10 17:23:22 UTC (rev 6647) @@ -22,12 +22,12 @@ ctx = InitialContext(env) try: - try: - ctx.bind("/jdbc/mysqldb", ds) - except NameAlreadyBoundException, e: - ctx.unbind("/jdbc/mysqldb") - ctx.bind("/jdbc/mysqldb", ds) + try: + ctx.bind("/jdbc/mysqldb", ds) + except NameAlreadyBoundException, e: + ctx.unbind("/jdbc/mysqldb") + ctx.bind("/jdbc/mysqldb", ds) finally: - ctx.close() + ctx.close() print "bound [%s] at /jdbc/mysqldb" % (ds) Modified: trunk/jython/Lib/test/zxjdbc/runner.py =================================================================== --- trunk/jython/Lib/test/zxjdbc/runner.py 2009-08-10 17:22:46 UTC (rev 6646) +++ trunk/jython/Lib/test/zxjdbc/runner.py 2009-08-10 17:23:22 UTC (rev 6647) @@ -18,187 +18,187 @@ import xmllib, __builtin__, re def __imp__(module, attr=None): - if attr: - j = __import__(module, globals(), locals()) - return getattr(j, attr) - else: - last = module.split(".")[-1] - return __import__(module, globals(), locals(), last) + if attr: + j = __import__(module, globals(), locals()) + return getattr(j, attr) + else: + last = module.split(".")[-1] + return __import__(module, globals(), locals(), last) class Factory: - def __init__(self, classname, method): - self.classname = classname - self.method = method - self.arguments = [] - self.keywords = {} + def __init__(self, classname, method): + self.classname = classname + self.method = method + self.arguments = [] + self.keywords = {} class Testcase: - def __init__(self, frm, impt): - self.frm = frm - self.impt = impt - self.ignore = [] + def __init__(self, frm, impt): + self.frm = frm + self.impt = impt + self.ignore = [] class Test: - def __init__(self, name, os): - self.name = name - self.os = os - self.factory = None - self.tests = [] + def __init__(self, name, os): + self.name = name + self.os = os + self.factory = None + self.tests = [] class Vendor: - def __init__(self, name, datahandler=None): - self.name = name - self.scroll = None - self.datahandler = datahandler - self.tests = [] - self.tables = {} + def __init__(self, name, datahandler=None): + self.name = name + self.scroll = None + self.datahandler = datahandler + self.tests = [] + self.tables = {} class ConfigParser(xmllib.XMLParser): - """ - A simple XML parser for the config file. - """ - def __init__(self, **kw): - apply(xmllib.XMLParser.__init__, (self,), kw) - self.vendors = [] - self.table_stack = [] - self.re_var = re.compile(r"\${(.*?)}") + """ + A simple XML parser for the config file. + """ + def __init__(self, **kw): + apply(xmllib.XMLParser.__init__, (self,), kw) + self.vendors = [] + self.table_stack = [] + self.re_var = re.compile(r"\${(.*?)}") - def vendor(self): - assert len(self.vendors) > 0, "no vendors" - return self.vendors[-1] + def vendor(self): + assert len(self.vendors) > 0, "no vendors" + return self.vendors[-1] - def test(self): - v = self.vendor() - assert len(v.tests) > 0, "no tests" - return v.tests[-1] + def test(self): + v = self.vendor() + assert len(v.tests) > 0, "no tests" + return v.tests[-1] - def factory(self): - c = self.test() - assert c.factory, "no factory" - return c.factory + def factory(self): + c = self.test() + assert c.factory, "no factory" + return c.factory - def testcase(self): - s = self.test() - assert len(s.tests) > 0, "no testcases" - return s.tests[-1] + def testcase(self): + s = self.test() + assert len(s.tests) > 0, "no testcases" + return s.tests[-1] - def value(self, value): - def repl(sub): - from java.lang import System - return System.getProperty(sub.group(1), sub.group(1)) - value = self.re_var.sub(repl, value) - return value + def value(self, value): + def repl(sub): + from java.lang import System + return System.getProperty(sub.group(1), sub.group(1)) + value = self.re_var.sub(repl, value) + return value - def start_vendor(self, attrs): - if attrs.has_key('datahandler'): - v = Vendor(attrs['name'], attrs['datahandler']) - else: - v = Vendor(attrs['name']) - if attrs.has_key('scroll'): - v.scroll = attrs['scroll'] - self.vendors.append(v) + def start_vendor(self, attrs): + if attrs.has_key('datahandler'): + v = Vendor(attrs['name'], attrs['datahandler']) + else: + v = Vendor(attrs['name']) + if attrs.has_key('scroll'): + v.scroll = attrs['scroll'] + self.vendors.append(v) - def start_test(self, attrs): - v = self.vendor() - c = Test(attrs['name'], attrs['os']) - v.tests.append(c) + def start_test(self, attrs): + v = self.vendor() + c = Test(attrs['name'], attrs['os']) + v.tests.append(c) - def start_factory(self, attrs): - c = self.test() - f = Factory(attrs['class'], attrs['method']) - c.factory = f + def start_factory(self, attrs): + c = self.test() + f = Factory(attrs['class'], attrs['method']) + c.factory = f - def start_argument(self, attrs): - f = self.factory() - if attrs.has_key('type'): - f.arguments.append((attrs['name'], getattr(__builtin__, attrs['type'])(self.value(attrs['value'])))) - else: - f.arguments.append((attrs['name'], self.value(attrs['value']))) + def start_argument(self, attrs): + f = self.factory() + if attrs.has_key('type'): + f.arguments.append((attrs['name'], getattr(__builtin__, attrs['type'])(self.value(attrs['value'])))) + else: + f.arguments.append((attrs['name'], self.value(attrs['value']))) - def start_keyword(self, attrs): - f = self.factory() - if attrs.has_key('type'): - f.keywords[attrs['name']] = getattr(__builtin__, attrs['type'])(self.value(attrs['value'])) - else: - f.keywords[attrs['name']] = self.value(attrs['value']) + def start_keyword(self, attrs): + f = self.factory() + if attrs.has_key('type'): + f.keywords[attrs['name']] = getattr(__builtin__, attrs['type'])(self.value(attrs['value'])) + else: + f.keywords[attrs['name']] = self.value(attrs['value']) - def start_ignore(self, attrs): - t = self.testcase() - t.ignore.append(attrs['name']) + def start_ignore(self, attrs): + t = self.testcase() + t.ignore.append(attrs['name']) - def start_testcase(self, attrs): - c = self.test() - c.tests.append(Testcase(attrs['from'], attrs['import'])) + def start_testcase(self, attrs): + c = self.test() + c.tests.append(Testcase(attrs['from'], attrs['import'])) - def start_table(self, attrs): - self.table_stack.append((attrs['ref'], attrs['name'])) + def start_table(self, attrs): + self.table_stack.append((attrs['ref'], attrs['name'])) - def end_table(self): - del self.table_stack[-1] + def end_table(self): + del self.table_stack[-1] - def handle_data(self, data): - if len(self.table_stack): - ref, tabname = self.table_stack[-1] - self.vendor().tables[ref] = (tabname, data.strip()) + def handle_data(self, data): + if len(self.table_stack): + ref, tabname = self.table_stack[-1] + self.vendor().tables[ref] = (tabname, data.strip()) class SQLTestCase(unittest.TestCase): - """ - Base testing class. It contains the list of table and factory information - to run any tests. - """ - def __init__(self, name, vendor, factory): - unittest.TestCase.__init__(self, name) - self.vendor = vendor - self.factory = factory - if self.vendor.datahandler: - self.datahandler = __imp__(self.vendor.datahandler) + """ + Base testing class. It contains the list of table and factory information + to run any tests. + """ + def __init__(self, name, vendor, factory): + unittest.TestCase.__init__(self, name) + self.vendor = vendor + self.factory = factory + if self.vendor.datahandler: + self.datahandler = __imp__(self.vendor.datahandler) - def table(self, name): - return self.vendor.tables[name] + def table(self, name): + return self.vendor.tables[name] - def has_table(self, name): - return self.vendor.tables.has_key(name) + def has_table(self, name): + return self.vendor.tables.has_key(name) def make_suite(vendor, testcase, factory, mask=None): - clz = __imp__(testcase.frm, testcase.impt) - caseNames = filter(lambda x, i=testcase.ignore: x not in i, unittest.getTestCaseNames(clz, "test")) - if mask is not None: - caseNames = filter(lambda x, mask=mask: x == mask, caseNames) - tests = [clz(caseName, vendor, factory) for caseName in caseNames] - return unittest.TestSuite(tests) + clz = __imp__(testcase.frm, testcase.impt) + caseNames = filter(lambda x, i=testcase.ignore: x not in i, unittest.getTestCaseNames(clz, "test")) + if mask is not None: + caseNames = filter(lambda x, mask=mask: x == mask, caseNames) + tests = [clz(caseName, vendor, factory) for caseName in caseNames] + return unittest.TestSuite(tests) def test(vendors, include=None, mask=None): - for vendor in vendors: - if not include or vendor.name in include: - print - print "testing [%s]" % (vendor.name) - for test in vendor.tests: - if not test.os or test.os == os.name: - for testcase in test.tests: - suite = make_suite(vendor, testcase, test.factory, mask) - unittest.TextTestRunner().run(suite) - else: - print - print "skipping [%s]" % (vendor.name) + for vendor in vendors: + if not include or vendor.name in include: + print + print "testing [%s]" % (vendor.name) + for test in vendor.tests: + if not test.os or test.os == os.name: + for testcase in test.tests: + suite = make_suite(vendor, testcase, test.factory, mask) + unittest.TextTestRunner().run(suite) + else: + print + print "skipping [%s]" % (vendor.name) if __name__ == '__main__': - import sys, getopt + import sys, getopt - try: - opts, args = getopt.getopt(sys.argv[1:], "t:", []) - except getopt.error, msg: - print "%s -t [testmask] <vendor>[,<vendor>]" - sys.exit(0) + try: + opts, args = getopt.getopt(sys.argv[1:], "t:", []) + except getopt.error, msg: + print "%s -t [testmask] <vendor>[,<vendor>]" + sys.exit(0) - mask = None - for a in opts: - opt, arg = a - if opt == '-t': - mask = arg + mask = None + for a in opts: + opt, arg = a + if opt == '-t': + mask = arg - configParser = ConfigParser() - fp = open(args[0], "r") - configParser.feed(fp.read()) - fp.close() - test(configParser.vendors, args[1:], mask=mask) - sys.exit(0) + configParser = ConfigParser() + fp = open(args[0], "r") + configParser.feed(fp.read()) + fp.close() + test(configParser.vendors, args[1:], mask=mask) + sys.exit(0) Modified: trunk/jython/Lib/test/zxjdbc/sptest.py =================================================================== --- trunk/jython/Lib/test/zxjdbc/sptest.py 2009-08-10 17:22:46 UTC (rev 6646) +++ trunk/jython/Lib/test/zxjdbc/sptest.py 2009-08-10 17:23:22 UTC (rev 6647) @@ -9,211 +9,211 @@ class OracleSPTest(zxCoreTestCase): - def setUp(self): - zxCoreTestCase.setUp(self) + def setUp(self): + zxCoreTestCase.setUp(self) - c = self.cursor() + c = self.cursor() - try: - try: - c.execute("drop table sptest") - except: - self.db.rollback() - try: - c.execute("create table sptest (x varchar2(20))") - c.execute("create or replace procedure procnone is begin insert into sptest values ('testing'); end;") - c.execute("create or replace procedure procin (y in varchar2) is begin insert into sptest values (y); end;") - c.execute("create or replace procedure procout (y out varchar2) is begin y := 'tested'; end;") - c.execute("create or replace procedure procinout (y out varchar2, z in varchar2) is begin insert into sptest values (z); y := 'tested'; end;") - c.execute("create or replace function funcnone return varchar2 is begin return 'tested'; end;") - c.execute("create or replace function funcin (y varchar2) return varchar2 is begin return y || y; end;") - c.execute("create or replace function funcout (y out varchar2) return varchar2 is begin y := 'tested'; return 'returned'; end;") - self.db.commit() - except: - self.db.rollback() - self.fail("procedure creation failed") + try: + try: + c.execute("drop table sptest") + except: + self.db.rollback() + try: + c.execute("create table sptest (x varchar2(20))") + c.execute("create or replace procedure procnone is begin insert into sptest values ('testing'); end;") + c.execute("create or replace procedure procin (y in varchar2) is begin insert into sptest values (y); end;") + c.execute("create or replace procedure procout (y out varchar2) is begin y := 'tested'; end;") + c.execute("create or replace procedure procinout (y out varchar2, z in varchar2) is begin insert into sptest values (z); y := 'tested'; end;") + c.execute("create or replace function funcnone return varchar2 is begin return 'tested'; end;") + c.execute("create or replace function funcin (y varchar2) return varchar2 is begin return y || y; end;") + c.execute("create or replace function funcout (y out varchar2) return varchar2 is begin y := 'tested'; return 'returned'; end;") + self.db.commit() + except: + self.db.rollback() + self.fail("procedure creation failed") - self.proc_errors("PROC") - self.proc_errors("FUNC") + self.proc_errors("PROC") + self.proc_errors("FUNC") - finally: - c.close() + finally: + c.close() - def tearDown(self): - zxCoreTestCase.tearDown(self) + def tearDown(self): + zxCoreTestCase.tearDown(self) - def proc_errors(self, name): - c = self.cursor() - try: - c.execute("select * from user_errors where name like '%s%%'" % (name.upper())) - errors = c.fetchall() - try: - assert not errors, "found errors" - except AssertionError, e: - print "printing errors:" - for a in errors: - print a - raise e - finally: - c.close() + def proc_errors(self, name): + c = self.cursor() + try: + c.execute("select * from user_errors where name like '%s%%'" % (name.upper())) + errors = c.fetchall() + try: + assert not errors, "found errors" + except AssertionError, e: + print "printing errors:" + for a in errors: + print a + raise e + finally: + c.close() - def testCursor(self): - c = self.cursor() - try: + def testCursor(self): + c = self.cursor() + try: - c.execute("insert into sptest values ('a')") - c.execute("insert into sptest values ('b')") - c.execute("insert into sptest values ('c')") - c.execute("insert into sptest values ('d')") - c.execute("insert into sptest values ('e')") + c.execute("insert into sptest values ('a')") + c.execute("insert into sptest values ('b')") + c.execute("insert into sptest values ('c')") + c.execute("insert into sptest values ('d')") + c.execute("insert into sptest values ('e')") - c.execute(""" - CREATE OR REPLACE PACKAGE types - AS - TYPE ref_cursor IS REF CURSOR; - END; - """) + c.execute(""" + CREATE OR REPLACE PACKAGE types + AS + TYPE ref_cursor IS REF CURSOR; + END; + """) - c.execute(""" - CREATE OR REPLACE FUNCTION funccur(v_x IN VARCHAR) - RETURN types.ref_cursor - AS - funccur_cursor types.ref_cursor; - BEGIN - OPEN funccur_cursor FOR - SELECT x FROM sptest WHERE x < v_x; - RETURN funccur_cursor; - END; - """) + c.execute(""" + CREATE OR REPLACE FUNCTION funccur(v_x IN VARCHAR) + RETURN types.ref_cursor + AS + funccur_cursor types.ref_cursor; + BEGIN + OPEN funccur_cursor FOR + SELECT x FROM sptest WHERE x < v_x; + RETURN funccur_cursor; + END; + """) - self.proc_errors("funccur") + self.proc_errors("funccur") - c.callproc("funccur", ("z",)) - data = c.fetchall() - self.assertEquals(5, len(data)) - c.callproc("funccur", ("c",)) - data = c.fetchall() - self.assertEquals(2, len(data)) + c.callproc("funccur", ("z",)) + data = c.fetchall() + self.assertEquals(5, len(data)) + c.callproc("funccur", ("c",)) + data = c.fetchall() + self.assertEquals(2, len(data)) - finally: - c.close() + finally: + c.close() - def testProcin(self): - c = self.cursor() - try: - params = ["testProcin"] - c.callproc("procin", params) - self.assertEquals([], c.fetchall()) - c.execute("select * from sptest") - self.assertEquals(1, len(c.fetchall())) - finally: - c.close() + def testProcin(self): + c = self.cursor() + try: + params = ["testProcin"] + c.callproc("procin", params) + self.assertEquals([], c.fetchall()) + c.execute("select * from sptest") + self.assertEquals(1, len(c.fetchall())) + finally: + c.close() - def testProcinout(self): - c = self.cursor() - try: - params = [None, "testing"] - c.callproc("procinout", params) - data = c.fetchone() - assert data is None, "data was not None" - c.execute("select * from sptest") - data = c.fetchone() - self.assertEquals("testing", data[0]) - self.assertEquals("tested", params[0]) - finally: - c.close() + def testProcinout(self): + c = self.cursor() + try: + params = [None, "testing"] + c.callproc("procinout", params) + data = c.fetchone() + assert data is None, "data was not None" + c.execute("select * from sptest") + data = c.fetchone() + self.assertEquals("testing", data[0]) + self.assertEquals("tested", params[0]) + finally: + c.close() - def testFuncnone(self): - c = self.cursor() - try: - c.callproc("funcnone") - data = c.fetchone() - assert data is not None, "data was None" - self.assertEquals(1, len(data)) - self.assertEquals("tested", data[0]) - finally: - c.close() + def testFuncnone(self): + c = self.cursor() + try: + c.callproc("funcnone") + data = c.fetchone() + assert data is not None, "data was None" + self.assertEquals(1, len(data)) + self.assertEquals("tested", data[0]) + finally: + c.close() - def testFuncin(self): - c = self.cursor() - try: - params = ["testing"] - c.callproc("funcin", params) - self.assertEquals(1, c.rowcount) - data = c.fetchone() - assert data is not None, "data was None" - self.assertEquals(1, len(data)) - self.assertEquals("testingtesting", data[0]) - finally: - c.close() + def testFuncin(self): + c = self.cursor() + try: + params = ["testing"] + c.callproc("funcin", params) + self.assertEquals(1, c.rowcount) + data = c.fetchone() + assert data is not None, "data was None" + self.assertEquals(1, len(data)) + self.assertEquals("testingtesting", data[0]) + finally: + c.close() - def testCallingWithKws(self): - c = self.cursor() - try: - params = ["testing"] - c.callproc("funcin", params=params) - self.assertEquals(1, c.rowcount) - data = c.fetchone() - assert data is not None, "data was None" - self.assertEquals(1, len(data)) - self.assertEquals("testingtesting", data[0]) - finally: - c.close() + def testCallingWithKws(self): + c = self.cursor() + try: + params = ["testing"] + c.callproc("funcin", params=params) + self.assertEquals(1, c.rowcount) + data = c.fetchone() + assert data is not None, "data was None" + self.assertEquals(1, len(data)) + self.assertEquals("testingtesting", data[0]) + finally: + c.close() - def testFuncout(self): - c = self.cursor() - try: - params = [None] - c.callproc("funcout", params) - data = c.fetchone() - assert data is not None, "data was None" - self.assertEquals(1, len(data)) - self.assertEquals("returned", data[0]) - self.assertEquals("tested", params[0].strip()) - finally: - c.close() + def testFuncout(self): + c = self.cursor() + try: + params = [None] + c.callproc("funcout", params) + data = c.fetchone() + assert data is not None, "data was None" + self.assertEquals(1, len(data)) + self.assertEquals("returned", data[0]) + self.assertEquals("tested", params[0].strip()) + finally: + c.close() - def testMultipleFetch(self): - """testing the second fetch call to a callproc() is None""" - c = self.cursor() - try: - c.callproc("funcnone") - data = c.fetchone() - assert data is not None, "data was None" - data = c.fetchone() - assert data is None, "data was not None" - finally: - c.close() + def testMultipleFetch(self): + """testing the second fetch call to a callproc() is None""" + c = self.cursor() + try: + c.callproc("funcnone") + data = c.fetchone() + assert data is not None, "data was None" + data = c.fetchone() + assert data is None, "data was not None" + finally: + c.close() class SQLServerSPTest(zxCoreTestCase): - def testProcWithResultSet(self): - c = self.cursor() + def testProcWithResultSet(self): + c = self.cursor() + try: + for a in (("table", "sptest"), ("procedure", "sp_proctest")): try: - for a in (("table", "sptest"), ("procedure", "sp_proctest")): - try: - c.execute("drop %s %s" % (a)) - except: - pass + c.execute("drop %s %s" % (a)) + except: + pass - c.execute("create table sptest (a int, b varchar(32))") - c.execute("insert into sptest values (1, 'hello')") - c.execute("insert into sptest values (2, 'there')") - c.execute("insert into sptest values (3, 'goodbye')") + c.execute("create table sptest (a int, b varchar(32))") + c.execute("insert into sptest values (1, 'hello')") + c.execute("insert into sptest values (2, 'there')") + c.execute("insert into sptest values (3, 'goodbye')") - c.execute(""" create procedure sp_proctest (@A int) as select a, b from sptest where a <= @A """) - self.db.commit() + c.execute(""" create procedure sp_proctest (@A int) as select a, b from sptest where a <= @A """) + self.db.commit() - c.callproc("sp_proctest", (2,)) - data = c.fetchall() - self.assertEquals(2, len(data)) - self.assertEquals(2, len(c.description)) - assert c.nextset() is not None, "expected an additional result set" - data = c.fetchall() - self.assertEquals(1, len(data)) - self.assertEquals(1, len(c.description)) - finally: - c.close() + c.callproc("sp_proctest", (2,)) + data = c.fetchall() + self.assertEquals(2, len(data)) + self.assertEquals(2, len(c.description)) + assert c.nextset() is not None, "expected an additional result set" + data = c.fetchall() + self.assertEquals(1, len(data)) + self.assertEquals(1, len(c.description)) + finally: + c.close() # def testSalesByCategory(self): # c = self.cursor() Modified: trunk/jython/Lib/test/zxjdbc/zxtest.py =================================================================== --- trunk/jython/Lib/test/zxjdbc/zxtest.py 2009-08-10 17:22:46 UTC (rev 6646) +++ trunk/jython/Lib/test/zxjdbc/zxtest.py 2009-08-10 17:23:22 UTC (rev 6647) @@ -12,1231 +12,1231 @@ class zxCoreTestCase(runner.SQLTestCase): - def setUp(self): - runner.SQLTestCase.setUp(self) - self.db = self.connect() - self.db.autocommit = 0 + def setUp(self): + runner.SQLTestCase.setUp(self) + self.db = self.connect() + self.db.autocommit = 0 - def tearDown(self): - self.db.close() - runner.SQLTestCase.tearDown(self) + def tearDown(self): + self.db.close() + runner.SQLTestCase.tearDown(self) - def connect(self): - factory = runner.__imp__(self.factory.classname) - args = map(lambda x: x[1], self.factory.arguments) - connect = getattr(factory, self.factory.method) - return apply(connect, args, self.factory.keywords) + def connect(self): + factory = runner.__imp__(self.factory.classname) + args = map(lambda x: x[1], self.factory.arguments) + connect = getattr(factory, self.factory.method) + return apply(connect, args, self.factory.keywords) - def cursor(self, *args, **kws): - c = apply(self.db.cursor, args, kws) - if hasattr(self, "datahandler"): - c.datahandler = self.datahandler(c.datahandler) - return c + def cursor(self, *args, **kws): + c = apply(self.db.cursor, args, kws) + if hasattr(self, "datahandler"): + c.datahandler = self.datahandler(c.datahandler) + return c class zxJDBCTestCase(zxCoreTestCase): - def setUp(self): - zxCoreTestCase.setUp(self) + def setUp(self): + zxCoreTestCase.setUp(self) - c = self.cursor() + c = self.cursor() - try: - c.execute("drop table zxtesting") - self.db.commit() - except: - self.db.rollback() + try: + c.execute("drop table zxtesting") + self.db.commit() + except: + self.db.rollback() - try: - c.execute("create table zxtesting (id int not null, name varchar(32), state varchar(32), primary key (id))") - self.db.commit() - c.execute("insert into zxtesting (id, name, state) values (1, 'test0', 'il')") - c.execute("insert into zxtesting (id, name, state) values (2, 'test1', 'wi')") - c.execute("insert into zxtesting (id, name, state) values (3, 'test2', 'tx')") - c.execute("insert into zxtesting (id, name, state) values (4, 'test3', 'co')") - c.execute("insert into zxtesting (id, name, state) values (5, 'test4', 'il')") - c.execute("insert into zxtesting (id, name, state) values (6, 'test5', 'ca')") - c.execute("insert into zxtesting (id, name, state) values (7, 'test6', 'wi')") - self.db.commit() - finally: - c.close() + try: + c.execute("create table zxtesting (id int not null, name varchar(32), state varchar(32), primary key (id))") + self.db.commit() + c.execute("insert into zxtesting (id, name, state) values (1, 'test0', 'il')") + c.execute("insert into zxtesting (id, name, state) values (2, 'test1', 'wi')") + c.execute("insert into zxtesting (id, name, state) values (3, 'test2', 'tx')") + c.execute("insert into zxtesting (id, name, state) values (4, 'test3', 'co')") + c.execute("insert into zxtesting (id, name, state) values (5, 'test4', 'il')") + c.execute("insert into zxtesting (id, name, state) values (6, 'test5', 'ca')") + c.execute("insert into zxtesting (id, name, state) values (7, 'test6', 'wi')") + self.db.commit() + finally: + c.close() - def tearDown(self): + def tearDown(self): - c = self.cursor() - try: - try: - c.execute("drop table zxtesting") - except: - self.db.rollback() - finally: - c.close() + c = self.cursor() + try: + try: + c.execute("drop table zxtesting") + except: + self.db.rollback() + finally: + c.close() - zxCoreTestCase.tearDown(self) + zxCoreTestCase.tearDown(self) class zxAPITestCase(zxJDBCTestCase): - def testConnection(self): - """testing connection""" - assert self.db, "invalid connection" + def testConnection(self): + """testing connection""" + assert self.db, "invalid connection" - def testAutocommit(self): - """testing autocommit functionality""" - if self.db.__connection__.getMetaData().supportsTransactions(): - self.db.autocommit = 1 - self.assertEquals(1, self.db.__connection__.getAutoCommit()) - self.db.autocommit = 0 - self.assertEquals(0, self.db.__connection__.getAutoCommit()) + def testAutocommit(self): + """testing autocommit functionality""" + if self.db.__connection__.getMetaData().supportsTransactions(): + self.db.autocommit = 1 + self.assertEquals(1, self.db.__connection__.getAutoCommit()) + self.db.autocommit = 0 + self.assertEquals(0, self.db.__connection__.getAutoCommit()) - def testSimpleQuery(self): - """testing simple queries with cursor.execute(), no parameters""" - c = self.cursor() - try: - c.execute("select count(*) from zxtesting") - f = c.fetchall() - assert len(f) == 1, "expecting one row" - c.execute("select * from zxtesting") - data = c.fetchone() - assert len(f) == 1, "expecting one row" - assert data[0] == 1, "expected [1] rows, got [%d]" % (data[0]) - finally: - c.close() + def testSimpleQuery(self): + """testing simple queries with cursor.execute(), no parameters""" + c = self.cursor() + try: + c.execute("select count(*) from zxtesting") + f = c.fetchall() + assert len(f) == 1, "expecting one row" + c.execute("select * from zxtesting") + data = c.fetchone() + assert len(f) == 1, "expecting one row" + assert data[0] == 1, "expected [1] rows, got [%d]" % (data[0]) + finally: + c.close() - def testNoneQuery(self): - """testing that executing None doesn't fail""" - c = self.cursor() - ... [truncated message content] |
From: <fwi...@us...> - 2009-08-10 17:22:53
|
Revision: 6646 http://jython.svn.sourceforge.net/jython/?rev=6646&view=rev Author: fwierzbicki Date: 2009-08-10 17:22:46 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindent. Modified Paths: -------------- trunk/jython/Lib/test/zxjdbc/test_zxjdbc_dbapi20.py Modified: trunk/jython/Lib/test/zxjdbc/test_zxjdbc_dbapi20.py =================================================================== --- trunk/jython/Lib/test/zxjdbc/test_zxjdbc_dbapi20.py 2009-08-10 17:17:35 UTC (rev 6645) +++ trunk/jython/Lib/test/zxjdbc/test_zxjdbc_dbapi20.py 2009-08-10 17:22:46 UTC (rev 6646) @@ -18,7 +18,7 @@ driver = zxjdbc connect_args = ("jdbc:postgresql://localhost/ziclix", "bzimmer", "", "org.postgresql.Driver") connect_kw_args = {} - + def test_nextset(self): pass def test_setoutputsize(self): pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:17:42
|
Revision: 6645 http://jython.svn.sourceforge.net/jython/?rev=6645&view=rev Author: fwierzbicki Date: 2009-08-10 17:17:35 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindents. Modified Paths: -------------- trunk/jython/Lib/xml/sax/drivers2/drv_javasax.py Modified: trunk/jython/Lib/xml/sax/drivers2/drv_javasax.py =================================================================== --- trunk/jython/Lib/xml/sax/drivers2/drv_javasax.py 2009-08-10 17:16:57 UTC (rev 6644) +++ trunk/jython/Lib/xml/sax/drivers2/drv_javasax.py 2009-08-10 17:17:35 UTC (rev 6645) @@ -35,7 +35,7 @@ jaxp = 1 except ImportError: jaxp = 0 - + from java.lang import String @@ -50,7 +50,7 @@ class JyErrorHandlerWrapper(javasax.ErrorHandler): def __init__(self, err_handler): self._err_handler = err_handler - + def error(self, exc): self._err_handler.error(_wrap_sax_exception(exc)) @@ -105,7 +105,7 @@ self.lineNum = lineNum self.pubId = pubId self.sysId = sysId - + def getColumnNumber(self): return self.colNum @@ -265,7 +265,7 @@ def get(self, name, alt=None): try: - return self.getValue(name) + return self.getValue(name) except KeyError: return alt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:17:04
|
Revision: 6644 http://jython.svn.sourceforge.net/jython/?rev=6644&view=rev Author: fwierzbicki Date: 2009-08-10 17:16:57 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindents. Modified Paths: -------------- trunk/jython/Lib/xml/sax/_exceptions.py trunk/jython/Lib/xml/sax/handler.py trunk/jython/Lib/xml/sax/saxutils.py Modified: trunk/jython/Lib/xml/sax/_exceptions.py =================================================================== --- trunk/jython/Lib/xml/sax/_exceptions.py 2009-08-10 17:15:48 UTC (rev 6643) +++ trunk/jython/Lib/xml/sax/_exceptions.py 2009-08-10 17:16:57 UTC (rev 6644) @@ -89,10 +89,10 @@ sysid = "<unknown>" linenum = self.getLineNumber() if linenum is None: - linenum = "?" + linenum = "?" colnum = self.getColumnNumber() if colnum is None: - colnum = "?" + colnum = "?" return "%s:%s:%s: %s" % (sysid, linenum, colnum, self._msg) Modified: trunk/jython/Lib/xml/sax/handler.py =================================================================== --- trunk/jython/Lib/xml/sax/handler.py 2009-08-10 17:15:48 UTC (rev 6643) +++ trunk/jython/Lib/xml/sax/handler.py 2009-08-10 17:16:57 UTC (rev 6644) @@ -326,7 +326,7 @@ # processing a META tag) # read: return the current encoding (possibly established through # auto-detection. -# initial value: UTF-8 +# initial value: UTF-8 # property_interning_dict = "http://www.python.org/sax/properties/interning-dict" Modified: trunk/jython/Lib/xml/sax/saxutils.py =================================================================== --- trunk/jython/Lib/xml/sax/saxutils.py 2009-08-10 17:15:48 UTC (rev 6643) +++ trunk/jython/Lib/xml/sax/saxutils.py 2009-08-10 17:16:57 UTC (rev 6644) @@ -525,11 +525,11 @@ def absolute_system_id(sysid, base=''): if os.path.exists(sysid): sysid = 'file:%s' % os.path.abspath(sysid) - elif base: + elif base: sysid = Absolutize(sysid, base) assert IsAbsolute(sysid) return MakeUrllibSafe(sysid) - + # =========================================================================== # # DEPRECATED SAX 1.0 CLASSES This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:15:53
|
Revision: 6643 http://jython.svn.sourceforge.net/jython/?rev=6643&view=rev Author: fwierzbicki Date: 2009-08-10 17:15:48 +0000 (Mon, 10 Aug 2009) Log Message: ----------- reindent. Modified Paths: -------------- trunk/jython/Lib/xml/parsers/expat.py Modified: trunk/jython/Lib/xml/parsers/expat.py =================================================================== --- trunk/jython/Lib/xml/parsers/expat.py 2009-08-10 17:14:52 UTC (rev 6642) +++ trunk/jython/Lib/xml/parsers/expat.py 2009-08-10 17:15:48 UTC (rev 6643) @@ -171,18 +171,18 @@ returns_unicode = property(_get_returns_unicode, _set_returns_unicode) def _expat_error(self, sax_error): - sax_message = sax_error.getMessage() - pattern = 'The entity ".*" was referenced, but not declared\.' - if re.match(pattern, sax_message): - expat_message = "undefined entity: line %s, column %s" % \ - (self.ErrorLineNumber, self.ErrorColumnNumber) - else: - expat_message = sax_message - error = ExpatError(expat_message) - error.lineno = self.ErrorLineNumber - error.offset = self.ErrorColumnNumber - error.code = self.ErrorCode - return error + sax_message = sax_error.getMessage() + pattern = 'The entity ".*" was referenced, but not declared\.' + if re.match(pattern, sax_message): + expat_message = "undefined entity: line %s, column %s" % \ + (self.ErrorLineNumber, self.ErrorColumnNumber) + else: + expat_message = sax_message + error = ExpatError(expat_message) + error.lineno = self.ErrorLineNumber + error.offset = self.ErrorColumnNumber + error.code = self.ErrorCode + return error def Parse(self, data, isfinal=False): # The 'data' argument should be an encoded text: a str instance that This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:14:59
|
Revision: 6642 http://jython.svn.sourceforge.net/jython/?rev=6642&view=rev Author: fwierzbicki Date: 2009-08-10 17:14:52 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindents. Modified Paths: -------------- trunk/jython/Lib/xml/dom/minidom.py trunk/jython/Lib/xml/dom/pulldom.py Modified: trunk/jython/Lib/xml/dom/minidom.py =================================================================== --- trunk/jython/Lib/xml/dom/minidom.py 2009-08-10 17:13:59 UTC (rev 6641) +++ trunk/jython/Lib/xml/dom/minidom.py 2009-08-10 17:14:52 UTC (rev 6642) @@ -1920,15 +1920,15 @@ except ImportError: pass from xml.dom import pulldom - return _do_pulldom_parse(pulldom.parse, (file,), + return _do_pulldom_parse(pulldom.parse, (file,), {'parser': parser, 'bufsize': bufsize}) def parseString(string, parser=None): """Parse a file into a DOM from a string.""" import sys if parser is None and sys.platform[:4] != "java": - from xml.dom import expatbuilder - return expatbuilder.parseString(string) + from xml.dom import expatbuilder + return expatbuilder.parseString(string) from xml.dom import pulldom return _do_pulldom_parse(pulldom.parseString, (string,), {'parser': parser}) Modified: trunk/jython/Lib/xml/dom/pulldom.py =================================================================== --- trunk/jython/Lib/xml/dom/pulldom.py 2009-08-10 17:13:59 UTC (rev 6641) +++ trunk/jython/Lib/xml/dom/pulldom.py 2009-08-10 17:14:52 UTC (rev 6642) @@ -235,7 +235,7 @@ def __iter__(self): return self - + def expandNode(self, node): event = self.getEvent() parents = [node] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:14:12
|
Revision: 6641 http://jython.svn.sourceforge.net/jython/?rev=6641&view=rev Author: fwierzbicki Date: 2009-08-10 17:13:59 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindent. Modified Paths: -------------- trunk/jython/Lib/xml/Uri.py Modified: trunk/jython/Lib/xml/Uri.py =================================================================== --- trunk/jython/Lib/xml/Uri.py 2009-08-10 17:13:06 UTC (rev 6640) +++ trunk/jython/Lib/xml/Uri.py 2009-08-10 17:13:59 UTC (rev 6641) @@ -17,7 +17,7 @@ def UnsplitUriRef(uriRefSeq): """should replace urlparse.urlunsplit - + Given a sequence as would be produced by SplitUriRef(), assembles and returns a URI reference as a string. """ @@ -40,7 +40,7 @@ def SplitUriRef(uriref): """should replace urlparse.urlsplit - + Given a valid URI reference as a string, returns a tuple representing the generic URI components, as per RFC 2396 appendix B. The tuple's structure is (scheme, authority, path, query, fragment). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:13:17
|
Revision: 6640 http://jython.svn.sourceforge.net/jython/?rev=6640&view=rev Author: fwierzbicki Date: 2009-08-10 17:13:06 +0000 (Mon, 10 Aug 2009) Log Message: ----------- reindent (mainly 8 space -> 4 space) Modified Paths: -------------- trunk/jython/Lib/pawt/__init__.py trunk/jython/Lib/pawt/colors.py trunk/jython/Lib/pawt/swing.py Modified: trunk/jython/Lib/pawt/__init__.py =================================================================== --- trunk/jython/Lib/pawt/__init__.py 2009-08-10 17:06:51 UTC (rev 6639) +++ trunk/jython/Lib/pawt/__init__.py 2009-08-10 17:13:06 UTC (rev 6640) @@ -2,34 +2,34 @@ from java import awt def test(panel, size=None, name='AWT Tester'): - f = awt.Frame(name, windowClosing=lambda event: sys.exit(0)) - if hasattr(panel, 'init'): - panel.init() + f = awt.Frame(name, windowClosing=lambda event: sys.exit(0)) + if hasattr(panel, 'init'): + panel.init() - f.add('Center', panel) - f.pack() - if size is not None: - f.setSize(apply(awt.Dimension, size)) - f.setVisible(1) - return f + f.add('Center', panel) + f.pack() + if size is not None: + f.setSize(apply(awt.Dimension, size)) + f.setVisible(1) + return f class GridBag: - def __init__(self, frame, **defaults): - self.frame = frame - self.gridbag = awt.GridBagLayout() - self.defaults = defaults - frame.setLayout(self.gridbag) + def __init__(self, frame, **defaults): + self.frame = frame + self.gridbag = awt.GridBagLayout() + self.defaults = defaults + frame.setLayout(self.gridbag) - def addRow(self, widget, **kw): - kw['gridwidth'] = 'REMAINDER' - apply(self.add, (widget, ), kw) + def addRow(self, widget, **kw): + kw['gridwidth'] = 'REMAINDER' + apply(self.add, (widget, ), kw) - def add(self, widget, **kw): - constraints = awt.GridBagConstraints() + def add(self, widget, **kw): + constraints = awt.GridBagConstraints() - for key, value in self.defaults.items()+kw.items(): - if isinstance(value, type('')): - value = getattr(awt.GridBagConstraints, value) - setattr(constraints, key, value) - self.gridbag.setConstraints(widget, constraints) - self.frame.add(widget) \ No newline at end of file + for key, value in self.defaults.items()+kw.items(): + if isinstance(value, type('')): + value = getattr(awt.GridBagConstraints, value) + setattr(constraints, key, value) + self.gridbag.setConstraints(widget, constraints) + self.frame.add(widget) Modified: trunk/jython/Lib/pawt/colors.py =================================================================== --- trunk/jython/Lib/pawt/colors.py 2009-08-10 17:06:51 UTC (rev 6639) +++ trunk/jython/Lib/pawt/colors.py 2009-08-10 17:13:06 UTC (rev 6640) @@ -141,4 +141,4 @@ yellow = Color(255, 255, 0) yellowgreen = Color(154, 205, 50) -del Color \ No newline at end of file +del Color Modified: trunk/jython/Lib/pawt/swing.py =================================================================== --- trunk/jython/Lib/pawt/swing.py 2009-08-10 17:06:51 UTC (rev 6639) +++ trunk/jython/Lib/pawt/swing.py 2009-08-10 17:13:06 UTC (rev 6640) @@ -5,20 +5,20 @@ import sys def test(panel, size=None, name='Swing Tester'): - f = swing.JFrame(name, windowClosing=lambda event: sys.exit(0)) - if hasattr(panel, 'init'): - panel.init() + f = swing.JFrame(name, windowClosing=lambda event: sys.exit(0)) + if hasattr(panel, 'init'): + panel.init() - f.contentPane.add(panel) - f.pack() - if size is not None: - from java import awt - f.setSize(apply(awt.Dimension, size)) - f.setVisible(1) - return f + f.contentPane.add(panel) + f.pack() + if size is not None: + from java import awt + f.setSize(apply(awt.Dimension, size)) + f.setVisible(1) + return f if swing is not None: - import pawt, sys - pawt.swing = swing - sys.modules['pawt.swing'] = swing - swing.__dict__['test'] = test + import pawt, sys + pawt.swing = swing + sys.modules['pawt.swing'] = swing + swing.__dict__['test'] = test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:06:58
|
Revision: 6639 http://jython.svn.sourceforge.net/jython/?rev=6639&view=rev Author: fwierzbicki Date: 2009-08-10 17:06:51 +0000 (Mon, 10 Aug 2009) Log Message: ----------- reindent. Another large 8 space indent -> 4 space indent. Modified Paths: -------------- trunk/jython/Lib/isql.py Modified: trunk/jython/Lib/isql.py =================================================================== --- trunk/jython/Lib/isql.py 2009-08-10 17:05:49 UTC (rev 6638) +++ trunk/jython/Lib/isql.py 2009-08-10 17:06:51 UTC (rev 6639) @@ -12,227 +12,226 @@ class IsqlExit(Exception): pass class Prompt: - """ - This class fixes a problem with the cmd.Cmd class since it uses an ivar 'prompt' - as opposed to a method 'prompt()'. To get around this, this class is plugged in - as a 'prompt' attribute and when invoked the '__str__' method is called which - figures out the appropriate prompt to display. I still think, even though this - is clever, the attribute version of 'prompt' is poor design. - """ - def __init__(self, isql): - self.isql = isql - def __str__(self): - prompt = "%s> " % (self.isql.db.dbname) - if len(self.isql.sqlbuffer) > 0: - prompt = "... " - return prompt - if os.name == 'java': - def __tojava__(self, cls): - import java.lang.String - if cls == java.lang.String: - return self.__str__() - return False + """ + This class fixes a problem with the cmd.Cmd class since it uses an ivar 'prompt' + as opposed to a method 'prompt()'. To get around this, this class is plugged in + as a 'prompt' attribute and when invoked the '__str__' method is called which + figures out the appropriate prompt to display. I still think, even though this + is clever, the attribute version of 'prompt' is poor design. + """ + def __init__(self, isql): + self.isql = isql + def __str__(self): + prompt = "%s> " % (self.isql.db.dbname) + if len(self.isql.sqlbuffer) > 0: + prompt = "... " + return prompt + if os.name == 'java': + def __tojava__(self, cls): + import java.lang.String + if cls == java.lang.String: + return self.__str__() + return False class IsqlCmd(cmd.Cmd): - def __init__(self, db=None, delimiter=";", comment=('#', '--')): - cmd.Cmd.__init__(self, completekey=None) - if db is None or type(db) == type(""): - self.db = dbexts.dbexts(db) - else: - self.db = db - self.kw = {} - self.sqlbuffer = [] - self.comment = comment - self.delimiter = delimiter - self.prompt = Prompt(self) - - def parseline(self, line): - command, arg, line = cmd.Cmd.parseline(self, line) - if command and command <> "EOF": - command = command.lower() - return command, arg, line + def __init__(self, db=None, delimiter=";", comment=('#', '--')): + cmd.Cmd.__init__(self, completekey=None) + if db is None or type(db) == type(""): + self.db = dbexts.dbexts(db) + else: + self.db = db + self.kw = {} + self.sqlbuffer = [] + self.comment = comment + self.delimiter = delimiter + self.prompt = Prompt(self) - def do_which(self, arg): - """\nPrints the current db connection parameters.\n""" - print self.db - return False + def parseline(self, line): + command, arg, line = cmd.Cmd.parseline(self, line) + if command and command <> "EOF": + command = command.lower() + return command, arg, line - def do_EOF(self, arg): - return False + def do_which(self, arg): + """\nPrints the current db connection parameters.\n""" + print self.db + return False - def do_p(self, arg): - """\nExecute a python expression.\n""" - try: - exec arg.strip() in globals() - except: - print sys.exc_info()[1] - return False - - def do_column(self, arg): - """\nInstructions for column display.\n""" - return False - - def do_use(self, arg): - """\nUse a new database connection.\n""" - # this allows custom dbexts - self.db = self.db.__class__(arg.strip()) - return False + def do_EOF(self, arg): + return False - def do_table(self, arg): - """\nPrints table meta-data. If no table name, prints all tables.\n""" - if len(arg.strip()): - self.db.table(arg, **self.kw) - else: - self.db.table(None, **self.kw) - return False + def do_p(self, arg): + """\nExecute a python expression.\n""" + try: + exec arg.strip() in globals() + except: + print sys.exc_info()[1] + return False - def do_proc(self, arg): - """\nPrints store procedure meta-data.\n""" - if len(arg.strip()): - self.db.proc(arg, **self.kw) - else: - self.db.proc(None, **self.kw) - return False + def do_column(self, arg): + """\nInstructions for column display.\n""" + return False - def do_schema(self, arg): - """\nPrints schema information.\n""" + def do_use(self, arg): + """\nUse a new database connection.\n""" + # this allows custom dbexts + self.db = self.db.__class__(arg.strip()) + return False + + def do_table(self, arg): + """\nPrints table meta-data. If no table name, prints all tables.\n""" + if len(arg.strip()): + self.db.table(arg, **self.kw) + else: + self.db.table(None, **self.kw) + return False + + def do_proc(self, arg): + """\nPrints store procedure meta-data.\n""" + if len(arg.strip()): + self.db.proc(arg, **self.kw) + else: + self.db.proc(None, **self.kw) + return False + + def do_schema(self, arg): + """\nPrints schema information.\n""" + print + self.db.schema(arg) + print + return False + + def do_delimiter(self, arg): + """\nChange the delimiter.\n""" + delimiter = arg.strip() + if len(delimiter) > 0: + self.delimiter = delimiter + + def do_o(self, arg): + """\nSet the output.\n""" + if not arg: + fp = self.db.out + try: + if fp: + fp.close() + finally: + self.db.out = None + else: + fp = open(arg, "w") + self.db.out = fp + + def do_q(self, arg): + """\nQuit.\n""" + try: + if self.db.out: + self.db.out.close() + finally: + return True + + def do_set(self, arg): + """\nSet a parameter. Some examples:\n set owner = 'informix'\n set types = ['VIEW', 'TABLE']\nThe right hand side is evaluated using `eval()`\n""" + if len(arg.strip()) == 0: + items = self.kw.items() + if len(items): print - self.db.schema(arg) + # format the results but don't include how many rows affected + for a in dbexts.console(items, ("key", "value"))[:-1]: + print a print - return False + return False + d = filter(lambda x: len(x) > 0, map(lambda x: x.strip(), arg.split("="))) + if len(d) == 1: + if self.kw.has_key(d[0]): + del self.kw[d[0]] + else: + self.kw[d[0]] = eval(d[1]) - def do_delimiter(self, arg): - """\nChange the delimiter.\n""" - delimiter = arg.strip() - if len(delimiter) > 0: - self.delimiter = delimiter - - def do_o(self, arg): - """\nSet the output.\n""" - if not arg: - fp = self.db.out - try: - if fp: - fp.close() - finally: - self.db.out = None - else: - fp = open(arg, "w") - self.db.out = fp + def do_i(self, arg): + fp = open(arg) + try: + print + for line in fp.readlines(): + line = self.precmd(line) + stop = self.onecmd(line) + stop = self.postcmd(stop, line) + finally: + fp.close() + return False - def do_q(self, arg): - """\nQuit.\n""" - try: - if self.db.out: - self.db.out.close() - finally: - return True - - def do_set(self, arg): - """\nSet a parameter. Some examples:\n set owner = 'informix'\n set types = ['VIEW', 'TABLE']\nThe right hand side is evaluated using `eval()`\n""" - if len(arg.strip()) == 0: - items = self.kw.items() - if len(items): - print - # format the results but don't include how many rows affected - for a in dbexts.console(items, ("key", "value"))[:-1]: - print a - print - return False - d = filter(lambda x: len(x) > 0, map(lambda x: x.strip(), arg.split("="))) - if len(d) == 1: - if self.kw.has_key(d[0]): - del self.kw[d[0]] - else: - self.kw[d[0]] = eval(d[1]) - - def do_i(self, arg): - fp = open(arg) - try: - print - for line in fp.readlines(): - line = self.precmd(line) - stop = self.onecmd(line) - stop = self.postcmd(stop, line) - finally: - fp.close() + def default(self, arg): + try: + token = arg.strip() + if not token: return False - - def default(self, arg): - try: - token = arg.strip() - if not token: - return False - comment = [token.startswith(x) for x in self.comment] - if reduce(lambda x,y: x or y, comment): - return False - if token[0] == '\\': - token = token[1:] - # is it possible the line contains the delimiter - if len(token) >= len(self.delimiter): - # does the line end with the delimiter - if token[-1 * len(self.delimiter):] == self.delimiter: - # now add all up to the delimiter - self.sqlbuffer.append(token[:-1 * len(self.delimiter)]) - if self.sqlbuffer: - q = " ".join(self.sqlbuffer) - print q - self.db.isql(q, **self.kw) - self.sqlbuffer = [] - if self.db.updatecount: - print - if self.db.updatecount == 1: - print "1 row affected" - else: - print "%d rows affected" % (self.db.updatecount) - print - return False - if token: - self.sqlbuffer.append(token) - except: - self.sqlbuffer = [] - print - print sys.exc_info()[1] - print + comment = [token.startswith(x) for x in self.comment] + if reduce(lambda x,y: x or y, comment): return False + if token[0] == '\\': + token = token[1:] + # is it possible the line contains the delimiter + if len(token) >= len(self.delimiter): + # does the line end with the delimiter + if token[-1 * len(self.delimiter):] == self.delimiter: + # now add all up to the delimiter + self.sqlbuffer.append(token[:-1 * len(self.delimiter)]) + if self.sqlbuffer: + q = " ".join(self.sqlbuffer) + print q + self.db.isql(q, **self.kw) + self.sqlbuffer = [] + if self.db.updatecount: + print + if self.db.updatecount == 1: + print "1 row affected" + else: + print "%d rows affected" % (self.db.updatecount) + print + return False + if token: + self.sqlbuffer.append(token) + except: + self.sqlbuffer = [] + print + print sys.exc_info()[1] + print + return False - def emptyline(self): - return False + def emptyline(self): + return False - def postloop(self): - raise IsqlExit() + def postloop(self): + raise IsqlExit() - def cmdloop(self, intro=None): - while 1: - try: - cmd.Cmd.cmdloop(self, intro) - except IsqlExit, e: - break - except Exception, e: - print - print e - print - intro = None + def cmdloop(self, intro=None): + while 1: + try: + cmd.Cmd.cmdloop(self, intro) + except IsqlExit, e: + break + except Exception, e: + print + print e + print + intro = None if __name__ == '__main__': - import getopt + import getopt - try: - opts, args = getopt.getopt(sys.argv[1:], "b:", []) - except getopt.error, msg: - print - print msg - print "Try `%s --help` for more information." % (sys.argv[0]) - sys.exit(0) + try: + opts, args = getopt.getopt(sys.argv[1:], "b:", []) + except getopt.error, msg: + print + print msg + print "Try `%s --help` for more information." % (sys.argv[0]) + sys.exit(0) - dbname = None - for opt, arg in opts: - if opt == '-b': - dbname = arg + dbname = None + for opt, arg in opts: + if opt == '-b': + dbname = arg - intro = "\nisql - interactive sql (%s)\n" % (__version__) - - isql = IsqlCmd(dbname) - isql.cmdloop() + intro = "\nisql - interactive sql (%s)\n" % (__version__) + isql = IsqlCmd(dbname) + isql.cmdloop() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:05:57
|
Revision: 6638 http://jython.svn.sourceforge.net/jython/?rev=6638&view=rev Author: fwierzbicki Date: 2009-08-10 17:05:49 +0000 (Mon, 10 Aug 2009) Log Message: ----------- big reindent -- unfortunately the entire file is 8-space indents. Guessing it was once converted from tabs to spaces. Modified Paths: -------------- trunk/jython/Lib/dbexts.py Modified: trunk/jython/Lib/dbexts.py =================================================================== --- trunk/jython/Lib/dbexts.py 2009-08-10 17:01:32 UTC (rev 6637) +++ trunk/jython/Lib/dbexts.py 2009-08-10 17:05:49 UTC (rev 6638) @@ -56,671 +56,671 @@ choose = lambda bool, a, b: (bool and [a] or [b])[0] def console(rows, headers=()): - """Format the results into a list of strings (one for each row): + """Format the results into a list of strings (one for each row): - <header> - <headersep> - <row1> - <row2> - ... + <header> + <headersep> + <row1> + <row2> + ... - headers may be given as list of strings. + headers may be given as list of strings. - Columns are separated by colsep; the header is separated from - the result set by a line of headersep characters. + Columns are separated by colsep; the header is separated from + the result set by a line of headersep characters. - The function calls stringify to format the value data into a string. - It defaults to calling str() and striping leading and trailing whitespace. + The function calls stringify to format the value data into a string. + It defaults to calling str() and striping leading and trailing whitespace. - - copied and modified from mxODBC - """ + - copied and modified from mxODBC + """ - # Check row entry lengths - output = [] - headers = map(lambda header: header.upper(), list(map(lambda x: x or "", headers))) - collen = map(len,headers) - output.append(headers) - if rows and len(rows) > 0: - for row in rows: - row = map(lambda x: str(x), row) - for i in range(len(row)): - entry = row[i] - if collen[i] < len(entry): - collen[i] = len(entry) - output.append(row) - if len(output) == 1: - affected = "0 rows affected" - elif len(output) == 2: - affected = "1 row affected" - else: - affected = "%d rows affected" % (len(output) - 1) + # Check row entry lengths + output = [] + headers = map(lambda header: header.upper(), list(map(lambda x: x or "", headers))) + collen = map(len,headers) + output.append(headers) + if rows and len(rows) > 0: + for row in rows: + row = map(lambda x: str(x), row) + for i in range(len(row)): + entry = row[i] + if collen[i] < len(entry): + collen[i] = len(entry) + output.append(row) + if len(output) == 1: + affected = "0 rows affected" + elif len(output) == 2: + affected = "1 row affected" + else: + affected = "%d rows affected" % (len(output) - 1) - # Format output - for i in range(len(output)): - row = output[i] - l = [] - for j in range(len(row)): - l.append('%-*s' % (collen[j],row[j])) - output[i] = " | ".join(l) + # Format output + for i in range(len(output)): + row = output[i] + l = [] + for j in range(len(row)): + l.append('%-*s' % (collen[j],row[j])) + output[i] = " | ".join(l) - # Insert header separator - totallen = len(output[0]) - output[1:1] = ["-"*(totallen/len("-"))] - output.append("\n" + affected) - return output + # Insert header separator + totallen = len(output[0]) + output[1:1] = ["-"*(totallen/len("-"))] + output.append("\n" + affected) + return output def html(rows, headers=()): - output = [] - output.append('<table class="results">') - output.append('<tr class="headers">') - headers = map(lambda x: '<td class="header">%s</td>' % (x.upper()), list(headers)) - map(output.append, headers) - output.append('</tr>') - if rows and len(rows) > 0: - for row in rows: - output.append('<tr class="row">') - row = map(lambda x: '<td class="value">%s</td>' % (x), row) - map(output.append, row) - output.append('</tr>') - output.append('</table>') - return output + output = [] + output.append('<table class="results">') + output.append('<tr class="headers">') + headers = map(lambda x: '<td class="header">%s</td>' % (x.upper()), list(headers)) + map(output.append, headers) + output.append('</tr>') + if rows and len(rows) > 0: + for row in rows: + output.append('<tr class="row">') + row = map(lambda x: '<td class="value">%s</td>' % (x), row) + map(output.append, row) + output.append('</tr>') + output.append('</table>') + return output comments = lambda x: re.compile("{.*?}", re.S).sub("", x, 0) class mxODBCProxy: - """Wraps mxODBC to provide proxy support for zxJDBC's additional parameters.""" - def __init__(self, c): - self.c = c - def __getattr__(self, name): - if name == "execute": - return self.execute - elif name == "gettypeinfo": - return self.gettypeinfo - else: - return getattr(self.c, name) - def execute(self, sql, params=None, bindings=None, maxrows=None): - if params: - self.c.execute(sql, params) - else: - self.c.execute(sql) - def gettypeinfo(self, typeid=None): - if typeid: - self.c.gettypeinfo(typeid) + """Wraps mxODBC to provide proxy support for zxJDBC's additional parameters.""" + def __init__(self, c): + self.c = c + def __getattr__(self, name): + if name == "execute": + return self.execute + elif name == "gettypeinfo": + return self.gettypeinfo + else: + return getattr(self.c, name) + def execute(self, sql, params=None, bindings=None, maxrows=None): + if params: + self.c.execute(sql, params) + else: + self.c.execute(sql) + def gettypeinfo(self, typeid=None): + if typeid: + self.c.gettypeinfo(typeid) class executor: - """Handles the insertion of values given dynamic data.""" - def __init__(self, table, cols): - self.cols = cols - self.table = table - if self.cols: - self.sql = "insert into %s (%s) values (%s)" % (table, ",".join(self.cols), ",".join(("?",) * len(self.cols))) - else: - self.sql = "insert into %s values (%%s)" % (table) - def execute(self, db, rows, bindings): - assert rows and len(rows) > 0, "must have at least one row" - if self.cols: - sql = self.sql - else: - sql = self.sql % (",".join(("?",) * len(rows[0]))) - db.raw(sql, rows, bindings) + """Handles the insertion of values given dynamic data.""" + def __init__(self, table, cols): + self.cols = cols + self.table = table + if self.cols: + self.sql = "insert into %s (%s) values (%s)" % (table, ",".join(self.cols), ",".join(("?",) * len(self.cols))) + else: + self.sql = "insert into %s values (%%s)" % (table) + def execute(self, db, rows, bindings): + assert rows and len(rows) > 0, "must have at least one row" + if self.cols: + sql = self.sql + else: + sql = self.sql % (",".join(("?",) * len(rows[0]))) + db.raw(sql, rows, bindings) def connect(dbname): - return dbexts(dbname) + return dbexts(dbname) def lookup(dbname): - return dbexts(jndiname=dbname) + return dbexts(jndiname=dbname) class dbexts: - def __init__(self, dbname=None, cfg=None, formatter=console, autocommit=0, jndiname=None, out=None): - self.verbose = 1 - self.results = [] - self.headers = [] - self.autocommit = autocommit - self.formatter = formatter - self.out = out - self.lastrowid = None - self.updatecount = None + def __init__(self, dbname=None, cfg=None, formatter=console, autocommit=0, jndiname=None, out=None): + self.verbose = 1 + self.results = [] + self.headers = [] + self.autocommit = autocommit + self.formatter = formatter + self.out = out + self.lastrowid = None + self.updatecount = None - if not jndiname: - if cfg == None: - fn = os.path.join(os.path.split(__file__)[0], "dbexts.ini") - if not os.path.exists(fn): - fn = os.path.join(os.environ['HOME'], ".dbexts") - self.dbs = IniParser(fn) - elif isinstance(cfg, IniParser): - self.dbs = cfg - else: - self.dbs = IniParser(cfg) - if dbname == None: dbname = self.dbs[("default", "name")] + if not jndiname: + if cfg == None: + fn = os.path.join(os.path.split(__file__)[0], "dbexts.ini") + if not os.path.exists(fn): + fn = os.path.join(os.environ['HOME'], ".dbexts") + self.dbs = IniParser(fn) + elif isinstance(cfg, IniParser): + self.dbs = cfg + else: + self.dbs = IniParser(cfg) + if dbname == None: dbname = self.dbs[("default", "name")] - if __OS__ == 'java': + if __OS__ == 'java': - from com.ziclix.python.sql import zxJDBC - database = zxJDBC - if not jndiname: - t = self.dbs[("jdbc", dbname)] - self.dburl, dbuser, dbpwd, jdbcdriver = t['url'], t['user'], t['pwd'], t['driver'] - if t.has_key('datahandler'): - self.datahandler = [] - for dh in t['datahandler'].split(','): - classname = dh.split(".")[-1] - datahandlerclass = __import__(dh, globals(), locals(), classname) - self.datahandler.append(datahandlerclass) - keys = [x for x in t.keys() if x not in ['url', 'user', 'pwd', 'driver', 'datahandler', 'name']] - props = {} - for a in keys: - props[a] = t[a] - self.db = apply(database.connect, (self.dburl, dbuser, dbpwd, jdbcdriver), props) - else: - self.db = database.lookup(jndiname) - self.db.autocommit = self.autocommit + from com.ziclix.python.sql import zxJDBC + database = zxJDBC + if not jndiname: + t = self.dbs[("jdbc", dbname)] + self.dburl, dbuser, dbpwd, jdbcdriver = t['url'], t['user'], t['pwd'], t['driver'] + if t.has_key('datahandler'): + self.datahandler = [] + for dh in t['datahandler'].split(','): + classname = dh.split(".")[-1] + datahandlerclass = __import__(dh, globals(), locals(), classname) + self.datahandler.append(datahandlerclass) + keys = [x for x in t.keys() if x not in ['url', 'user', 'pwd', 'driver', 'datahandler', 'name']] + props = {} + for a in keys: + props[a] = t[a] + self.db = apply(database.connect, (self.dburl, dbuser, dbpwd, jdbcdriver), props) + else: + self.db = database.lookup(jndiname) + self.db.autocommit = self.autocommit - elif __OS__ == 'nt': + elif __OS__ == 'nt': - for modname in ["mx.ODBC.Windows", "ODBC.Windows"]: - try: - database = __import__(modname, globals(), locals(), "Windows") - break - except: - continue - else: - raise ImportError("unable to find appropriate mxODBC module") + for modname in ["mx.ODBC.Windows", "ODBC.Windows"]: + try: + database = __import__(modname, globals(), locals(), "Windows") + break + except: + continue + else: + raise ImportError("unable to find appropriate mxODBC module") - t = self.dbs[("odbc", dbname)] - self.dburl, dbuser, dbpwd = t['url'], t['user'], t['pwd'] - self.db = database.Connect(self.dburl, dbuser, dbpwd, clear_auto_commit=1) + t = self.dbs[("odbc", dbname)] + self.dburl, dbuser, dbpwd = t['url'], t['user'], t['pwd'] + self.db = database.Connect(self.dburl, dbuser, dbpwd, clear_auto_commit=1) - self.dbname = dbname - for a in database.sqltype.keys(): - setattr(self, database.sqltype[a], a) - for a in dir(database): - try: - p = getattr(database, a) - if issubclass(p, Exception): - setattr(self, a, p) - except: - continue - del database + self.dbname = dbname + for a in database.sqltype.keys(): + setattr(self, database.sqltype[a], a) + for a in dir(database): + try: + p = getattr(database, a) + if issubclass(p, Exception): + setattr(self, a, p) + except: + continue + del database - def __str__(self): - return self.dburl + def __str__(self): + return self.dburl - def __repr__(self): - return self.dburl + def __repr__(self): + return self.dburl - def __getattr__(self, name): - if "cfg" == name: - return self.dbs.cfg - raise AttributeError("'dbexts' object has no attribute '%s'" % (name)) + def __getattr__(self, name): + if "cfg" == name: + return self.dbs.cfg + raise AttributeError("'dbexts' object has no attribute '%s'" % (name)) - def close(self): - """ close the connection to the database """ - self.db.close() + def close(self): + """ close the connection to the database """ + self.db.close() - def begin(self, style=None): - """ reset ivars and return a new cursor, possibly binding an auxiliary datahandler """ - self.headers, self.results = [], [] - if style: - c = self.db.cursor(style) - else: - c = self.db.cursor() - if __OS__ == 'java': - if hasattr(self, 'datahandler'): - for dh in self.datahandler: - c.datahandler = dh(c.datahandler) - else: - c = mxODBCProxy(c) - return c + def begin(self, style=None): + """ reset ivars and return a new cursor, possibly binding an auxiliary datahandler """ + self.headers, self.results = [], [] + if style: + c = self.db.cursor(style) + else: + c = self.db.cursor() + if __OS__ == 'java': + if hasattr(self, 'datahandler'): + for dh in self.datahandler: + c.datahandler = dh(c.datahandler) + else: + c = mxODBCProxy(c) + return c - def commit(self, cursor=None, close=1): - """ commit the cursor and create the result set """ - if cursor and cursor.description: - self.headers = cursor.description - self.results = cursor.fetchall() - if hasattr(cursor, "nextset"): - s = cursor.nextset() - while s: - self.results += cursor.fetchall() - s = cursor.nextset() - if hasattr(cursor, "lastrowid"): - self.lastrowid = cursor.lastrowid - if hasattr(cursor, "updatecount"): - self.updatecount = cursor.updatecount - if not self.autocommit or cursor is None: - if not self.db.autocommit: - self.db.commit() - if cursor and close: cursor.close() + def commit(self, cursor=None, close=1): + """ commit the cursor and create the result set """ + if cursor and cursor.description: + self.headers = cursor.description + self.results = cursor.fetchall() + if hasattr(cursor, "nextset"): + s = cursor.nextset() + while s: + self.results += cursor.fetchall() + s = cursor.nextset() + if hasattr(cursor, "lastrowid"): + self.lastrowid = cursor.lastrowid + if hasattr(cursor, "updatecount"): + self.updatecount = cursor.updatecount + if not self.autocommit or cursor is None: + if not self.db.autocommit: + self.db.commit() + if cursor and close: cursor.close() - def rollback(self): - """ rollback the cursor """ - self.db.rollback() + def rollback(self): + """ rollback the cursor """ + self.db.rollback() - def prepare(self, sql): - """ prepare the sql statement """ - cur = self.begin() - try: - return cur.prepare(sql) - finally: - self.commit(cur) + def prepare(self, sql): + """ prepare the sql statement """ + cur = self.begin() + try: + return cur.prepare(sql) + finally: + self.commit(cur) - def display(self): - """ using the formatter, display the results """ - if self.formatter and self.verbose > 0: - res = self.results - if res: - print >> self.out, "" - for a in self.formatter(res, map(lambda x: x[0], self.headers)): - print >> self.out, a - print >> self.out, "" + def display(self): + """ using the formatter, display the results """ + if self.formatter and self.verbose > 0: + res = self.results + if res: + print >> self.out, "" + for a in self.formatter(res, map(lambda x: x[0], self.headers)): + print >> self.out, a + print >> self.out, "" - def __execute__(self, sql, params=None, bindings=None, maxrows=None): - """ the primary execution method """ - cur = self.begin() - try: - if bindings: - cur.execute(sql, params, bindings, maxrows=maxrows) - elif params: - cur.execute(sql, params, maxrows=maxrows) - else: - cur.execute(sql, maxrows=maxrows) - finally: - self.commit(cur, close=isinstance(sql, StringType)) + def __execute__(self, sql, params=None, bindings=None, maxrows=None): + """ the primary execution method """ + cur = self.begin() + try: + if bindings: + cur.execute(sql, params, bindings, maxrows=maxrows) + elif params: + cur.execute(sql, params, maxrows=maxrows) + else: + cur.execute(sql, maxrows=maxrows) + finally: + self.commit(cur, close=isinstance(sql, StringType)) - def isql(self, sql, params=None, bindings=None, maxrows=None): - """ execute and display the sql """ - self.raw(sql, params, bindings, maxrows=maxrows) - self.display() + def isql(self, sql, params=None, bindings=None, maxrows=None): + """ execute and display the sql """ + self.raw(sql, params, bindings, maxrows=maxrows) + self.display() - def raw(self, sql, params=None, bindings=None, delim=None, comments=comments, maxrows=None): - """ execute the sql and return a tuple of (headers, results) """ - if delim: - headers = [] - results = [] - if type(sql) == type(StringType): - if comments: sql = comments(sql) - statements = filter(lambda x: len(x) > 0, - map(lambda statement: statement.strip(), sql.split(delim))) - else: - statements = [sql] - for a in statements: - self.__execute__(a, params, bindings, maxrows=maxrows) - headers.append(self.headers) - results.append(self.results) - self.headers = headers - self.results = results - else: - self.__execute__(sql, params, bindings, maxrows=maxrows) - return (self.headers, self.results) + def raw(self, sql, params=None, bindings=None, delim=None, comments=comments, maxrows=None): + """ execute the sql and return a tuple of (headers, results) """ + if delim: + headers = [] + results = [] + if type(sql) == type(StringType): + if comments: sql = comments(sql) + statements = filter(lambda x: len(x) > 0, + map(lambda statement: statement.strip(), sql.split(delim))) + else: + statements = [sql] + for a in statements: + self.__execute__(a, params, bindings, maxrows=maxrows) + headers.append(self.headers) + results.append(self.results) + self.headers = headers + self.results = results + else: + self.__execute__(sql, params, bindings, maxrows=maxrows) + return (self.headers, self.results) - def callproc(self, procname, params=None, bindings=None, maxrows=None): - """ execute a stored procedure """ - cur = self.begin() - try: - cur.callproc(procname, params=params, bindings=bindings, maxrows=maxrows) - finally: - self.commit(cur) - self.display() + def callproc(self, procname, params=None, bindings=None, maxrows=None): + """ execute a stored procedure """ + cur = self.begin() + try: + cur.callproc(procname, params=params, bindings=bindings, maxrows=maxrows) + finally: + self.commit(cur) + self.display() - def pk(self, table, owner=None, schema=None): - """ display the table's primary keys """ - cur = self.begin() - cur.primarykeys(schema, owner, table) - self.commit(cur) - self.display() + def pk(self, table, owner=None, schema=None): + """ display the table's primary keys """ + cur = self.begin() + cur.primarykeys(schema, owner, table) + self.commit(cur) + self.display() - def fk(self, primary_table=None, foreign_table=None, owner=None, schema=None): - """ display the table's foreign keys """ - cur = self.begin() - if primary_table and foreign_table: - cur.foreignkeys(schema, owner, primary_table, schema, owner, foreign_table) - elif primary_table: - cur.foreignkeys(schema, owner, primary_table, schema, owner, None) - elif foreign_table: - cur.foreignkeys(schema, owner, None, schema, owner, foreign_table) - self.commit(cur) - self.display() + def fk(self, primary_table=None, foreign_table=None, owner=None, schema=None): + """ display the table's foreign keys """ + cur = self.begin() + if primary_table and foreign_table: + cur.foreignkeys(schema, owner, primary_table, schema, owner, foreign_table) + elif primary_table: + cur.foreignkeys(schema, owner, primary_table, schema, owner, None) + elif foreign_table: + cur.foreignkeys(schema, owner, None, schema, owner, foreign_table) + self.commit(cur) + self.display() - def table(self, table=None, types=("TABLE",), owner=None, schema=None): - """If no table argument, displays a list of all tables. If a table argument, - displays the columns of the given table.""" - cur = self.begin() - if table: - cur.columns(schema, owner, table, None) - else: - cur.tables(schema, owner, None, types) - self.commit(cur) - self.display() + def table(self, table=None, types=("TABLE",), owner=None, schema=None): + """If no table argument, displays a list of all tables. If a table argument, + displays the columns of the given table.""" + cur = self.begin() + if table: + cur.columns(schema, owner, table, None) + else: + cur.tables(schema, owner, None, types) + self.commit(cur) + self.display() - def proc(self, proc=None, owner=None, schema=None): - """If no proc argument, displays a list of all procedures. If a proc argument, - displays the parameters of the given procedure.""" - cur = self.begin() - if proc: - cur.procedurecolumns(schema, owner, proc, None) - else: - cur.procedures(schema, owner, None) - self.commit(cur) - self.display() + def proc(self, proc=None, owner=None, schema=None): + """If no proc argument, displays a list of all procedures. If a proc argument, + displays the parameters of the given procedure.""" + cur = self.begin() + if proc: + cur.procedurecolumns(schema, owner, proc, None) + else: + cur.procedures(schema, owner, None) + self.commit(cur) + self.display() - def stat(self, table, qualifier=None, owner=None, unique=0, accuracy=0): - """ display the table's indicies """ - cur = self.begin() - cur.statistics(qualifier, owner, table, unique, accuracy) - self.commit(cur) - self.display() + def stat(self, table, qualifier=None, owner=None, unique=0, accuracy=0): + """ display the table's indicies """ + cur = self.begin() + cur.statistics(qualifier, owner, table, unique, accuracy) + self.commit(cur) + self.display() - def typeinfo(self, sqltype=None): - """ display the types available for the database """ - cur = self.begin() - cur.gettypeinfo(sqltype) - self.commit(cur) - self.display() + def typeinfo(self, sqltype=None): + """ display the types available for the database """ + cur = self.begin() + cur.gettypeinfo(sqltype) + self.commit(cur) + self.display() - def tabletypeinfo(self): - """ display the table types available for the database """ - cur = self.begin() - cur.gettabletypeinfo() - self.commit(cur) - self.display() + def tabletypeinfo(self): + """ display the table types available for the database """ + cur = self.begin() + cur.gettabletypeinfo() + self.commit(cur) + self.display() - def schema(self, table, full=0, sort=1, owner=None): - """Displays a Schema object for the table. If full is true, then generates - references to the table in addition to the standard fields. If sort is true, - sort all the items in the schema, else leave them in db dependent order.""" - print >> self.out, str(Schema(self, table, owner, full, sort)) + def schema(self, table, full=0, sort=1, owner=None): + """Displays a Schema object for the table. If full is true, then generates + references to the table in addition to the standard fields. If sort is true, + sort all the items in the schema, else leave them in db dependent order.""" + print >> self.out, str(Schema(self, table, owner, full, sort)) - def bulkcopy(self, dst, table, include=[], exclude=[], autobatch=0, executor=executor): - """Returns a Bulkcopy object using the given table.""" - if type(dst) == type(""): - dst = dbexts(dst, cfg=self.dbs) - bcp = Bulkcopy(dst, table, include=include, exclude=exclude, autobatch=autobatch, executor=executor) - return bcp + def bulkcopy(self, dst, table, include=[], exclude=[], autobatch=0, executor=executor): + """Returns a Bulkcopy object using the given table.""" + if type(dst) == type(""): + dst = dbexts(dst, cfg=self.dbs) + bcp = Bulkcopy(dst, table, include=include, exclude=exclude, autobatch=autobatch, executor=executor) + return bcp - def bcp(self, src, table, where='(1=1)', params=[], include=[], exclude=[], autobatch=0, executor=executor): - """Bulkcopy of rows from a src database to the current database for a given table and where clause.""" - if type(src) == type(""): - src = dbexts(src, cfg=self.dbs) - bcp = self.bulkcopy(self, table, include, exclude, autobatch, executor) - num = bcp.transfer(src, where, params) - return num + def bcp(self, src, table, where='(1=1)', params=[], include=[], exclude=[], autobatch=0, executor=executor): + """Bulkcopy of rows from a src database to the current database for a given table and where clause.""" + if type(src) == type(""): + src = dbexts(src, cfg=self.dbs) + bcp = self.bulkcopy(self, table, include, exclude, autobatch, executor) + num = bcp.transfer(src, where, params) + return num - def unload(self, filename, sql, delimiter=",", includeheaders=1): - """ Unloads the delimited results of the query to the file specified, optionally including headers. """ - u = Unload(self, filename, delimiter, includeheaders) - u.unload(sql) + def unload(self, filename, sql, delimiter=",", includeheaders=1): + """ Unloads the delimited results of the query to the file specified, optionally including headers. """ + u = Unload(self, filename, delimiter, includeheaders) + u.unload(sql) class Bulkcopy: - """The idea for a bcp class came from http://object-craft.com.au/projects/sybase""" - def __init__(self, dst, table, include=[], exclude=[], autobatch=0, executor=executor): - self.dst = dst - self.table = table - self.total = 0 - self.rows = [] - self.autobatch = autobatch - self.bindings = {} + """The idea for a bcp class came from http://object-craft.com.au/projects/sybase""" + def __init__(self, dst, table, include=[], exclude=[], autobatch=0, executor=executor): + self.dst = dst + self.table = table + self.total = 0 + self.rows = [] + self.autobatch = autobatch + self.bindings = {} - include = map(lambda x: x.lower(), include) - exclude = map(lambda x: x.lower(), exclude) + include = map(lambda x: x.lower(), include) + exclude = map(lambda x: x.lower(), exclude) - _verbose = self.dst.verbose - self.dst.verbose = 0 - try: - self.dst.table(self.table) - if self.dst.results: - colmap = {} - for a in self.dst.results: - colmap[a[3].lower()] = a[4] - cols = self.__filter__(colmap.keys(), include, exclude) - for a in zip(range(len(cols)), cols): - self.bindings[a[0]] = colmap[a[1]] - colmap = None - else: - cols = self.__filter__(include, include, exclude) - finally: - self.dst.verbose = _verbose + _verbose = self.dst.verbose + self.dst.verbose = 0 + try: + self.dst.table(self.table) + if self.dst.results: + colmap = {} + for a in self.dst.results: + colmap[a[3].lower()] = a[4] + cols = self.__filter__(colmap.keys(), include, exclude) + for a in zip(range(len(cols)), cols): + self.bindings[a[0]] = colmap[a[1]] + colmap = None + else: + cols = self.__filter__(include, include, exclude) + finally: + self.dst.verbose = _verbose - self.executor = executor(table, cols) + self.executor = executor(table, cols) - def __str__(self): - return "[%s].[%s]" % (self.dst, self.table) + def __str__(self): + return "[%s].[%s]" % (self.dst, self.table) - def __repr__(self): - return "[%s].[%s]" % (self.dst, self.table) + def __repr__(self): + return "[%s].[%s]" % (self.dst, self.table) - def __getattr__(self, name): - if name == 'columns': - return self.executor.cols + def __getattr__(self, name): + if name == 'columns': + return self.executor.cols - def __filter__(self, values, include, exclude): - cols = map(lambda col: col.lower(), values) - if exclude: - cols = filter(lambda x, ex=exclude: x not in ex, cols) - if include: - cols = filter(lambda x, inc=include: x in inc, cols) - return cols + def __filter__(self, values, include, exclude): + cols = map(lambda col: col.lower(), values) + if exclude: + cols = filter(lambda x, ex=exclude: x not in ex, cols) + if include: + cols = filter(lambda x, inc=include: x in inc, cols) + return cols - def format(self, column, type): - self.bindings[column] = type + def format(self, column, type): + self.bindings[column] = type - def done(self): - if len(self.rows) > 0: - return self.batch() - return 0 + def done(self): + if len(self.rows) > 0: + return self.batch() + return 0 - def batch(self): - self.executor.execute(self.dst, self.rows, self.bindings) - cnt = len(self.rows) - self.total += cnt - self.rows = [] - return cnt + def batch(self): + self.executor.execute(self.dst, self.rows, self.bindings) + cnt = len(self.rows) + self.total += cnt + self.rows = [] + return cnt - def rowxfer(self, line): - self.rows.append(line) - if self.autobatch: self.batch() + def rowxfer(self, line): + self.rows.append(line) + if self.autobatch: self.batch() - def transfer(self, src, where="(1=1)", params=[]): - sql = "select %s from %s where %s" % (", ".join(self.columns), self.table, where) - h, d = src.raw(sql, params) - if d: - map(self.rowxfer, d) - return self.done() - return 0 + def transfer(self, src, where="(1=1)", params=[]): + sql = "select %s from %s where %s" % (", ".join(self.columns), self.table, where) + h, d = src.raw(sql, params) + if d: + map(self.rowxfer, d) + return self.done() + return 0 class Unload: - """Unloads a sql statement to a file with optional formatting of each value.""" - def __init__(self, db, filename, delimiter=",", includeheaders=1): - self.db = db - self.filename = filename - self.delimiter = delimiter - self.includeheaders = includeheaders - self.formatters = {} + """Unloads a sql statement to a file with optional formatting of each value.""" + def __init__(self, db, filename, delimiter=",", includeheaders=1): + self.db = db + self.filename = filename + self.delimiter = delimiter + self.includeheaders = includeheaders + self.formatters = {} - def format(self, o): - if not o: - return "" - o = str(o) - if o.find(",") != -1: - o = "\"\"%s\"\"" % (o) - return o + def format(self, o): + if not o: + return "" + o = str(o) + if o.find(",") != -1: + o = "\"\"%s\"\"" % (o) + return o - def unload(self, sql, mode="w"): - headers, results = self.db.raw(sql) - w = open(self.filename, mode) - if self.includeheaders: - w.write("%s\n" % (self.delimiter.join(map(lambda x: x[0], headers)))) - if results: - for a in results: - w.write("%s\n" % (self.delimiter.join(map(self.format, a)))) - w.flush() - w.close() + def unload(self, sql, mode="w"): + headers, results = self.db.raw(sql) + w = open(self.filename, mode) + if self.includeheaders: + w.write("%s\n" % (self.delimiter.join(map(lambda x: x[0], headers)))) + if results: + for a in results: + w.write("%s\n" % (self.delimiter.join(map(self.format, a)))) + w.flush() + w.close() class Schema: - """Produces a Schema object which represents the database schema for a table""" - def __init__(self, db, table, owner=None, full=0, sort=1): - self.db = db - self.table = table - self.owner = owner - self.full = full - self.sort = sort - _verbose = self.db.verbose - self.db.verbose = 0 - try: - if table: self.computeschema() - finally: - self.db.verbose = _verbose + """Produces a Schema object which represents the database schema for a table""" + def __init__(self, db, table, owner=None, full=0, sort=1): + self.db = db + self.table = table + self.owner = owner + self.full = full + self.sort = sort + _verbose = self.db.verbose + self.db.verbose = 0 + try: + if table: self.computeschema() + finally: + self.db.verbose = _verbose - def computeschema(self): - self.db.table(self.table, owner=self.owner) - self.columns = [] - # (column name, type_name, size, nullable) - if self.db.results: - self.columns = map(lambda x: (x[3], x[5], x[6], x[10]), self.db.results) - if self.sort: self.columns.sort(lambda x, y: cmp(x[0], y[0])) + def computeschema(self): + self.db.table(self.table, owner=self.owner) + self.columns = [] + # (column name, type_name, size, nullable) + if self.db.results: + self.columns = map(lambda x: (x[3], x[5], x[6], x[10]), self.db.results) + if self.sort: self.columns.sort(lambda x, y: cmp(x[0], y[0])) - self.db.fk(None, self.table) - # (pk table name, pk column name, fk column name, fk name, pk name) - self.imported = [] - if self.db.results: - self.imported = map(lambda x: (x[2], x[3], x[7], x[11], x[12]), self.db.results) - if self.sort: self.imported.sort(lambda x, y: cmp(x[2], y[2])) + self.db.fk(None, self.table) + # (pk table name, pk column name, fk column name, fk name, pk name) + self.imported = [] + if self.db.results: + self.imported = map(lambda x: (x[2], x[3], x[7], x[11], x[12]), self.db.results) + if self.sort: self.imported.sort(lambda x, y: cmp(x[2], y[2])) - self.exported = [] - if self.full: - self.db.fk(self.table, None) - # (pk column name, fk table name, fk column name, fk name, pk name) - if self.db.results: - self.exported = map(lambda x: (x[3], x[6], x[7], x[11], x[12]), self.db.results) - if self.sort: self.exported.sort(lambda x, y: cmp(x[1], y[1])) + self.exported = [] + if self.full: + self.db.fk(self.table, None) + # (pk column name, fk table name, fk column name, fk name, pk name) + if self.db.results: + self.exported = map(lambda x: (x[3], x[6], x[7], x[11], x[12]), self.db.results) + if self.sort: self.exported.sort(lambda x, y: cmp(x[1], y[1])) - self.db.pk(self.table) - self.primarykeys = [] - if self.db.results: - # (column name, key_seq, pk name) - self.primarykeys = map(lambda x: (x[3], x[4], x[5]), self.db.results) - if self.sort: self.primarykeys.sort(lambda x, y: cmp(x[1], y[1])) + self.db.pk(self.table) + self.primarykeys = [] + if self.db.results: + # (column name, key_seq, pk name) + self.primarykeys = map(lambda x: (x[3], x[4], x[5]), self.db.results) + if self.sort: self.primarykeys.sort(lambda x, y: cmp(x[1], y[1])) - try: - self.indices = None - self.db.stat(self.table) - self.indices = [] - # (non-unique, name, type, pos, column name, asc) - if self.db.results: - idxdict = {} - # mxODBC returns a row of None's, so filter it out - idx = map(lambda x: (x[3], x[5].strip(), x[6], x[7], x[8]), filter(lambda x: x[5], self.db.results)) - def cckmp(x, y): - c = cmp(x[1], y[1]) - if c == 0: c = cmp(x[3], y[3]) - return c - # sort this regardless, this gets the indicies lined up - idx.sort(cckmp) - for a in idx: - if not idxdict.has_key(a[1]): - idxdict[a[1]] = [] - idxdict[a[1]].append(a) - self.indices = idxdict.values() - if self.sort: self.indices.sort(lambda x, y: cmp(x[0][1], y[0][1])) - except: - pass + try: + self.indices = None + self.db.stat(self.table) + self.indices = [] + # (non-unique, name, type, pos, column name, asc) + if self.db.results: + idxdict = {} + # mxODBC returns a row of None's, so filter it out + idx = map(lambda x: (x[3], x[5].strip(), x[6], x[7], x[8]), filter(lambda x: x[5], self.db.results)) + def cckmp(x, y): + c = cmp(x[1], y[1]) + if c == 0: c = cmp(x[3], y[3]) + return c + # sort this regardless, this gets the indicies lined up + idx.sort(cckmp) + for a in idx: + if not idxdict.has_key(a[1]): + idxdict[a[1]] = [] + idxdict[a[1]].append(a) + self.indices = idxdict.values() + if self.sort: self.indices.sort(lambda x, y: cmp(x[0][1], y[0][1])) + except: + pass - def __str__(self): - d = [] - d.append("Table") - d.append(" " + self.table) - d.append("\nPrimary Keys") - for a in self.primarykeys: - d.append(" %s {%s}" % (a[0], a[2])) - d.append("\nImported (Foreign) Keys") - for a in self.imported: - d.append(" %s (%s.%s) {%s}" % (a[2], a[0], a[1], a[3])) - if self.full: - d.append("\nExported (Referenced) Keys") - for a in self.exported: - d.append(" %s (%s.%s) {%s}" % (a[0], a[1], a[2], a[3])) - d.append("\nColumns") - for a in self.columns: - nullable = choose(a[3], "nullable", "non-nullable") - d.append(" %-20s %s(%s), %s" % (a[0], a[1], a[2], nullable)) - d.append("\nIndices") - if self.indices is None: - d.append(" (failed)") - else: - for a in self.indices: - unique = choose(a[0][0], "non-unique", "unique") - cname = ", ".join(map(lambda x: x[4], a)) - d.append(" %s index {%s} on (%s)" % (unique, a[0][1], cname)) - return "\n".join(d) + def __str__(self): + d = [] + d.append("Table") + d.append(" " + self.table) + d.append("\nPrimary Keys") + for a in self.primarykeys: + d.append(" %s {%s}" % (a[0], a[2])) + d.append("\nImported (Foreign) Keys") + for a in self.imported: + d.append(" %s (%s.%s) {%s}" % (a[2], a[0], a[1], a[3])) + if self.full: + d.append("\nExported (Referenced) Keys") + for a in self.exported: + d.append(" %s (%s.%s) {%s}" % (a[0], a[1], a[2], a[3])) + d.append("\nColumns") + for a in self.columns: + nullable = choose(a[3], "nullable", "non-nullable") + d.append(" %-20s %s(%s), %s" % (a[0], a[1], a[2], nullable)) + d.append("\nIndices") + if self.indices is None: + d.append(" (failed)") + else: + for a in self.indices: + unique = choose(a[0][0], "non-unique", "unique") + cname = ", ".join(map(lambda x: x[4], a)) + d.append(" %s index {%s} on (%s)" % (unique, a[0][1], cname)) + return "\n".join(d) class IniParser: - def __init__(self, cfg, key='name'): - self.key = key - self.records = {} - self.ctypeRE = re.compile("\[(jdbc|odbc|default)\]") - self.entryRE = re.compile("([a-zA-Z]+)[ \t]*=[ \t]*(.*)") - self.cfg = cfg - self.parse() + def __init__(self, cfg, key='name'): + self.key = key + self.records = {} + self.ctypeRE = re.compile("\[(jdbc|odbc|default)\]") + self.entryRE = re.compile("([a-zA-Z]+)[ \t]*=[ \t]*(.*)") + self.cfg = cfg + self.parse() - def parse(self): - fp = open(self.cfg, "r") - data = fp.readlines() - fp.close() - lines = filter(lambda x: len(x) > 0 and x[0] not in ['#', ';'], map(lambda x: x.strip(), data)) - current = None - for i in range(len(lines)): - line = lines[i] - g = self.ctypeRE.match(line) - if g: # a section header - current = {} - if not self.records.has_key(g.group(1)): - self.records[g.group(1)] = [] - self.records[g.group(1)].append(current) - else: - g = self.entryRE.match(line) - if g: - current[g.group(1)] = g.group(2) + def parse(self): + fp = open(self.cfg, "r") + data = fp.readlines() + fp.close() + lines = filter(lambda x: len(x) > 0 and x[0] not in ['#', ';'], map(lambda x: x.strip(), data)) + current = None + for i in range(len(lines)): + line = lines[i] + g = self.ctypeRE.match(line) + if g: # a section header + current = {} + if not self.records.has_key(g.group(1)): + self.records[g.group(1)] = [] + self.records[g.group(1)].append(current) + else: + g = self.entryRE.match(line) + if g: + current[g.group(1)] = g.group(2) - def __getitem__(self, (ctype, skey)): - if skey == self.key: return self.records[ctype][0][skey] - t = filter(lambda x, p=self.key, s=skey: x[p] == s, self.records[ctype]) - if not t or len(t) > 1: - raise KeyError, "invalid key ('%s', '%s')" % (ctype, skey) - return t[0] + def __getitem__(self, (ctype, skey)): + if skey == self.key: return self.records[ctype][0][skey] + t = filter(lambda x, p=self.key, s=skey: x[p] == s, self.records[ctype]) + if not t or len(t) > 1: + raise KeyError, "invalid key ('%s', '%s')" % (ctype, skey) + return t[0] def random_table_name(prefix, num_chars): - import random - d = [prefix, '_'] - i = 0 - while i < num_chars: - d.append(chr(int(100 * random.random()) % 26 + ord('A'))) - i += 1 - return "".join(d) + import random + d = [prefix, '_'] + i = 0 + while i < num_chars: + d.append(chr(int(100 * random.random()) % 26 + ord('A'))) + i += 1 + return "".join(d) class ResultSetRow: - def __init__(self, rs, row): - self.row = row - self.rs = rs - def __getitem__(self, i): - if type(i) == type(""): - i = self.rs.index(i) - return self.row[i] - def __getslice__(self, i, j): - if type(i) == type(""): i = self.rs.index(i) - if type(j) == type(""): j = self.rs.index(j) - return self.row[i:j] - def __len__(self): - return len(self.row) - def __repr__(self): - return str(self.row) + def __init__(self, rs, row): + self.row = row + self.rs = rs + def __getitem__(self, i): + if type(i) == type(""): + i = self.rs.index(i) + return self.row[i] + def __getslice__(self, i, j): + if type(i) == type(""): i = self.rs.index(i) + if type(j) == type(""): j = self.rs.index(j) + return self.row[i:j] + def __len__(self): + return len(self.row) + def __repr__(self): + return str(self.row) class ResultSet: - def __init__(self, headers, results=[]): - self.headers = map(lambda x: x.upper(), headers) - self.results = results - def index(self, i): - return self.headers.index(i.upper()) - def __getitem__(self, i): - return ResultSetRow(self, self.results[i]) - def __getslice__(self, i, j): - return map(lambda x, rs=self: ResultSetRow(rs, x), self.results[i:j]) - def __repr__(self): - return "<%s instance {cols [%d], rows [%d]} at %s>" % (self.__class__, len(self.headers), len(self.results), id(self)) + def __init__(self, headers, results=[]): + self.headers = map(lambda x: x.upper(), headers) + self.results = results + def index(self, i): + return self.headers.index(i.upper()) + def __getitem__(self, i): + return ResultSetRow(self, self.results[i]) + def __getslice__(self, i, j): + return map(lambda x, rs=self: ResultSetRow(rs, x), self.results[i:j]) + def __repr__(self): + return "<%s instance {cols [%d], rows [%d]} at %s>" % (self.__class__, len(self.headers), len(self.results), id(self)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 17:01:38
|
Revision: 6637 http://jython.svn.sourceforge.net/jython/?rev=6637&view=rev Author: fwierzbicki Date: 2009-08-10 17:01:32 +0000 (Mon, 10 Aug 2009) Log Message: ----------- reindent. Trivial except for the class at the top that had 2 space indents. Modified Paths: -------------- trunk/jython/Lib/os.py Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2009-08-10 16:48:17 UTC (rev 6636) +++ trunk/jython/Lib/os.py 2009-08-10 17:01:32 UTC (rev 6637) @@ -173,60 +173,60 @@ class stat_result: - _stat_members = ( - ('st_mode', _stat.ST_MODE), - ('st_ino', _stat.ST_INO), - ('st_dev', _stat.ST_DEV), - ('st_nlink', _stat.ST_NLINK), - ('st_uid', _stat.ST_UID), - ('st_gid', _stat.ST_GID), - ('st_size', _stat.ST_SIZE), - ('st_atime', _stat.ST_ATIME), - ('st_mtime', _stat.ST_MTIME), - ('st_ctime', _stat.ST_CTIME), - ) + _stat_members = ( + ('st_mode', _stat.ST_MODE), + ('st_ino', _stat.ST_INO), + ('st_dev', _stat.ST_DEV), + ('st_nlink', _stat.ST_NLINK), + ('st_uid', _stat.ST_UID), + ('st_gid', _stat.ST_GID), + ('st_size', _stat.ST_SIZE), + ('st_atime', _stat.ST_ATIME), + ('st_mtime', _stat.ST_MTIME), + ('st_ctime', _stat.ST_CTIME), + ) - def __init__(self, results): - if len(results) != 10: - raise TypeError("stat_result() takes an a 10-sequence") - for (name, index) in stat_result._stat_members: - self.__dict__[name] = results[index] + def __init__(self, results): + if len(results) != 10: + raise TypeError("stat_result() takes an a 10-sequence") + for (name, index) in stat_result._stat_members: + self.__dict__[name] = results[index] - @classmethod - def from_jnastat(cls, s): - results = [] - for meth in (s.mode, s.ino, s.dev, s.nlink, s.uid, s.gid, s.st_size, - s.atime, s.mtime, s.ctime): - try: - results.append(meth()) - except NotImplementedError: - results.append(0) - return cls(results) + @classmethod + def from_jnastat(cls, s): + results = [] + for meth in (s.mode, s.ino, s.dev, s.nlink, s.uid, s.gid, s.st_size, + s.atime, s.mtime, s.ctime): + try: + results.append(meth()) + except NotImplementedError: + results.append(0) + return cls(results) - def __getitem__(self, i): - if i < 0 or i > 9: - raise IndexError(i) - return getattr(self, stat_result._stat_members[i][0]) + def __getitem__(self, i): + if i < 0 or i > 9: + raise IndexError(i) + return getattr(self, stat_result._stat_members[i][0]) - def __setitem__(self, x, value): - raise TypeError("object doesn't support item assignment") + def __setitem__(self, x, value): + raise TypeError("object doesn't support item assignment") - def __setattr__(self, name, value): - if name in [x[0] for x in stat_result._stat_members]: - raise TypeError(name) - raise AttributeError("readonly attribute") + def __setattr__(self, name, value): + if name in [x[0] for x in stat_result._stat_members]: + raise TypeError(name) + raise AttributeError("readonly attribute") - def __len__(self): - return 10 + def __len__(self): + return 10 - def __cmp__(self, other): - if not isinstance(other, stat_result): - return 1 - return cmp(self.__dict__, other.__dict__) + def __cmp__(self, other): + if not isinstance(other, stat_result): + return 1 + return cmp(self.__dict__, other.__dict__) - def __repr__(self): - return repr(tuple(self.__dict__[member[0]] for member - in stat_result._stat_members)) + def __repr__(self): + return repr(tuple(self.__dict__[member[0]] for member + in stat_result._stat_members)) error = OSError @@ -247,7 +247,7 @@ def getcwdu(): """getcwd() -> path - + Return a unicode string representing the current working directory. """ return sys.getCurrentWorkingDir() @@ -514,8 +514,8 @@ # native abs_parent = f.getAbsoluteFile().getParentFile() if not abs_parent: - # root isn't a link - return stat(path) + # root isn't a link + return stat(path) can_parent = abs_parent.getCanonicalFile() if can_parent.getAbsolutePath() == abs_parent.getAbsolutePath(): @@ -1029,7 +1029,7 @@ # def fork(): # """fork() -> pid - # + # # Fork a child process. # Return 0 to child process and PID of child to parent process.""" # return _posix.fork() @@ -1042,7 +1042,7 @@ def wait(): """wait() -> (pid, status) - + Wait for completion of a child process.""" status = jarray.zeros(1, 'i') @@ -1063,7 +1063,7 @@ def fdatasync(fd): """fdatasync(fildes) - + force write of file with filedescriptor to disk. does not force update of metadata. """ @@ -1076,7 +1076,7 @@ def fsync(fd): """fsync(fildes) - + force write of file with filedescriptor to disk. """ _fsync(fd, True) @@ -1085,7 +1085,7 @@ """Internal fsync impl""" rawio = FileDescriptors.get(fd) rawio.checkClosed() - + from java.nio.channels import FileChannel channel = rawio.getChannel() if not isinstance(channel, FileChannel): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 16:48:29
|
Revision: 6636 http://jython.svn.sourceforge.net/jython/?rev=6636&view=rev Author: fwierzbicki Date: 2009-08-10 16:48:17 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Ran these through reindent.py. These are the files that resulted in fairly trivial changes. The files os.py, dbexts.py, and isql.py resulted in large changes, so I'll look at them one at a time. Modified Paths: -------------- trunk/jython/Lib/_rawffi.py trunk/jython/Lib/codeop.py trunk/jython/Lib/datetime.py trunk/jython/Lib/fileinput.py trunk/jython/Lib/javapath.py trunk/jython/Lib/javashell.py trunk/jython/Lib/pkgutil.py trunk/jython/Lib/posixpath.py trunk/jython/Lib/readline.py trunk/jython/Lib/signal.py trunk/jython/Lib/socket.py trunk/jython/Lib/subprocess.py trunk/jython/Lib/telnetlib.py trunk/jython/Lib/threading.py trunk/jython/Lib/unicodedata.py trunk/jython/Lib/zlib.py Modified: trunk/jython/Lib/_rawffi.py =================================================================== --- trunk/jython/Lib/_rawffi.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/_rawffi.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -52,6 +52,3 @@ fnp = FuncPtr(fn, name, argtypes, restype) self.cache[key] = fnp return fnp - - - Modified: trunk/jython/Lib/codeop.py =================================================================== --- trunk/jython/Lib/codeop.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/codeop.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -132,4 +132,3 @@ raise ValueError,"symbol arg must be either single or eval" symbol = CompileMode.getMode(symbol) return Py.compile_command_flags(source,filename,symbol,self._cflags,0) - Modified: trunk/jython/Lib/datetime.py =================================================================== --- trunk/jython/Lib/datetime.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/datetime.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -13,7 +13,7 @@ Sources for time zone and DST data: http://www.twinsun.com/tz/tz-link.htm This was originally copied from the sandbox of the CPython CVS repository. -Thanks to Tim Peters for suggesting using it. +Thanks to Tim Peters for suggesting using it. """ import time as _time @@ -599,9 +599,9 @@ def __neg__(self): # for CPython compatibility, we cannot use # our __class__ here, but need a real timedelta - return timedelta(-self.__days, - -self.__seconds, - -self.__microseconds) + return timedelta(-self.__days, + -self.__seconds, + -self.__microseconds) def __pos__(self): return self @@ -1622,7 +1622,7 @@ if L[-1] == 0: del L[-1] if L[-1] == 0: - del L[-1] + del L[-1] s = ", ".join(map(str, L)) s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s) if self._tzinfo is not None: @@ -2076,4 +2076,3 @@ perverse time zone returns a negative dst()). So a breaking case must be pretty bizarre, and a tzinfo subclass can override fromutc() if it is. """ - Modified: trunk/jython/Lib/fileinput.py =================================================================== --- trunk/jython/Lib/fileinput.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/fileinput.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -324,8 +324,8 @@ try: perm = os.fstat(self._file.fileno()).st_mode except (AttributeError, OSError): - # AttributeError occurs in Jython, where there's no - # os.fstat. + # AttributeError occurs in Jython, where there's no + # os.fstat. self._output = open(self._filename, "w") else: fd = os.open(self._filename, Modified: trunk/jython/Lib/javapath.py =================================================================== --- trunk/jython/Lib/javapath.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/javapath.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -38,7 +38,7 @@ type_name = '%s.' % obj_type.__module__ type_name += obj_type.__name__ return type_name - + def dirname(path): """Return the directory component of a pathname""" path = _tostr(path, "dirname") @@ -83,7 +83,7 @@ return (path[:n], path[n:]) def splitdrive(path): - """Split a pathname into drive and path specifiers. + """Split a pathname into drive and path specifiers. Returns a 2-tuple "(drive,path)"; either part may be empty. """ @@ -260,7 +260,7 @@ """Return an absolute path normalized and symbolic links eliminated""" path = _tostr(path, "realpath") return _realpath(path) - + def _realpath(path): try: return asPyString(File(sys.getPath(path)).getCanonicalPath()) @@ -358,6 +358,3 @@ res = res + c index = index + 1 return res - - - Modified: trunk/jython/Lib/javashell.py =================================================================== --- trunk/jython/Lib/javashell.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/javashell.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -28,7 +28,7 @@ def __warn( *args ): print " ".join( [str( arg ) for arg in args ]) - + class _ShellEnv: """Provide environment derived by spawning a subshell and parsing its environment. Also supports subshell execution functions and provides @@ -69,14 +69,14 @@ if self.cmd is None: msgFmt = "Unable to execute commands in subshell because shell" \ " functionality not implemented for OS %s" \ - " Failed command=%s" + " Failed command=%s" raise OSError( 0, msgFmt % ( os._name, cmd )) - + if isinstance(cmd, basestring): shellCmd = self.cmd + [cmd] else: shellCmd = cmd - + return shellCmd def _formatEnvironment( self, env ): Modified: trunk/jython/Lib/pkgutil.py =================================================================== --- trunk/jython/Lib/pkgutil.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/pkgutil.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -246,7 +246,7 @@ return f.read() finally: f.close() - + def _reopen(self): if self.file and self.file.closed: mod_type = self.etc[2] @@ -454,7 +454,7 @@ if loader is not None: return loader fullname = module.__name__ - elif module_or_name == sys: + elif module_or_name == sys: # Jython sys is not a real module; fake it here for now since # making it a module requires a fair amount of decoupling from # PySystemState Modified: trunk/jython/Lib/posixpath.py =================================================================== --- trunk/jython/Lib/posixpath.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/posixpath.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -227,7 +227,7 @@ """Test whether two pathnames reference the same actual file""" s1 = os.stat(f1) s2 = os.stat(f2) - return samestat(s1, s2) + return samestat(s1, s2) # XXX: Jython currently lacks fstat @@ -244,7 +244,7 @@ __all__.append("sameopenfile") -# XXX: Pure Java stat lacks st_ino/st_dev +# XXX: Pure Java stat lacks st_ino/st_dev if os._native_posix: # Are two stat buffers (obtained from stat, fstat or lstat) # describing the same file? Modified: trunk/jython/Lib/readline.py =================================================================== --- trunk/jython/Lib/readline.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/readline.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -6,9 +6,9 @@ """ try: - from org.gnu.readline import Readline, ReadlineCompleter + from org.gnu.readline import Readline, ReadlineCompleter except ImportError, msg: - raise ImportError, '%s. The readline module requires that java-readline from http://java-readline.sourceforge.net/ be on the classpath' % msg + raise ImportError, '%s. The readline module requires that java-readline from http://java-readline.sourceforge.net/ be on the classpath' % msg __all__ = ["readline"] @@ -55,10 +55,10 @@ """ class DerivedCompleter (ReadlineCompleter): def __init__ (self, method): - self.method = method + self.method = method def completer (self, text, state): - return self.method(text, state) + return self.method(text, state) Readline.setCompleter(DerivedCompleter(completionfunction)) Modified: trunk/jython/Lib/signal.py =================================================================== --- trunk/jython/Lib/signal.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/signal.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -1,22 +1,22 @@ """ This module provides mechanisms to use signal handlers in Python. - + Functions: - + signal(sig,action) -- set the action for a given signal (done) pause(sig) -- wait until a signal arrives [Unix only] alarm(seconds) -- cause SIGALRM after a specified time [Unix only] getsignal(sig) -- get the signal action for a given signal default_int_handler(action) -- default SIGINT handler (done, but acts string) - + Constants: - + SIG_DFL -- used to refer to the system default handler SIG_IGN -- used to ignore the signal NSIG -- number of defined signals - + SIGINT, SIGTERM, etc. -- signal numbers - + *** IMPORTANT NOTICES *** A signal handler function is called with two arguments: the first is the signal number, the second is the interrupted stack frame. @@ -173,7 +173,7 @@ def default_int_handler(sig, frame): """ default_int_handler(...) - + The default handler for SIGINT installed by Python. It raises KeyboardInterrupt. """ @@ -214,7 +214,7 @@ return self.scheduled - now else: return 0 - + def alarm(time): try: SIGALRM Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/socket.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -24,7 +24,7 @@ import time import types -# Java.io classes +# Java.io classes import java.io.BufferedInputStream import java.io.BufferedOutputStream # Java.io exceptions @@ -221,7 +221,7 @@ 'SOCK_RAW', 'SOCK_RDM', 'SOCK_SEQPACKET', 'SOCK_STREAM', 'SOL_SOCKET', 'SO_BROADCAST', 'SO_ERROR', 'SO_KEEPALIVE', 'SO_LINGER', 'SO_OOBINLINE', 'SO_RCVBUF', 'SO_REUSEADDR', 'SO_SNDBUF', 'SO_TIMEOUT', 'TCP_NODELAY', - 'INADDR_ANY', 'INADDR_BROADCAST', 'IPPROTO_TCP', 'IPPROTO_UDP', + 'INADDR_ANY', 'INADDR_BROADCAST', 'IPPROTO_TCP', 'IPPROTO_UDP', 'SocketType', 'error', 'herror', 'gaierror', 'timeout', 'getfqdn', 'gethostbyaddr', 'gethostbyname', 'gethostname', 'socket', 'getaddrinfo', 'getdefaulttimeout', 'setdefaulttimeout', @@ -529,8 +529,8 @@ names = [] addrs = [] for addr in addresses: - names.append(asPyString(addr.getHostName())) - addrs.append(asPyString(addr.getHostAddress())) + names.append(asPyString(addr.getHostName())) + addrs.append(asPyString(addr.getHostAddress())) return (names, addrs) def getfqdn(name=None): @@ -741,7 +741,7 @@ def shutdown(self, how): assert how in (SHUT_RD, SHUT_WR, SHUT_RDWR) if not self.sock_impl: - raise error(errno.ENOTCONN, "Transport endpoint is not connected") + raise error(errno.ENOTCONN, "Transport endpoint is not connected") try: self.sock_impl.shutdown(how) except java.lang.Exception, jlx: @@ -953,8 +953,8 @@ self.sock_impl.close() except java.lang.Exception, jlx: raise _map_exception(jlx) - + class _udpsocket(_nonblocking_api_mixin): sock_impl = None @@ -1027,7 +1027,7 @@ http://bugs.sun.com/view_bug.do?bug_id=6621689 """ try: - # This is the old 2.1 behaviour + # This is the old 2.1 behaviour #assert self.sock_impl # This is amak's preferred interpretation #raise error(errno.ENOTCONN, "Recvfrom on unbound udp socket meaningless operation") @@ -1124,7 +1124,7 @@ if isinstance(_sock, _nonblocking_api_mixin): _sock.close_lock.acquire() try: - _sock.reference_count -=1 + _sock.reference_count -=1 if not _sock.reference_count: _sock.close() self._sock = _closedsocket() Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/subprocess.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -562,7 +562,7 @@ (which takes a String cmdline). This process ruins String cmdlines from the user with escapes or quotes. To avoid this we first parse these cmdlines into an argv. - + Runtime.exec(String) is too naive and useless for this case. """ whitespace = ' \t' @@ -623,7 +623,7 @@ os_info = os._os_map.get(os._name) if os_info is None: os_info = os._os_map.get('posix') - + for shell_command in os_info[1]: executable = shell_command[0] if not os.path.isabs(executable): @@ -1174,7 +1174,7 @@ else: # Assuming file-like object errwrite = stderr.fileno() - + return (p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite) @@ -1184,7 +1184,7 @@ """Determine if the subprocess' stderr should be redirected to stdout """ - return (errwrite == STDOUT or c2pwrite not in (None, PIPE) and + return (errwrite == STDOUT or c2pwrite not in (None, PIPE) and c2pwrite is errwrite) @@ -1196,7 +1196,7 @@ def _setup_env(self, env, builder_env): """Carefully merge env with ProcessBuilder's only overwriting key/values that differ - + System.getenv (Map<String, String>) may be backed by <byte[], byte[]> on UNIX platforms where these are really bytes. ProcessBuilder's env inherits its contents and will Modified: trunk/jython/Lib/telnetlib.py =================================================================== --- trunk/jython/Lib/telnetlib.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/telnetlib.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -38,9 +38,9 @@ import socket import os if os.name == 'java': - from select import cpython_compatible_select as select + from select import cpython_compatible_select as select else: - from select import select + from select import select del os Modified: trunk/jython/Lib/threading.py =================================================================== --- trunk/jython/Lib/threading.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/threading.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -125,10 +125,10 @@ self._thread.join(millis_int, nanos) else: self._thread.join() - + def getName(self): return self._thread.getName() - + def setName(self, name): self._thread.setName(str(name)) Modified: trunk/jython/Lib/unicodedata.py =================================================================== --- trunk/jython/Lib/unicodedata.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/unicodedata.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -91,7 +91,7 @@ if v is None: v = check_segments(codepoint, _segments) if v is not None: - return "%s-%X" % (v[8], codepoint) + return "%s-%X" % (v[8], codepoint) if v is None: if default is not Nonesuch: @@ -126,13 +126,13 @@ v = _eaw.get(codepoint, None) if v is None: v = check_segments(codepoint, _eaw_segments) - + if v is None: if default is not Nonesuch: return default raise ValueError() return v - + def get(unichr, default, fn, getter): codepoint = get_codepoint(unichr, fn) data = _codepoints.get(codepoint, None) @@ -192,24 +192,24 @@ try: from java.text import Normalizer - _forms = { - 'NFC': Normalizer.Form.NFC, - 'NFKC': Normalizer.Form.NFKC, - 'NFD': Normalizer.Form.NFD, - 'NFKD': Normalizer.Form.NFKD - } + _forms = { + 'NFC': Normalizer.Form.NFC, + 'NFKC': Normalizer.Form.NFKC, + 'NFD': Normalizer.Form.NFD, + 'NFKD': Normalizer.Form.NFKD + } - def normalize(form, unistr): - """ - Return the normal form 'form' for the Unicode string unistr. Valid - values for form are 'NFC', 'NFKC', 'NFD', and 'NFKD'. - """ - + def normalize(form, unistr): + """ + Return the normal form 'form' for the Unicode string unistr. Valid + values for form are 'NFC', 'NFKC', 'NFD', and 'NFKD'. + """ + try: normalizer_form = _forms[form] except KeyError: raise ValueError('invalid normalization form') - return Normalizer.normalize(unistr, normalizer_form) + return Normalizer.normalize(unistr, normalizer_form) except ImportError: pass Modified: trunk/jython/Lib/zlib.py =================================================================== --- trunk/jython/Lib/zlib.py 2009-08-09 00:05:01 UTC (rev 6635) +++ trunk/jython/Lib/zlib.py 2009-08-10 16:48:17 UTC (rev 6636) @@ -45,7 +45,7 @@ _valid_flush_modes = (Z_FINISH,) def adler32(s, value=1): - if value != 1: + if value != 1: raise ValueError, "adler32 only support start value of 1" checksum = Adler32() checksum.update(String.getBytes(s, 'iso-8859-1')) @@ -86,7 +86,7 @@ raise error("compressobj may not be used after flush(Z_FINISH)") self.deflater.setInput(string, 0, len(string)) return _get_deflate_data(self.deflater) - + def flush(self, mode=Z_FINISH): if self._ended: raise error("compressobj may not be used after flush(Z_FINISH)") @@ -111,7 +111,7 @@ def decompress(self, string, max_length=0): if self._ended: raise error("decompressobj may not be used after flush()") - + # unused_data is always "" until inflation is finished; then it is # the unused bytes of the input; # unconsumed_tail is whatever input was not used because max_length @@ -132,7 +132,7 @@ self.unconsumed_tail = string[-r:] else: self.unused_data = string[-r:] - + return inflated def flush(self, length=None): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-09 00:05:21
|
Revision: 6635 http://jython.svn.sourceforge.net/jython/?rev=6635&view=rev Author: pjenvey Date: 2009-08-09 00:05:01 +0000 (Sun, 09 Aug 2009) Log Message: ----------- handle Oracle TIMESTAMPTZ/LTZ (currently dropping the tz like cx_oracle does) and specially handle its DATE and NUMERIC refs #1421 Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java trunk/jython/src/org/python/core/Py.java Modified: trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java 2009-08-06 20:17:09 UTC (rev 6634) +++ trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java 2009-08-09 00:05:01 UTC (rev 6635) @@ -16,6 +16,7 @@ import oracle.sql.BLOB; import oracle.sql.ROWID; import org.python.core.Py; +import org.python.core.PyInteger; import org.python.core.PyObject; import java.io.BufferedInputStream; @@ -23,7 +24,9 @@ import java.sql.CallableStatement; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.ResultSetMetaData; import java.sql.SQLException; +import java.sql.Timestamp; import java.sql.Types; /** @@ -66,12 +69,17 @@ switch (type) { - case OracleTypes.ROWID: - stmt.setString(index, (String) object.__tojava__(String.class)); + case Types.DATE: + // Oracle DATE is a timestamp with one second precision + Timestamp timestamp = (Timestamp) object.__tojava__(Timestamp.class); + if (timestamp != Py.NoConversion) { + stmt.setTimestamp(index, timestamp); + } else { + super.setJDBCObject(stmt, index, object, type); + } break; case Types.DECIMAL: - // Oracle is annoying Object input = object.__tojava__(Double.class); @@ -94,6 +102,18 @@ String msg = zxJDBC.getString("errorSettingIndex", vals); throw new SQLException(msg); + + case OracleTypes.ROWID: + stmt.setString(index, (String) object.__tojava__(String.class)); + break; + + case OracleTypes.TIMESTAMPLTZ: + case OracleTypes.TIMESTAMPTZ: + // XXX: We should include time zone information, but cx_Oracle currently + // doesn't either + super.setJDBCObject(stmt, index, object, Types.TIMESTAMP); + break; + default : super.setJDBCObject(stmt, index, object, type); } @@ -108,11 +128,55 @@ switch (type) { + case Types.DATE: + // Oracle DATE is a timestamp with one second precision + obj = Py.newDatetime(set.getTimestamp(col)); + break; + + case Types.NUMERIC: + // Oracle NUMBER encompasses all numeric types + String number = set.getString(col); + if (number == null) { + obj = Py.None; + break; + } + + ResultSetMetaData metaData = set.getMetaData(); + int scale = metaData.getScale(col); + int precision = metaData.getPrecision(col); + if (scale == -127) { + if (precision == 0) { + // Unspecified precision. Normally an integer from a sequence but + // possibly any kind of number + obj = number.indexOf('.') == -1 + ? PyInteger.TYPE.__call__(Py.newString(number)) + : Py.newDecimal(number); + } else { + // Floating point binary precision + obj = Py.newFloat(set.getBigDecimal(col).doubleValue()); + } + } else { + // Decimal precision. A plain integer when without a scale. Maybe a + // plain integer when NUMBER(0,0) (scale and precision unknown, + // similar to NUMBER(0,-127) above) + obj = scale == 0 && (precision != 0 || number.indexOf('.') == -1) + ? PyInteger.TYPE.__call__(Py.newString(number)) + : Py.newDecimal(number); + } + break; + case Types.BLOB: BLOB blob = ((OracleResultSet) set).getBLOB(col); obj = blob == null ? Py.None : Py.java2py(read(blob.getBinaryStream())); break; + case OracleTypes.TIMESTAMPLTZ: + case OracleTypes.TIMESTAMPTZ: + // XXX: We should include time zone information, but cx_Oracle currently + // doesn't either + obj = super.getPyObject(set, col, Types.TIMESTAMP); + break; + case OracleTypes.ROWID: ROWID rowid = ((OracleResultSet) set).getROWID(col); Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-08-06 20:17:09 UTC (rev 6634) +++ trunk/jython/src/org/python/core/Py.java 2009-08-09 00:05:01 UTC (rev 6635) @@ -618,6 +618,15 @@ newInteger(timestamp.getNanos() / 1000)}); } + public static PyObject newDecimal(String decimal) { + if (decimal == null) { + return Py.None; + } + PyObject decimalModule = __builtin__.__import__("decimal"); + PyObject decimalClass = decimalModule.__getattr__("Decimal"); + return decimalClass.__call__(newString(decimal)); + } + public static PyCode newCode(int argcount, String varnames[], String filename, String name, boolean args, boolean keywords, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2009-08-06 20:17:17
|
Revision: 6634 http://jython.svn.sourceforge.net/jython/?rev=6634&view=rev Author: leosoto Date: 2009-08-06 20:17:09 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Handle exceptions when running a JAR file through -jar cmdline switch. Fixes http://bugs.jython.org/issue1405 Modified Paths: -------------- trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2009-08-06 05:10:26 UTC (rev 6633) +++ trunk/jython/src/org/python/util/jython.java 2009-08-06 20:17:09 UTC (rev 6634) @@ -70,6 +70,18 @@ public static boolean shouldRestart; + /** + * Runs a JAR file, by executing the code found in the file __run__.py, + * which should be in the root of the JAR archive. + * + * Note that the __name__ is set to the base name of the JAR file and not + * to "__main__" (for historic reasons). + * + * This method do NOT handle exceptions. the caller SHOULD handle any + * (Py)Exceptions thrown by the code. + * + * @param filename The path to the filename to run. + */ public static void runJar(String filename) { // TBD: this is kind of gross because a local called `zipfile' just magically // shows up in the module's globals. Either `zipfile' should be called @@ -201,7 +213,12 @@ } Py.getSystemState().path.insert(0, new PyString(path)); if (opts.jar) { - runJar(opts.filename); + try { + runJar(opts.filename); + } catch (Throwable t) { + Py.printException(t); + System.exit(-1); + } } else if (opts.filename.equals("-")) { try { interp.locals.__setitem__(new PyString("__file__"), new PyString("<stdin>")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-06 05:10:48
|
Revision: 6633 http://jython.svn.sourceforge.net/jython/?rev=6633&view=rev Author: pjenvey Date: 2009-08-06 05:10:26 +0000 (Thu, 06 Aug 2009) Log Message: ----------- include precision/scale in NUMERIC/TINYINT metadata Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/Fetch.java Modified: trunk/jython/src/com/ziclix/python/sql/Fetch.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/Fetch.java 2009-08-04 23:56:50 UTC (rev 6632) +++ trunk/jython/src/com/ziclix/python/sql/Fetch.java 2009-08-06 05:10:26 UTC (rev 6633) @@ -268,10 +268,12 @@ case Types.BIGINT: case Types.BIT: case Types.DECIMAL: + case Types.NUMERIC: case Types.DOUBLE: case Types.FLOAT: case Types.INTEGER: case Types.SMALLINT: + case Types.TINYINT: a[4] = Py.newInteger(meta.getPrecision(i)); a[5] = Py.newInteger(meta.getScale(i)); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-04 23:56:57
|
Revision: 6632 http://jython.svn.sourceforge.net/jython/?rev=6632&view=rev Author: fwierzbicki Date: 2009-08-04 23:56:50 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Added test and NEWS for http://bugs.jython.org/issue1415 "ast Node creation fails with no arg constructors". Modified Paths: -------------- trunk/jython/Lib/test/test_ast_jy.py trunk/jython/NEWS Modified: trunk/jython/Lib/test/test_ast_jy.py =================================================================== --- trunk/jython/Lib/test/test_ast_jy.py 2009-08-04 23:52:49 UTC (rev 6631) +++ trunk/jython/Lib/test/test_ast_jy.py 2009-08-04 23:56:50 UTC (rev 6632) @@ -37,6 +37,115 @@ self.assert_(isinstance(z[0][0], ast.Lt)) self.assert_(isinstance(z[0][1], ast.Name)) + def test_empty_init(self): + # Jython 2.5.0 did not allow empty constructors for many ast node types + # but CPython ast nodes do allow this. For the moment, I don't see a + # reason to allow construction of the super types (like ast.AST and + # ast.stmt) as well as the op types that are implemented as enums in + # Jython (like boolop), but I've left them in but commented out for + # now. We may need them in the future since CPython allows this, but + # it may fall under implementation detail. + + #ast.AST() + ast.Add() + ast.And() + ast.Assert() + ast.Assign() + ast.Attribute() + ast.AugAssign() + ast.AugLoad() + ast.AugStore() + ast.BinOp() + ast.BitAnd() + ast.BitOr() + ast.BitXor() + ast.BoolOp() + ast.Break() + ast.Call() + ast.ClassDef() + ast.Compare() + ast.Continue() + ast.Del() + ast.Delete() + ast.Dict() + ast.Div() + ast.Ellipsis() + ast.Eq() + ast.Exec() + ast.Expr() + ast.Expression() + ast.ExtSlice() + ast.FloorDiv() + ast.For() + ast.FunctionDef() + ast.GeneratorExp() + ast.Global() + ast.Gt() + ast.GtE() + ast.If() + ast.IfExp() + ast.Import() + ast.ImportFrom() + ast.In() + ast.Index() + ast.Interactive() + ast.Invert() + ast.Is() + ast.IsNot() + ast.LShift() + ast.Lambda() + ast.List() + ast.ListComp() + ast.Load() + ast.Lt() + ast.LtE() + ast.Mod() + ast.Module() + ast.Mult() + ast.Name() + ast.Not() + ast.NotEq() + ast.NotIn() + ast.Num() + ast.Or() + ast.Param() + ast.Pass() + ast.Pow() + ast.Print() + ast.RShift() + ast.Raise() + ast.Repr() + ast.Return() + ast.Slice() + ast.Store() + ast.Str() + ast.Sub() + ast.Subscript() + ast.Suite() + ast.TryExcept() + ast.TryFinally() + ast.Tuple() + ast.UAdd() + ast.USub() + ast.UnaryOp() + ast.While() + ast.With() + ast.Yield() + ast.alias() + ast.arguments() + #ast.boolop() + #ast.cmpop() + ast.comprehension() + #ast.excepthandler() + #ast.expr() + #ast.expr_context() + ast.keyword() + #ast.mod() + #ast.operator() + #ast.slice() + #ast.stmt() + #ast.unaryop() + #============================================================================== def test_main(verbose=None): Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-08-04 23:52:49 UTC (rev 6631) +++ trunk/jython/NEWS 2009-08-04 23:56:50 UTC (rev 6632) @@ -8,6 +8,7 @@ the name of the produced proxy class. - Built in JSR 223 scripting engine, with LiveTribe JSR 223 implementation for JDK 5 Bugs Fixed + - [ 1415 ] ast Node creation fails with no arg constructors - [ 645615 ] cannot import through symbolic links - [ 1366 ] parsing of lamda expression fails - [ 1365 ] continuation lines fail in interactive interpreter This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-04 23:52:58
|
Revision: 6631 http://jython.svn.sourceforge.net/jython/?rev=6631&view=rev Author: fwierzbicki Date: 2009-08-04 23:52:49 +0000 (Tue, 04 Aug 2009) Log Message: ----------- AST codegen, should fix http://bugs.jython.org/issue1415 Modified Paths: -------------- trunk/jython/src/org/python/antlr/ast/Assert.java trunk/jython/src/org/python/antlr/ast/Assign.java trunk/jython/src/org/python/antlr/ast/Attribute.java trunk/jython/src/org/python/antlr/ast/AugAssign.java trunk/jython/src/org/python/antlr/ast/BinOp.java trunk/jython/src/org/python/antlr/ast/BoolOp.java trunk/jython/src/org/python/antlr/ast/Break.java trunk/jython/src/org/python/antlr/ast/Call.java trunk/jython/src/org/python/antlr/ast/ClassDef.java trunk/jython/src/org/python/antlr/ast/Compare.java trunk/jython/src/org/python/antlr/ast/Continue.java trunk/jython/src/org/python/antlr/ast/Delete.java trunk/jython/src/org/python/antlr/ast/Dict.java trunk/jython/src/org/python/antlr/ast/Ellipsis.java trunk/jython/src/org/python/antlr/ast/ExceptHandler.java trunk/jython/src/org/python/antlr/ast/Exec.java trunk/jython/src/org/python/antlr/ast/Expr.java trunk/jython/src/org/python/antlr/ast/Expression.java trunk/jython/src/org/python/antlr/ast/ExtSlice.java trunk/jython/src/org/python/antlr/ast/For.java trunk/jython/src/org/python/antlr/ast/FunctionDef.java trunk/jython/src/org/python/antlr/ast/GeneratorExp.java trunk/jython/src/org/python/antlr/ast/Global.java trunk/jython/src/org/python/antlr/ast/If.java trunk/jython/src/org/python/antlr/ast/IfExp.java trunk/jython/src/org/python/antlr/ast/Import.java trunk/jython/src/org/python/antlr/ast/ImportFrom.java trunk/jython/src/org/python/antlr/ast/Index.java trunk/jython/src/org/python/antlr/ast/Interactive.java trunk/jython/src/org/python/antlr/ast/Lambda.java trunk/jython/src/org/python/antlr/ast/List.java trunk/jython/src/org/python/antlr/ast/ListComp.java trunk/jython/src/org/python/antlr/ast/Module.java trunk/jython/src/org/python/antlr/ast/Name.java trunk/jython/src/org/python/antlr/ast/Num.java trunk/jython/src/org/python/antlr/ast/Pass.java trunk/jython/src/org/python/antlr/ast/Print.java trunk/jython/src/org/python/antlr/ast/Raise.java trunk/jython/src/org/python/antlr/ast/Repr.java trunk/jython/src/org/python/antlr/ast/Return.java trunk/jython/src/org/python/antlr/ast/Slice.java trunk/jython/src/org/python/antlr/ast/Str.java trunk/jython/src/org/python/antlr/ast/Subscript.java trunk/jython/src/org/python/antlr/ast/Suite.java trunk/jython/src/org/python/antlr/ast/TryExcept.java trunk/jython/src/org/python/antlr/ast/TryFinally.java trunk/jython/src/org/python/antlr/ast/Tuple.java trunk/jython/src/org/python/antlr/ast/UnaryOp.java trunk/jython/src/org/python/antlr/ast/While.java trunk/jython/src/org/python/antlr/ast/With.java trunk/jython/src/org/python/antlr/ast/Yield.java trunk/jython/src/org/python/antlr/ast/alias.java trunk/jython/src/org/python/antlr/ast/arguments.java trunk/jython/src/org/python/antlr/ast/comprehension.java trunk/jython/src/org/python/antlr/ast/keyword.java Modified: trunk/jython/src/org/python/antlr/ast/Assert.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Assert.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Assert.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void Assert___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Assert", args, keywords, new String[] - {"test", "msg", "lineno", "col_offset"}, 2); - setTest(ap.getPyObject(0)); - setMsg(ap.getPyObject(1)); + {"test", "msg", "lineno", "col_offset"}, 2, true); + setTest(ap.getPyObject(0, Py.None)); + setMsg(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Assign.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Assign.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Assign.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void Assign___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Assign", args, keywords, new String[] - {"targets", "value", "lineno", "col_offset"}, 2); - setTargets(ap.getPyObject(0)); - setValue(ap.getPyObject(1)); + {"targets", "value", "lineno", "col_offset"}, 2, true); + setTargets(ap.getPyObject(0, Py.None)); + setValue(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Attribute.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Attribute.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Attribute.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -89,10 +89,10 @@ @ExposedMethod public void Attribute___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Attribute", args, keywords, new String[] - {"value", "attr", "ctx", "lineno", "col_offset"}, 3); - setValue(ap.getPyObject(0)); - setAttr(ap.getPyObject(1)); - setCtx(ap.getPyObject(2)); + {"value", "attr", "ctx", "lineno", "col_offset"}, 3, true); + setValue(ap.getPyObject(0, Py.None)); + setAttr(ap.getPyObject(1, Py.None)); + setCtx(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/AugAssign.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AugAssign.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/AugAssign.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void AugAssign___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("AugAssign", args, keywords, new String[] - {"target", "op", "value", "lineno", "col_offset"}, 3); - setTarget(ap.getPyObject(0)); - setOp(ap.getPyObject(1)); - setValue(ap.getPyObject(2)); + {"target", "op", "value", "lineno", "col_offset"}, 3, true); + setTarget(ap.getPyObject(0, Py.None)); + setOp(ap.getPyObject(1, Py.None)); + setValue(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/BinOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BinOp.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/BinOp.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void BinOp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("BinOp", args, keywords, new String[] - {"left", "op", "right", "lineno", "col_offset"}, 3); - setLeft(ap.getPyObject(0)); - setOp(ap.getPyObject(1)); - setRight(ap.getPyObject(2)); + {"left", "op", "right", "lineno", "col_offset"}, 3, true); + setLeft(ap.getPyObject(0, Py.None)); + setOp(ap.getPyObject(1, Py.None)); + setRight(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/BoolOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BoolOp.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/BoolOp.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void BoolOp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("BoolOp", args, keywords, new String[] - {"op", "values", "lineno", "col_offset"}, 2); - setOp(ap.getPyObject(0)); - setValues(ap.getPyObject(1)); + {"op", "values", "lineno", "col_offset"}, 2, true); + setOp(ap.getPyObject(0, Py.None)); + setValues(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Break.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Break.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Break.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -45,7 +45,7 @@ @ExposedMethod public void Break___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Break", args, keywords, new String[] - {"lineno", "col_offset"}, 0); + {"lineno", "col_offset"}, 0, true); int lin = ap.getInt(0, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Call.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Call.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Call.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -115,12 +115,12 @@ @ExposedMethod public void Call___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Call", args, keywords, new String[] - {"func", "args", "keywords", "starargs", "kwargs", "lineno", "col_offset"}, 5); - setFunc(ap.getPyObject(0)); - setArgs(ap.getPyObject(1)); - setKeywords(ap.getPyObject(2)); - setStarargs(ap.getPyObject(3)); - setKwargs(ap.getPyObject(4)); + {"func", "args", "keywords", "starargs", "kwargs", "lineno", "col_offset"}, 5, true); + setFunc(ap.getPyObject(0, Py.None)); + setArgs(ap.getPyObject(1, Py.None)); + setKeywords(ap.getPyObject(2, Py.None)); + setStarargs(ap.getPyObject(3, Py.None)); + setKwargs(ap.getPyObject(4, Py.None)); int lin = ap.getInt(5, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/ClassDef.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDef.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/ClassDef.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -103,11 +103,11 @@ @ExposedMethod public void ClassDef___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ClassDef", args, keywords, new String[] - {"name", "bases", "body", "decorator_list", "lineno", "col_offset"}, 4); - setName(ap.getPyObject(0)); - setBases(ap.getPyObject(1)); - setBody(ap.getPyObject(2)); - setDecorator_list(ap.getPyObject(3)); + {"name", "bases", "body", "decorator_list", "lineno", "col_offset"}, 4, true); + setName(ap.getPyObject(0, Py.None)); + setBases(ap.getPyObject(1, Py.None)); + setBody(ap.getPyObject(2, Py.None)); + setDecorator_list(ap.getPyObject(3, Py.None)); int lin = ap.getInt(4, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Compare.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Compare.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Compare.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void Compare___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Compare", args, keywords, new String[] - {"left", "ops", "comparators", "lineno", "col_offset"}, 3); - setLeft(ap.getPyObject(0)); - setOps(ap.getPyObject(1)); - setComparators(ap.getPyObject(2)); + {"left", "ops", "comparators", "lineno", "col_offset"}, 3, true); + setLeft(ap.getPyObject(0, Py.None)); + setOps(ap.getPyObject(1, Py.None)); + setComparators(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Continue.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Continue.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Continue.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -45,7 +45,7 @@ @ExposedMethod public void Continue___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Continue", args, keywords, new String[] - {"lineno", "col_offset"}, 0); + {"lineno", "col_offset"}, 0, true); int lin = ap.getInt(0, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Delete.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Delete.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Delete.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Delete___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Delete", args, keywords, new String[] - {"targets", "lineno", "col_offset"}, 1); - setTargets(ap.getPyObject(0)); + {"targets", "lineno", "col_offset"}, 1, true); + setTargets(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Dict.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Dict.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Dict.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void Dict___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Dict", args, keywords, new String[] - {"keys", "values", "lineno", "col_offset"}, 2); - setKeys(ap.getPyObject(0)); - setValues(ap.getPyObject(1)); + {"keys", "values", "lineno", "col_offset"}, 2, true); + setKeys(ap.getPyObject(0, Py.None)); + setValues(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Ellipsis.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Ellipsis.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Ellipsis.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -44,7 +44,7 @@ @ExposedMethod public void Ellipsis___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Ellipsis", args, keywords, new String[] - {}, 0); + {}, 0, true); } public Ellipsis() { Modified: trunk/jython/src/org/python/antlr/ast/ExceptHandler.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExceptHandler.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/ExceptHandler.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void ExceptHandler___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ExceptHandler", args, keywords, new String[] - {"type", "name", "body", "lineno", "col_offset"}, 3); - setExceptType(ap.getPyObject(0)); - setName(ap.getPyObject(1)); - setBody(ap.getPyObject(2)); + {"type", "name", "body", "lineno", "col_offset"}, 3, true); + setExceptType(ap.getPyObject(0, Py.None)); + setName(ap.getPyObject(1, Py.None)); + setBody(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Exec.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Exec.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Exec.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void Exec___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Exec", args, keywords, new String[] - {"body", "globals", "locals", "lineno", "col_offset"}, 3); - setBody(ap.getPyObject(0)); - setGlobals(ap.getPyObject(1)); - setLocals(ap.getPyObject(2)); + {"body", "globals", "locals", "lineno", "col_offset"}, 3, true); + setBody(ap.getPyObject(0, Py.None)); + setGlobals(ap.getPyObject(1, Py.None)); + setLocals(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Expr.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Expr.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Expr.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Expr___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Expr", args, keywords, new String[] - {"value", "lineno", "col_offset"}, 1); - setValue(ap.getPyObject(0)); + {"value", "lineno", "col_offset"}, 1, true); + setValue(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Expression.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Expression.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Expression.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -61,8 +61,8 @@ @ExposedMethod public void Expression___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Expression", args, keywords, new String[] - {"body"}, 1); - setBody(ap.getPyObject(0)); + {"body"}, 1, true); + setBody(ap.getPyObject(0, Py.None)); } public Expression(PyObject body) { Modified: trunk/jython/src/org/python/antlr/ast/ExtSlice.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExtSlice.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/ExtSlice.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -61,8 +61,8 @@ @ExposedMethod public void ExtSlice___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ExtSlice", args, keywords, new String[] - {"dims"}, 1); - setDims(ap.getPyObject(0)); + {"dims"}, 1, true); + setDims(ap.getPyObject(0, Py.None)); } public ExtSlice(PyObject dims) { Modified: trunk/jython/src/org/python/antlr/ast/For.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/For.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/For.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -102,11 +102,11 @@ @ExposedMethod public void For___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("For", args, keywords, new String[] - {"target", "iter", "body", "orelse", "lineno", "col_offset"}, 4); - setTarget(ap.getPyObject(0)); - setIter(ap.getPyObject(1)); - setBody(ap.getPyObject(2)); - setOrelse(ap.getPyObject(3)); + {"target", "iter", "body", "orelse", "lineno", "col_offset"}, 4, true); + setTarget(ap.getPyObject(0, Py.None)); + setIter(ap.getPyObject(1, Py.None)); + setBody(ap.getPyObject(2, Py.None)); + setOrelse(ap.getPyObject(3, Py.None)); int lin = ap.getInt(4, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/FunctionDef.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/FunctionDef.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -103,11 +103,11 @@ @ExposedMethod public void FunctionDef___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("FunctionDef", args, keywords, new String[] - {"name", "args", "body", "decorator_list", "lineno", "col_offset"}, 4); - setName(ap.getPyObject(0)); - setArgs(ap.getPyObject(1)); - setBody(ap.getPyObject(2)); - setDecorator_list(ap.getPyObject(3)); + {"name", "args", "body", "decorator_list", "lineno", "col_offset"}, 4, true); + setName(ap.getPyObject(0, Py.None)); + setArgs(ap.getPyObject(1, Py.None)); + setBody(ap.getPyObject(2, Py.None)); + setDecorator_list(ap.getPyObject(3, Py.None)); int lin = ap.getInt(4, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/GeneratorExp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GeneratorExp.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/GeneratorExp.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void GeneratorExp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("GeneratorExp", args, keywords, new String[] - {"elt", "generators", "lineno", "col_offset"}, 2); - setElt(ap.getPyObject(0)); - setGenerators(ap.getPyObject(1)); + {"elt", "generators", "lineno", "col_offset"}, 2, true); + setElt(ap.getPyObject(0, Py.None)); + setGenerators(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Global.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Global.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Global.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Global___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Global", args, keywords, new String[] - {"names", "lineno", "col_offset"}, 1); - setNames(ap.getPyObject(0)); + {"names", "lineno", "col_offset"}, 1, true); + setNames(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/If.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/If.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/If.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void If___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("If", args, keywords, new String[] - {"test", "body", "orelse", "lineno", "col_offset"}, 3); - setTest(ap.getPyObject(0)); - setBody(ap.getPyObject(1)); - setOrelse(ap.getPyObject(2)); + {"test", "body", "orelse", "lineno", "col_offset"}, 3, true); + setTest(ap.getPyObject(0, Py.None)); + setBody(ap.getPyObject(1, Py.None)); + setOrelse(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/IfExp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfExp.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/IfExp.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void IfExp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("IfExp", args, keywords, new String[] - {"test", "body", "orelse", "lineno", "col_offset"}, 3); - setTest(ap.getPyObject(0)); - setBody(ap.getPyObject(1)); - setOrelse(ap.getPyObject(2)); + {"test", "body", "orelse", "lineno", "col_offset"}, 3, true); + setTest(ap.getPyObject(0, Py.None)); + setBody(ap.getPyObject(1, Py.None)); + setOrelse(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Import.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Import.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Import.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Import___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Import", args, keywords, new String[] - {"names", "lineno", "col_offset"}, 1); - setNames(ap.getPyObject(0)); + {"names", "lineno", "col_offset"}, 1, true); + setNames(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportFrom.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/ImportFrom.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -89,10 +89,10 @@ @ExposedMethod public void ImportFrom___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ImportFrom", args, keywords, new String[] - {"module", "names", "level", "lineno", "col_offset"}, 3); - setModule(ap.getPyObject(0)); - setNames(ap.getPyObject(1)); - setLevel(ap.getPyObject(2)); + {"module", "names", "level", "lineno", "col_offset"}, 3, true); + setModule(ap.getPyObject(0, Py.None)); + setNames(ap.getPyObject(1, Py.None)); + setLevel(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Index.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Index.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Index.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -61,8 +61,8 @@ @ExposedMethod public void Index___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Index", args, keywords, new String[] - {"value"}, 1); - setValue(ap.getPyObject(0)); + {"value"}, 1, true); + setValue(ap.getPyObject(0, Py.None)); } public Index(PyObject value) { Modified: trunk/jython/src/org/python/antlr/ast/Interactive.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Interactive.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Interactive.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -61,8 +61,8 @@ @ExposedMethod public void Interactive___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Interactive", args, keywords, new String[] - {"body"}, 1); - setBody(ap.getPyObject(0)); + {"body"}, 1, true); + setBody(ap.getPyObject(0, Py.None)); } public Interactive(PyObject body) { Modified: trunk/jython/src/org/python/antlr/ast/Lambda.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Lambda.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Lambda.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void Lambda___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Lambda", args, keywords, new String[] - {"args", "body", "lineno", "col_offset"}, 2); - setArgs(ap.getPyObject(0)); - setBody(ap.getPyObject(1)); + {"args", "body", "lineno", "col_offset"}, 2, true); + setArgs(ap.getPyObject(0, Py.None)); + setBody(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/List.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/List.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/List.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void List___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("List", args, keywords, new String[] - {"elts", "ctx", "lineno", "col_offset"}, 2); - setElts(ap.getPyObject(0)); - setCtx(ap.getPyObject(1)); + {"elts", "ctx", "lineno", "col_offset"}, 2, true); + setElts(ap.getPyObject(0, Py.None)); + setCtx(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/ListComp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListComp.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/ListComp.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void ListComp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("ListComp", args, keywords, new String[] - {"elt", "generators", "lineno", "col_offset"}, 2); - setElt(ap.getPyObject(0)); - setGenerators(ap.getPyObject(1)); + {"elt", "generators", "lineno", "col_offset"}, 2, true); + setElt(ap.getPyObject(0, Py.None)); + setGenerators(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Module.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Module.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Module.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -61,8 +61,8 @@ @ExposedMethod public void Module___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Module", args, keywords, new String[] - {"body"}, 1); - setBody(ap.getPyObject(0)); + {"body"}, 1, true); + setBody(ap.getPyObject(0, Py.None)); } public Module(PyObject body) { Modified: trunk/jython/src/org/python/antlr/ast/Name.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Name.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Name.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -76,9 +76,9 @@ @ExposedMethod public void Name___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Name", args, keywords, new String[] - {"id", "ctx", "lineno", "col_offset"}, 2); - setId(ap.getPyObject(0)); - setCtx(ap.getPyObject(1)); + {"id", "ctx", "lineno", "col_offset"}, 2, true); + setId(ap.getPyObject(0, Py.None)); + setCtx(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Num.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Num.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Num.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Num___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Num", args, keywords, new String[] - {"n", "lineno", "col_offset"}, 1); - setN(ap.getPyObject(0)); + {"n", "lineno", "col_offset"}, 1, true); + setN(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Pass.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Pass.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Pass.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -45,7 +45,7 @@ @ExposedMethod public void Pass___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Pass", args, keywords, new String[] - {"lineno", "col_offset"}, 0); + {"lineno", "col_offset"}, 0, true); int lin = ap.getInt(0, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Print.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Print.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Print.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -89,10 +89,10 @@ @ExposedMethod public void Print___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Print", args, keywords, new String[] - {"dest", "values", "nl", "lineno", "col_offset"}, 3); - setDest(ap.getPyObject(0)); - setValues(ap.getPyObject(1)); - setNl(ap.getPyObject(2)); + {"dest", "values", "nl", "lineno", "col_offset"}, 3, true); + setDest(ap.getPyObject(0, Py.None)); + setValues(ap.getPyObject(1, Py.None)); + setNl(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Raise.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Raise.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Raise.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void Raise___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Raise", args, keywords, new String[] - {"type", "inst", "tback", "lineno", "col_offset"}, 3); - setExceptType(ap.getPyObject(0)); - setInst(ap.getPyObject(1)); - setTback(ap.getPyObject(2)); + {"type", "inst", "tback", "lineno", "col_offset"}, 3, true); + setExceptType(ap.getPyObject(0, Py.None)); + setInst(ap.getPyObject(1, Py.None)); + setTback(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Repr.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Repr.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Repr.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Repr___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Repr", args, keywords, new String[] - {"value", "lineno", "col_offset"}, 1); - setValue(ap.getPyObject(0)); + {"value", "lineno", "col_offset"}, 1, true); + setValue(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Return.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Return.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Return.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Return___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Return", args, keywords, new String[] - {"value", "lineno", "col_offset"}, 1); - setValue(ap.getPyObject(0)); + {"value", "lineno", "col_offset"}, 1, true); + setValue(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Slice.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Slice.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Slice.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -87,10 +87,10 @@ @ExposedMethod public void Slice___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Slice", args, keywords, new String[] - {"lower", "upper", "step"}, 3); - setLower(ap.getPyObject(0)); - setUpper(ap.getPyObject(1)); - setStep(ap.getPyObject(2)); + {"lower", "upper", "step"}, 3, true); + setLower(ap.getPyObject(0, Py.None)); + setUpper(ap.getPyObject(1, Py.None)); + setStep(ap.getPyObject(2, Py.None)); } public Slice(PyObject lower, PyObject upper, PyObject step) { Modified: trunk/jython/src/org/python/antlr/ast/Str.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Str.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Str.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Str___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Str", args, keywords, new String[] - {"s", "lineno", "col_offset"}, 1); - setS(ap.getPyObject(0)); + {"s", "lineno", "col_offset"}, 1, true); + setS(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Subscript.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Subscript.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Subscript.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void Subscript___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Subscript", args, keywords, new String[] - {"value", "slice", "ctx", "lineno", "col_offset"}, 3); - setValue(ap.getPyObject(0)); - setSlice(ap.getPyObject(1)); - setCtx(ap.getPyObject(2)); + {"value", "slice", "ctx", "lineno", "col_offset"}, 3, true); + setValue(ap.getPyObject(0, Py.None)); + setSlice(ap.getPyObject(1, Py.None)); + setCtx(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Suite.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Suite.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Suite.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -61,8 +61,8 @@ @ExposedMethod public void Suite___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Suite", args, keywords, new String[] - {"body"}, 1); - setBody(ap.getPyObject(0)); + {"body"}, 1, true); + setBody(ap.getPyObject(0, Py.None)); } public Suite(PyObject body) { Modified: trunk/jython/src/org/python/antlr/ast/TryExcept.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryExcept.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/TryExcept.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void TryExcept___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("TryExcept", args, keywords, new String[] - {"body", "handlers", "orelse", "lineno", "col_offset"}, 3); - setBody(ap.getPyObject(0)); - setHandlers(ap.getPyObject(1)); - setOrelse(ap.getPyObject(2)); + {"body", "handlers", "orelse", "lineno", "col_offset"}, 3, true); + setBody(ap.getPyObject(0, Py.None)); + setHandlers(ap.getPyObject(1, Py.None)); + setOrelse(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/TryFinally.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryFinally.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/TryFinally.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void TryFinally___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("TryFinally", args, keywords, new String[] - {"body", "finalbody", "lineno", "col_offset"}, 2); - setBody(ap.getPyObject(0)); - setFinalbody(ap.getPyObject(1)); + {"body", "finalbody", "lineno", "col_offset"}, 2, true); + setBody(ap.getPyObject(0, Py.None)); + setFinalbody(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Tuple.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Tuple.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Tuple.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void Tuple___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Tuple", args, keywords, new String[] - {"elts", "ctx", "lineno", "col_offset"}, 2); - setElts(ap.getPyObject(0)); - setCtx(ap.getPyObject(1)); + {"elts", "ctx", "lineno", "col_offset"}, 2, true); + setElts(ap.getPyObject(0, Py.None)); + setCtx(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/UnaryOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/UnaryOp.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/UnaryOp.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void UnaryOp___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("UnaryOp", args, keywords, new String[] - {"op", "operand", "lineno", "col_offset"}, 2); - setOp(ap.getPyObject(0)); - setOperand(ap.getPyObject(1)); + {"op", "operand", "lineno", "col_offset"}, 2, true); + setOp(ap.getPyObject(0, Py.None)); + setOperand(ap.getPyObject(1, Py.None)); int lin = ap.getInt(2, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/While.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/While.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/While.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -88,10 +88,10 @@ @ExposedMethod public void While___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("While", args, keywords, new String[] - {"test", "body", "orelse", "lineno", "col_offset"}, 3); - setTest(ap.getPyObject(0)); - setBody(ap.getPyObject(1)); - setOrelse(ap.getPyObject(2)); + {"test", "body", "orelse", "lineno", "col_offset"}, 3, true); + setTest(ap.getPyObject(0, Py.None)); + setBody(ap.getPyObject(1, Py.None)); + setOrelse(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/With.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/With.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/With.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -89,10 +89,10 @@ @ExposedMethod public void With___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("With", args, keywords, new String[] - {"context_expr", "optional_vars", "body", "lineno", "col_offset"}, 3); - setContext_expr(ap.getPyObject(0)); - setOptional_vars(ap.getPyObject(1)); - setBody(ap.getPyObject(2)); + {"context_expr", "optional_vars", "body", "lineno", "col_offset"}, 3, true); + setContext_expr(ap.getPyObject(0, Py.None)); + setOptional_vars(ap.getPyObject(1, Py.None)); + setBody(ap.getPyObject(2, Py.None)); int lin = ap.getInt(3, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/Yield.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Yield.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/Yield.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -62,8 +62,8 @@ @ExposedMethod public void Yield___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("Yield", args, keywords, new String[] - {"value", "lineno", "col_offset"}, 1); - setValue(ap.getPyObject(0)); + {"value", "lineno", "col_offset"}, 1, true); + setValue(ap.getPyObject(0, Py.None)); int lin = ap.getInt(1, -1); if (lin != -1) { setLineno(lin); Modified: trunk/jython/src/org/python/antlr/ast/alias.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/alias.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/alias.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -76,9 +76,9 @@ @ExposedMethod public void alias___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("alias", args, keywords, new String[] - {"name", "asname"}, 2); - setName(ap.getPyObject(0)); - setAsname(ap.getPyObject(1)); + {"name", "asname"}, 2, true); + setName(ap.getPyObject(0, Py.None)); + setAsname(ap.getPyObject(1, Py.None)); } public alias(PyObject name, PyObject asname) { Modified: trunk/jython/src/org/python/antlr/ast/arguments.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/arguments.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/arguments.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -103,11 +103,11 @@ @ExposedMethod public void arguments___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("arguments", args, keywords, new String[] - {"args", "vararg", "kwarg", "defaults"}, 4); - setArgs(ap.getPyObject(0)); - setVararg(ap.getPyObject(1)); - setKwarg(ap.getPyObject(2)); - setDefaults(ap.getPyObject(3)); + {"args", "vararg", "kwarg", "defaults"}, 4, true); + setArgs(ap.getPyObject(0, Py.None)); + setVararg(ap.getPyObject(1, Py.None)); + setKwarg(ap.getPyObject(2, Py.None)); + setDefaults(ap.getPyObject(3, Py.None)); } public arguments(PyObject args, PyObject vararg, PyObject kwarg, PyObject defaults) { Modified: trunk/jython/src/org/python/antlr/ast/comprehension.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/comprehension.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/comprehension.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -87,10 +87,10 @@ @ExposedMethod public void comprehension___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("comprehension", args, keywords, new String[] - {"target", "iter", "ifs"}, 3); - setTarget(ap.getPyObject(0)); - setIter(ap.getPyObject(1)); - setIfs(ap.getPyObject(2)); + {"target", "iter", "ifs"}, 3, true); + setTarget(ap.getPyObject(0, Py.None)); + setIter(ap.getPyObject(1, Py.None)); + setIfs(ap.getPyObject(2, Py.None)); } public comprehension(PyObject target, PyObject iter, PyObject ifs) { Modified: trunk/jython/src/org/python/antlr/ast/keyword.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/keyword.java 2009-08-04 23:50:44 UTC (rev 6630) +++ trunk/jython/src/org/python/antlr/ast/keyword.java 2009-08-04 23:52:49 UTC (rev 6631) @@ -75,9 +75,9 @@ @ExposedMethod public void keyword___init__(PyObject[] args, String[] keywords) { ArgParser ap = new ArgParser("keyword", args, keywords, new String[] - {"arg", "value"}, 2); - setArg(ap.getPyObject(0)); - setValue(ap.getPyObject(1)); + {"arg", "value"}, 2, true); + setArg(ap.getPyObject(0, Py.None)); + setValue(ap.getPyObject(1, Py.None)); } public keyword(PyObject arg, PyObject value) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-04 23:50:50
|
Revision: 6630 http://jython.svn.sourceforge.net/jython/?rev=6630&view=rev Author: fwierzbicki Date: 2009-08-04 23:50:44 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Another step towards fixing #1415. Now handling arg parsing of AST nodes more like CPython (well, once the AST codegen is done). Modified Paths: -------------- trunk/jython/ast/asdl_antlr.py trunk/jython/src/org/python/antlr/AST.java trunk/jython/src/org/python/core/ArgParser.java Modified: trunk/jython/ast/asdl_antlr.py =================================================================== --- trunk/jython/ast/asdl_antlr.py 2009-08-04 19:54:15 UTC (rev 6629) +++ trunk/jython/ast/asdl_antlr.py 2009-08-04 23:50:44 UTC (rev 6630) @@ -481,7 +481,7 @@ self.emit("@ExposedMethod", depth) self.emit("public void %s___init__(PyObject[] args, String[] keywords) {" % clsname, depth) self.emit('ArgParser ap = new ArgParser("%s", args, keywords, new String[]' % clsname, depth + 1) - self.emit('{%s}, 0);' % fpargs, depth + 2) + self.emit('{%s}, %s, true);' % (fpargs, len(fields)), depth + 2) i = 0 for f in fields: self.emit("set%s(ap.getPyObject(%s, Py.None));" % (self.processFieldName(f.name), Modified: trunk/jython/src/org/python/antlr/AST.java =================================================================== --- trunk/jython/src/org/python/antlr/AST.java 2009-08-04 19:54:15 UTC (rev 6629) +++ trunk/jython/src/org/python/antlr/AST.java 2009-08-04 23:50:44 UTC (rev 6630) @@ -1,5 +1,7 @@ package org.python.antlr; +import org.python.core.Py; +import org.python.core.PyException; import org.python.core.PyObject; import org.python.core.PyType; import org.python.expose.ExposedType; @@ -15,4 +17,21 @@ super(objtype); } + public static boolean check(int nargs, int expected, boolean takesZeroArgs) { + if (nargs == expected) { + return true; + } + if (takesZeroArgs && nargs == 0) { + return true; + } + return false; + } + + public static PyException unexpectedCall(int expected, String name) { + String message = " constructor takes 0 positional arguments"; + if (expected != 0) { + message = " constructor takes either 0 or " + expected + " arguments"; + } + return Py.TypeError(name + message); + } } Modified: trunk/jython/src/org/python/core/ArgParser.java =================================================================== --- trunk/jython/src/org/python/core/ArgParser.java 2009-08-04 19:54:15 UTC (rev 6629) +++ trunk/jython/src/org/python/core/ArgParser.java 2009-08-04 23:50:44 UTC (rev 6630) @@ -3,6 +3,8 @@ import java.util.HashSet; import java.util.Set; +import org.python.antlr.AST; + /** * A utility class for handling mixed positional and keyword arguments. * @@ -122,6 +124,16 @@ } } + public ArgParser(String funcname, PyObject[] args, String[] kws, + String[] paramnames, int minargs, boolean takesZeroArgs) { + this(funcname, args, kws); + this.params = paramnames; + check(); + if (!AST.check(args.length - kws.length, minargs, takesZeroArgs)) { + throw AST.unexpectedCall(minargs, funcname); + } + } + /** * Return a required argument as a String. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-04 19:54:23
|
Revision: 6629 http://jython.svn.sourceforge.net/jython/?rev=6629&view=rev Author: fwierzbicki Date: 2009-08-04 19:54:15 +0000 (Tue, 04 Aug 2009) Log Message: ----------- cleanup of antlr/adapter/*Adapter classes in prep to fix http://bugs.jython.org/issue1415. Checked in change to asdl_antlr.py but haven't applied it yet (since this generates lots of changes in the check in that obscures the real changes). Next checkin will apply the codegen. Modified Paths: -------------- trunk/jython/ast/asdl_antlr.py trunk/jython/src/org/python/antlr/adapter/AliasAdapter.java trunk/jython/src/org/python/antlr/adapter/AstAdapters.java trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java trunk/jython/src/org/python/antlr/adapter/ComprehensionAdapter.java trunk/jython/src/org/python/antlr/adapter/ExcepthandlerAdapter.java trunk/jython/src/org/python/antlr/adapter/ExprAdapter.java trunk/jython/src/org/python/antlr/adapter/IdentifierAdapter.java trunk/jython/src/org/python/antlr/adapter/KeywordAdapter.java trunk/jython/src/org/python/antlr/adapter/SliceAdapter.java trunk/jython/src/org/python/antlr/adapter/StmtAdapter.java Modified: trunk/jython/ast/asdl_antlr.py =================================================================== --- trunk/jython/ast/asdl_antlr.py 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/ast/asdl_antlr.py 2009-08-04 19:54:15 UTC (rev 6629) @@ -481,10 +481,10 @@ self.emit("@ExposedMethod", depth) self.emit("public void %s___init__(PyObject[] args, String[] keywords) {" % clsname, depth) self.emit('ArgParser ap = new ArgParser("%s", args, keywords, new String[]' % clsname, depth + 1) - self.emit('{%s}, %s);' % (fpargs, len(fields)), depth + 2) + self.emit('{%s}, 0);' % fpargs, depth + 2) i = 0 for f in fields: - self.emit("set%s(ap.getPyObject(%s));" % (self.processFieldName(f.name), + self.emit("set%s(ap.getPyObject(%s, Py.None));" % (self.processFieldName(f.name), str(i)), depth+1) i += 1 if str(name) in ('stmt', 'expr', 'excepthandler'): Modified: trunk/jython/src/org/python/antlr/adapter/AliasAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/AliasAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/AliasAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -10,24 +10,25 @@ public class AliasAdapter implements AstAdapter { public Object py2ast(PyObject o) { - if (o == null) { - return o; - } if (o instanceof alias) { return o; } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to alias node"); + return null; } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } return (PyObject)o; } public List iter2ast(PyObject iter) { List<alias> aliases = new ArrayList<alias>(); - for(Object o : (Iterable)iter) { - aliases.add((alias)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + aliases.add((alias)py2ast((PyObject)o)); + } } return aliases; } Modified: trunk/jython/src/org/python/antlr/adapter/AstAdapters.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/AstAdapters.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/AstAdapters.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -60,12 +60,11 @@ return (expr)exprAdapter.py2ast(o); } - public static int py2int(Object o) { + public static Integer py2int(Object o) { if (o == null || o instanceof Integer) { return (Integer)o; } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to int node"); + return null; } public static String py2identifier(PyObject o) { @@ -75,7 +74,8 @@ public static expr_contextType py2expr_context(Object o) { if (o == null || o instanceof expr_contextType) { return (expr_contextType)o; - } else if (o instanceof PyObject) { + } + if (o instanceof PyObject && o != Py.None) { switch (((PyObject)o).asInt()) { case 1: return expr_contextType.Load; @@ -89,10 +89,11 @@ return expr_contextType.AugStore; case 6: return expr_contextType.Param; + default: + return expr_contextType.UNDEFINED; } } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to expr_context node"); + return expr_contextType.UNDEFINED; } public static slice py2slice(PyObject o) { @@ -105,17 +106,16 @@ //XXX: Unnecessary but needs to be fixed in the code generation of asdl_antlr.py public static Object py2string(Object o) { - if (o == null || o instanceof PyString) { + if (o instanceof PyString) { return o; } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to string node"); + return null; } public static operatorType py2operator(Object o) { if (o == null || o instanceof operatorType) { return (operatorType)o; - } else if (o instanceof PyObject) { + } else if (o instanceof PyObject && o != Py.None) { switch (((PyObject)o).asInt()) { case 1: return operatorType.Add; @@ -141,10 +141,11 @@ return operatorType.BitAnd; case 12: return operatorType.FloorDiv; + default: + return operatorType.UNDEFINED; } } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to operator node"); + return operatorType.UNDEFINED; } public static PyObject operator2py(operatorType o) { @@ -173,8 +174,9 @@ return new BitAnd(); case FloorDiv: return new FloorDiv(); + default: + return Py.None; } - return Py.None; } public static PyObject boolop2py(boolopType o) { @@ -183,8 +185,9 @@ return new And(); case Or: return new Or(); + default: + return Py.None; } - return Py.None; } public static PyObject cmpop2py(cmpopType o) { @@ -209,8 +212,9 @@ return new In(); case NotIn: return new NotIn(); + default: + return Py.None; } - return Py.None; } public static PyObject unaryop2py(unaryopType o) { @@ -223,8 +227,9 @@ return new UAdd(); case USub: return new USub(); + default: + return Py.None; } - return Py.None; } @@ -242,31 +247,33 @@ return new AugStore(); case Param: return new Param(); + default: + return Py.None; } - return Py.None; } public static boolopType py2boolop(Object o) { if (o == null || o instanceof boolopType) { return (boolopType)o; - } else if (o instanceof PyObject) { + } + if (o instanceof PyObject && o != Py.None) { switch (((PyObject)o).asInt()) { case 1: return boolopType.And; case 2: return boolopType.Or; + default: + return boolopType.UNDEFINED; } } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to boolop node"); + return boolopType.UNDEFINED; } public static arguments py2arguments(Object o) { - if (o == null || o instanceof arguments) { + if (o instanceof arguments) { return (arguments)o; } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to arguments node"); + return null; } //XXX: clearly this isn't necessary -- need to adjust the code generation. @@ -275,18 +282,17 @@ } public static Boolean py2bool(Object o) { - if (o == null || o instanceof Boolean) { + if (o instanceof Boolean) { return (Boolean)o; } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to Boolean node"); + return null; } public static unaryopType py2unaryop(Object o) { if (o == null || o instanceof unaryopType) { return (unaryopType)o; } - if (o instanceof PyObject) { + if (o instanceof PyObject && o != Py.None) { switch (((PyObject)o).asInt()) { case 1: return unaryopType.Invert; @@ -296,10 +302,10 @@ return unaryopType.UAdd; case 4: return unaryopType.USub; + default: + return unaryopType.UNDEFINED; } } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to unaryop node"); + return unaryopType.UNDEFINED; } - } Modified: trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/CmpopAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -20,34 +20,39 @@ public class CmpopAdapter implements AstAdapter { public Object py2ast(PyObject o) { - switch ((o).asInt()) { - case 1: - return cmpopType.Eq; - case 2: - return cmpopType.NotEq; - case 3: - return cmpopType.Lt; - case 4: - return cmpopType.LtE; - case 5: - return cmpopType.Gt; - case 6: - return cmpopType.GtE; - case 7: - return cmpopType.Is; - case 8: - return cmpopType.IsNot; - case 9: - return cmpopType.In; - case 10: - return cmpopType.NotIn; + if (o != Py.None) { + switch ((o).asInt()) { + case 1: + return cmpopType.Eq; + case 2: + return cmpopType.NotEq; + case 3: + return cmpopType.Lt; + case 4: + return cmpopType.LtE; + case 5: + return cmpopType.Gt; + case 6: + return cmpopType.GtE; + case 7: + return cmpopType.Is; + case 8: + return cmpopType.IsNot; + case 9: + return cmpopType.In; + case 10: + return cmpopType.NotIn; + default: + return cmpopType.UNDEFINED; + } } - - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to cmpop node"); + return cmpopType.UNDEFINED; } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } switch ((cmpopType)o) { case Eq: return new Eq(); @@ -69,14 +74,17 @@ return new In(); case NotIn: return new NotIn(); + default: + return Py.None; } - return Py.None; } public List iter2ast(PyObject iter) { List<cmpopType> cmpops = new ArrayList<cmpopType>(); - for(Object o : (Iterable)iter) { - cmpops.add((cmpopType)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + cmpops.add((cmpopType)py2ast((PyObject)o)); + } } return cmpops; } Modified: trunk/jython/src/org/python/antlr/adapter/ComprehensionAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/ComprehensionAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/ComprehensionAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -10,24 +10,25 @@ public class ComprehensionAdapter implements AstAdapter { public Object py2ast(PyObject o) { - if (o == null) { - return o; - } if (o instanceof comprehension) { return o; } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to comprehension node"); + return null; } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } return (PyObject)o; } public List iter2ast(PyObject iter) { List<comprehension> comprehensions = new ArrayList<comprehension>(); - for(Object o : (Iterable)iter) { - comprehensions.add((comprehension)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + comprehensions.add((comprehension)py2ast((PyObject)o)); + } } return comprehensions; } Modified: trunk/jython/src/org/python/antlr/adapter/ExcepthandlerAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/ExcepthandlerAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/ExcepthandlerAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -10,27 +10,26 @@ public class ExcepthandlerAdapter implements AstAdapter { public Object py2ast(PyObject o) { - if (o == null) { - return o; - } if (o instanceof ExceptHandler) { return o; } - - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to excepthandler node"); + return null; } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } return (PyObject)o; } public List iter2ast(PyObject iter) { List<ExceptHandler> excepthandlers = new ArrayList<ExceptHandler>(); - for(Object o : (Iterable)iter) { - excepthandlers.add((ExceptHandler)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + excepthandlers.add((ExceptHandler)py2ast((PyObject)o)); + } } return excepthandlers; } - } Modified: trunk/jython/src/org/python/antlr/adapter/ExprAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/ExprAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/ExprAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -18,30 +18,32 @@ public class ExprAdapter implements AstAdapter { public Object py2ast(PyObject o) { - if (o == null || o instanceof expr) { + if (o instanceof expr) { return o; - } else if (o instanceof PyInteger || o instanceof PyLong || o instanceof PyFloat || o instanceof PyComplex) { + } + if (o instanceof PyInteger || o instanceof PyLong || o instanceof PyFloat || o instanceof PyComplex) { return new Num(o); - } else if (o instanceof PyString || o instanceof PyUnicode) { + } + if (o instanceof PyString || o instanceof PyUnicode) { return new Str(o); - } else if (o == Py.None) { - return null; } - - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to expr node"); + return null; } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } return (PyObject)o; } public List iter2ast(PyObject iter) { List<expr> exprs = new ArrayList<expr>(); - for(Object o : (Iterable)iter) { - exprs.add((expr)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + exprs.add((expr)py2ast((PyObject)o)); + } } return exprs; } - } Modified: trunk/jython/src/org/python/antlr/adapter/IdentifierAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/IdentifierAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/IdentifierAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -3,25 +3,33 @@ import java.util.ArrayList; import java.util.List; +import org.python.core.Py; import org.python.core.PyObject; import org.python.core.PyString; public class IdentifierAdapter implements AstAdapter { public Object py2ast(PyObject o) { + if (o == null || o == Py.None) { + return null; + } return o.toString(); } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } return new PyString(o.toString()); } public List iter2ast(PyObject iter) { List<String> identifiers = new ArrayList<String>(); - for(Object o : (Iterable)iter) { - identifiers.add((String)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + identifiers.add((String)py2ast((PyObject)o)); + } } return identifiers; } - } Modified: trunk/jython/src/org/python/antlr/adapter/KeywordAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/KeywordAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/KeywordAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -10,25 +10,25 @@ public class KeywordAdapter implements AstAdapter { public Object py2ast(PyObject o) { - if (o == null) { - return o; - } if (o instanceof keyword) { return o; } - - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to keyword node"); + return null; } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } return (PyObject)o; } public List iter2ast(PyObject iter) { List<keyword> keywords = new ArrayList<keyword>(); - for(Object o : (Iterable)iter) { - keywords.add((keyword)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + keywords.add((keyword)py2ast((PyObject)o)); + } } return keywords; } Modified: trunk/jython/src/org/python/antlr/adapter/SliceAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/SliceAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/SliceAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -10,27 +10,26 @@ public class SliceAdapter implements AstAdapter { public Object py2ast(PyObject o) { - if (o == null) { - return o; - } if (o instanceof slice) { return o; } - - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to slice node"); + return null; } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } return (PyObject)o; } public List iter2ast(PyObject iter) { List<slice> slices = new ArrayList<slice>(); - for(Object o : (Iterable)iter) { - slices.add((slice)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + slices.add((slice)py2ast((PyObject)o)); + } } return slices; } - } Modified: trunk/jython/src/org/python/antlr/adapter/StmtAdapter.java =================================================================== --- trunk/jython/src/org/python/antlr/adapter/StmtAdapter.java 2009-08-04 00:06:16 UTC (rev 6628) +++ trunk/jython/src/org/python/antlr/adapter/StmtAdapter.java 2009-08-04 19:54:15 UTC (rev 6629) @@ -10,24 +10,25 @@ public class StmtAdapter implements AstAdapter { public Object py2ast(PyObject o) { - if (o == null) { - return o; - } if (o instanceof stmt) { return o; } - //FIXME: investigate the right exception - throw Py.TypeError("Can't convert " + o.getClass().getName() + " to stmt node"); + return null; } public PyObject ast2py(Object o) { + if (o == null) { + return Py.None; + } return (PyObject)o; } public List iter2ast(PyObject iter) { List<stmt> stmts = new ArrayList<stmt>(); - for(Object o : (Iterable)iter) { - stmts.add((stmt)py2ast((PyObject)o)); + if (iter != Py.None) { + for(Object o : (Iterable)iter) { + stmts.add((stmt)py2ast((PyObject)o)); + } } return stmts; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2009-08-04 00:06:26
|
Revision: 6628 http://jython.svn.sourceforge.net/jython/?rev=6628&view=rev Author: thobes Date: 2009-08-04 00:06:16 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Imported patches by "Andrea" for issues 1412 and 1419, also for {PyList,PyTuple}.toArray(Object[]); as well as adding link to core javadoc. Modified Paths: -------------- trunk/jython/build.xml trunk/jython/src/org/python/core/PyList.java trunk/jython/src/org/python/core/PyTuple.java trunk/jython/src/org/python/core/PythonTraceFunction.java Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-08-03 06:30:19 UTC (rev 6627) +++ trunk/jython/build.xml 2009-08-04 00:06:16 UTC (rev 6628) @@ -634,6 +634,7 @@ windowtitle="Jython API documentation" bottom="<a href='http://www.jython.org' target='_top'>Jython homepage</a>" > + <link href="http://java.sun.com/j2se/1.5.0/docs/api/" /> <classpath refid="javadoc.classpath" /> </javadoc> </target> Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2009-08-03 06:30:19 UTC (rev 6627) +++ trunk/jython/src/org/python/core/PyList.java 2009-08-04 00:06:16 UTC (rev 6628) @@ -17,6 +17,8 @@ import java.util.List; import java.util.ListIterator; +import java.lang.reflect.Array; + @ExposedType(name = "list", base = PyObject.class) public class PyList extends PySequenceList implements List { @@ -977,7 +979,7 @@ @Override public synchronized int indexOf(Object o) { - return list.indexOf(o); + return list.indexOf(Py.java2py(o)); } @Override @@ -1134,15 +1136,18 @@ @Override public synchronized Object[] toArray(Object[] a) { - Object copy[] = list.toArray(); - if (a.length < copy.length) { - a = copy; + int size = size(); + Class<?> type = a.getClass().getComponentType(); + if (a.length < size) { + a = (Object[])Array.newInstance(type, size); } - for (int i = 0; i < copy.length; i++) { - a[i] = ((PyObject) copy[i]).__tojava__(Object.class); + for (int i = 0; i < size; i++) { + a[i] = list.get(i).__tojava__(type); } - if (a.length > copy.length) { - a[copy.length] = null; + if (a.length > size) { + for (int i = size; i < a.length; i++) { + a[i] = null; + } } return a; } Modified: trunk/jython/src/org/python/core/PyTuple.java =================================================================== --- trunk/jython/src/org/python/core/PyTuple.java 2009-08-03 06:30:19 UTC (rev 6627) +++ trunk/jython/src/org/python/core/PyTuple.java 2009-08-04 00:06:16 UTC (rev 6628) @@ -7,6 +7,8 @@ import java.util.List; import java.util.ListIterator; +import java.lang.reflect.Array; + import org.python.expose.ExposedMethod; import org.python.expose.ExposedNew; import org.python.expose.ExposedType; @@ -494,7 +496,7 @@ @Override public int indexOf(Object o) { - return getList().indexOf(o); + return getList().indexOf(Py.java2py(o)); } @Override @@ -543,11 +545,12 @@ @Override public Object[] toArray(Object[] converted) { - if (converted.length != array.length) { - converted = new Object[array.length]; + Class<?> type = converted.getClass().getComponentType(); + if (converted.length < array.length) { + converted = (Object[])Array.newInstance(type, array.length); } for (int i = 0; i < array.length; i++) { - converted[i] = array[i].__tojava__(Object.class); + converted[i] = type.cast(array[i].__tojava__(type)); } if (array.length < converted.length) { for (int i = array.length; i < converted.length; i++) { Modified: trunk/jython/src/org/python/core/PythonTraceFunction.java =================================================================== --- trunk/jython/src/org/python/core/PythonTraceFunction.java 2009-08-03 06:30:19 UTC (rev 6627) +++ trunk/jython/src/org/python/core/PythonTraceFunction.java 2009-08-04 00:06:16 UTC (rev 6628) @@ -52,8 +52,9 @@ } public TraceFunction traceException(PyFrame frame, PyException exc) { - return safeCall(frame, - "exception", - new PyTuple(exc.type, exc.value, exc.traceback)); + // We must avoid passing a null to a PyTuple + PyObject safeTraceback = exc.traceback == null ? Py.None : exc.traceback; + return safeCall(frame, "exception", + new PyTuple(exc.type, exc.value, safeTraceback)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-08-03 06:30:29
|
Revision: 6627 http://jython.svn.sourceforge.net/jython/?rev=6627&view=rev Author: cgroves Date: 2009-08-03 06:30:19 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Force static initialization on PyObject subclasses with Class.forName when looking for TypeBuilders. This gets rid of the need to access some static variable on exposed classes before handing them over to Python code. Modified Paths: -------------- trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-08-02 23:52:18 UTC (rev 6626) +++ trunk/jython/src/org/python/core/PyType.java 2009-08-03 06:30:19 UTC (rev 6627) @@ -1126,7 +1126,40 @@ } private static TypeBuilder getBuilder(Class<?> c) { - return classToBuilder == null ? null : classToBuilder.get(c); + if (classToBuilder == null) { + // PyType itself has yet to be initialized. This should be a bootstrap type, so it'll + // go through the builder process in a second + return null; + } + if (c.isPrimitive() || !PyObject.class.isAssignableFrom(c)) { + // If this isn't a PyObject, don't bother forcing it to be initialized to load its + // builder + return null; + } + + // This is a PyObject, call forName to force static initialization on the class so if it has + // a builder, it'll be filled in + SecurityException exc = null; + try { + Class.forName(c.getName(), true, c.getClassLoader()); + } catch (ClassNotFoundException e) { + // Well, this is certainly surprising. + throw new RuntimeException("Got ClassNotFound calling Class.forName on an already " + + " found class.", e); + } catch (ExceptionInInitializerError e) { + throw Py.JavaError(e); + } catch (SecurityException e) { + exc = e; + } + TypeBuilder builder = classToBuilder.get(c); + if (builder == null && exc != null) { + Py.writeComment("type", + "Unable to initialize " + c.getName() + ", a PyObject subclass, due to a " + + "security exception, and no type builder could be found for it. If it's an " + + "exposed type, it may not work properly. Security exception: " + + exc.getMessage()); + } + return builder; } private static PyType createType(Class<?> c, Set<PyJavaType> needsInners) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-08-03 01:14:40
|
Revision: 6626 http://jython.svn.sourceforge.net/jython/?rev=6626&view=rev Author: cgroves Date: 2009-08-02 23:52:18 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Use the Java class name instead of _new_impl for Java constructors. Fixes issue #1393 Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/src/org/python/core/PyJavaType.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-08-02 21:30:31 UTC (rev 6625) +++ trunk/jython/Lib/test/test_java_integration.py 2009-08-02 23:52:18 UTC (rev 6626) @@ -36,6 +36,13 @@ def test_str_doesnt_coerce_to_int(self): self.assertRaises(TypeError, Date, '99-01-01', 1, 1) + def test_class_in_failed_constructor(self): + try: + Dimension(123, 456, 789) + except TypeError, exc: + self.failUnless("java.awt.Dimension" in exc.message) + + class BeanTest(unittest.TestCase): def test_shared_names(self): self.failUnless(callable(Vector.size), Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2009-08-02 21:30:31 UTC (rev 6625) +++ trunk/jython/src/org/python/core/PyJavaType.java 2009-08-02 23:52:18 UTC (rev 6626) @@ -457,7 +457,7 @@ dict.__setitem__(prop.__name__, prop); } - final PyReflectedConstructor reflctr = new PyReflectedConstructor("_new_impl"); + final PyReflectedConstructor reflctr = new PyReflectedConstructor(name); Constructor<?>[] constructors; // No matter the security manager, trying to set the constructor on class to accessible // blows up @@ -475,8 +475,7 @@ } if (PyObject.class.isAssignableFrom(forClass)) { PyObject new_ = new PyNewWrapper(forClass, "__new__", -1, -1) { - - public PyObject new_impl(boolean init, + @Override public PyObject new_impl(boolean init, PyType subtype, PyObject[] args, String[] keywords) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-02 21:30:39
|
Revision: 6625 http://jython.svn.sourceforge.net/jython/?rev=6625&view=rev Author: fwierzbicki Date: 2009-08-02 21:30:31 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Forgot to commit this image, and added left.nav to the docs redirect dir. Modified Paths: -------------- trunk/website/build.xml Added Paths: ----------- trunk/website/images/ trunk/website/images/jython-new-small.gif Modified: trunk/website/build.xml =================================================================== --- trunk/website/build.xml 2009-08-02 19:56:36 UTC (rev 6624) +++ trunk/website/build.xml 2009-08-02 21:30:31 UTC (rev 6625) @@ -49,6 +49,9 @@ <copy todir="dist/css"> <fileset dir="css"/> </copy> + <copy todir="dist/images"> + <fileset dir="images"/> + </copy> <copy todir="dist/checksums"> <fileset dir="checksums"/> </copy> @@ -75,6 +78,11 @@ <include name="left.nav"/> </fileset> </copy> + <copy todir="dist/docs"> + <fileset dir="."> + <include name="left.nav"/> + </fileset> + </copy> <copy todir="dist/graphics"> <fileset dir="."> <include name="left.nav"/> Added: trunk/website/images/jython-new-small.gif =================================================================== (Binary files differ) Property changes on: trunk/website/images/jython-new-small.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |