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-16 03:04:18
|
Revision: 6674 http://jython.svn.sourceforge.net/jython/?rev=6674&view=rev Author: fwierzbicki Date: 2009-08-16 03:04:08 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Fix col_offset for some NOT expressions. Modified Paths: -------------- trunk/jython/grammar/Python.g Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-08-16 02:55:25 UTC (rev 6673) +++ trunk/jython/grammar/Python.g 2009-08-16 03:04:08 UTC (rev 6674) @@ -1080,7 +1080,7 @@ //not_test: 'not' not_test | comparison not_test [expr_contextType ctype] returns [Token leftTok] - : NOT nt=not_test[ctype] {$leftTok = $nt.leftTok;} + : NOT nt=not_test[ctype] -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, actions.castExpr($nt.tree)]) | comparison[ctype] {$leftTok = $comparison.leftTok;} ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-16 02:55:32
|
Revision: 6673 http://jython.svn.sourceforge.net/jython/?rev=6673&view=rev Author: fwierzbicki Date: 2009-08-16 02:55:25 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Added tests for BoolOp and parens. Modified Paths: -------------- trunk/jython/Lib/test/test_ast.py Modified: trunk/jython/Lib/test/test_ast.py =================================================================== --- trunk/jython/Lib/test/test_ast.py 2009-08-16 02:51:07 UTC (rev 6672) +++ trunk/jython/Lib/test/test_ast.py 2009-08-16 02:55:25 UTC (rev 6673) @@ -64,6 +64,9 @@ "break", # Continue "continue", + # Parens and BoolOp + "(a == '') and b", + "not (a == '') or b", ] # These are compiled through "single" @@ -326,6 +329,8 @@ ('Module', [('Pass', (1, 0))]), ('Module', [('Break', (1, 0))]), ('Module', [('Continue', (1, 0))]), +('Module', [('Expr', (1, 0), ('BoolOp', (1, 0), ('And',), [('Compare', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('Eq',)], [('Str', (1, 6), '')]), ('Name', (1, 14), 'b', ('Load',))]))]), +('Module', [('Expr', (1, 0), ('BoolOp', (1, 0), ('Or',), [('UnaryOp', (1, 0), ('Not',), ('Compare', (1, 5), ('Name', (1, 5), 'a', ('Load',)), [('Eq',)], [('Str', (1, 10), '')])), ('Name', (1, 17), 'b', ('Load',))]))]), ] single_results = [ ('Interactive', [('Expr', (1, 0), ('BinOp', (1, 0), ('Num', (1, 0), 1), ('Add',), ('Num', (1, 2), 2)))]), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-16 02:51:14
|
Revision: 6672 http://jython.svn.sourceforge.net/jython/?rev=6672&view=rev Author: fwierzbicki Date: 2009-08-16 02:51:07 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Bugfix for test ast generation code. Modified Paths: -------------- trunk/jython/Lib/test/test_ast.py Modified: trunk/jython/Lib/test/test_ast.py =================================================================== --- trunk/jython/Lib/test/test_ast.py 2009-08-16 02:49:27 UTC (rev 6671) +++ trunk/jython/Lib/test/test_ast.py 2009-08-16 02:51:07 UTC (rev 6672) @@ -297,7 +297,7 @@ print kind+"_results = [" for s in statements: print repr(to_tuple(compile(s, "?", kind, 0x400)))+"," - print "]" + print "]" print "main()" raise SystemExit test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-16 02:49:33
|
Revision: 6671 http://jython.svn.sourceforge.net/jython/?rev=6671&view=rev Author: fwierzbicki Date: 2009-08-16 02:49:27 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Better match with CPython for col_offset on BoolOp with left arg in parens. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-08-16 02:36:35 UTC (rev 6670) +++ trunk/jython/grammar/Python.g 2009-08-16 02:49:27 UTC (rev 6671) @@ -1038,10 +1038,15 @@ ; //or_test: and_test ('or' and_test)* -or_test[expr_contextType ctype] +or_test + [expr_contextType ctype] returns [Token leftTok] @after { if ($or != null) { - $or_test.tree = actions.makeBoolOp($left.tree, boolopType.Or, $right); + Token tok = $left.start; + if ($left.leftTok != null) { + tok = $left.leftTok; + } + $or_test.tree = actions.makeBoolOp(tok, $left.tree, boolopType.Or, $right); } } : left=and_test[ctype] @@ -1053,10 +1058,15 @@ ; //and_test: not_test ('and' not_test)* -and_test[expr_contextType ctype] +and_test + [expr_contextType ctype] returns [Token leftTok] @after { if ($and != null) { - $and_test.tree = actions.makeBoolOp($left.tree, boolopType.And, $right); + Token tok = $left.start; + if ($left.leftTok != null) { + tok = $left.leftTok; + } + $and_test.tree = actions.makeBoolOp(tok, $left.tree, boolopType.And, $right); } } : left=not_test[ctype] @@ -1068,18 +1078,21 @@ ; //not_test: 'not' not_test | comparison -not_test[expr_contextType ctype] - : NOT nt=not_test[ctype] +not_test + [expr_contextType ctype] returns [Token leftTok] + : NOT nt=not_test[ctype] {$leftTok = $nt.leftTok;} -> ^(NOT<UnaryOp>[$NOT, unaryopType.Not, actions.castExpr($nt.tree)]) - | comparison[ctype] + | comparison[ctype] {$leftTok = $comparison.leftTok;} ; //comparison: expr (comp_op expr)* -comparison[expr_contextType ctype] +comparison + [expr_contextType ctype] returns [Token leftTok] @init { List cmps = new ArrayList(); } @after { + $leftTok = $left.leftTok; if (!cmps.isEmpty()) { $comparison.tree = new Compare($left.start, actions.castExpr($left.tree), actions.makeCmpOps(cmps), actions.castExprs($right)); @@ -1125,14 +1138,18 @@ //expr: xor_expr ('|' xor_expr)* -expr[expr_contextType ect] +expr + [expr_contextType ect] returns [Token leftTok] scope { expr_contextType ctype; + Token lparen; } @init { $expr::ctype = ect; + $expr::lparen = null; } @after { + $leftTok = $expr::lparen; if ($op != null) { $expr.tree = actions.makeBinOp($left.tree, operatorType.BitOr, $right); } @@ -1342,7 +1359,7 @@ // '`' testlist1 '`' | // NAME | NUMBER | STRING+) atom - : LPAREN + : LPAREN {$expr::lparen = $LPAREN;} ( yield_expr -> yield_expr | testlist_gexp Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-08-16 02:36:35 UTC (rev 6670) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-08-16 02:49:27 UTC (rev 6671) @@ -642,11 +642,11 @@ return result; } - BoolOp makeBoolOp(PythonTree left, boolopType op, List right) { + BoolOp makeBoolOp(Token t, PythonTree left, boolopType op, List right) { List values = new ArrayList(); values.add(left); values.addAll(right); - return new BoolOp(left, op, castExprs(values)); + return new BoolOp(t, op, castExprs(values)); } BinOp makeBinOp(PythonTree left, operatorType op, List rights) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-16 02:36:41
|
Revision: 6670 http://jython.svn.sourceforge.net/jython/?rev=6670&view=rev Author: pjenvey Date: 2009-08-16 02:36:35 +0000 (Sun, 16 Aug 2009) Log Message: ----------- preserve our old exit code behavior Modified Paths: -------------- trunk/jython/Lib/os.py Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2009-08-16 01:32:41 UTC (rev 6669) +++ trunk/jython/Lib/os.py 2009-08-16 02:36:35 UTC (rev 6670) @@ -755,7 +755,7 @@ if _name == 'nt': return returncode else: - return returncode << 8 # Shift left to match old behavior + return returncode def __getattr__(self, name): return getattr(self._stream, name) def __iter__(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-16 01:32:58
|
Revision: 6669 http://jython.svn.sourceforge.net/jython/?rev=6669&view=rev Author: pjenvey Date: 2009-08-16 01:32:41 +0000 (Sun, 16 Aug 2009) Log Message: ----------- changelog r6668, fixes #1434 Modified Paths: -------------- trunk/jython/NEWS Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-08-16 01:30:38 UTC (rev 6668) +++ trunk/jython/NEWS 2009-08-16 01:32:41 UTC (rev 6669) @@ -19,6 +19,7 @@ - [ 1145 ] Jython 2.5 compatibility problem with JSR 223 - [ 1400 ] Evaluating expression via JSR 223 ScriptEngine returns null instead of True/False - [ 1413 ] Array data type (PostgreSQL) is not supported (NPE) + - [ 1434 ] Cannot get return code from a process started with os.popen with Jython 2.5 (worked in 2.2) Jython 2.5.0 The same as rc4. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-16 01:30:56
|
Revision: 6668 http://jython.svn.sourceforge.net/jython/?rev=6668&view=rev Author: pjenvey Date: 2009-08-16 01:30:38 +0000 (Sun, 16 Aug 2009) Log Message: ----------- steal Python3's _wrap_close to fix popen files' close to return the exit status when its non-zero Modified Paths: -------------- trunk/jython/Lib/os.py Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2009-08-16 01:11:01 UTC (rev 6667) +++ trunk/jython/Lib/os.py 2009-08-16 01:30:38 UTC (rev 6668) @@ -732,14 +732,35 @@ """ import subprocess if mode == 'r': - return subprocess.Popen(command, bufsize=bufsize, shell=True, - stdout=subprocess.PIPE).stdout + proc = subprocess.Popen(command, bufsize=bufsize, shell=True, + stdout=subprocess.PIPE) + return _wrap_close(proc.stdout, proc) elif mode == 'w': - return subprocess.Popen(command, bufsize=bufsize, shell=True, - stdin=subprocess.PIPE).stdin + proc = subprocess.Popen(command, bufsize=bufsize, shell=True, + stdin=subprocess.PIPE) + return _wrap_close(proc.stdin, proc) else: raise OSError(errno.EINVAL, strerror(errno.EINVAL)) +# Helper for popen() -- a proxy for a file whose close waits for the process +class _wrap_close(object): + def __init__(self, stream, proc): + self._stream = stream + self._proc = proc + def close(self): + self._stream.close() + returncode = self._proc.wait() + if returncode == 0: + return None + if _name == 'nt': + return returncode + else: + return returncode << 8 # Shift left to match old behavior + def __getattr__(self, name): + return getattr(self._stream, name) + def __iter__(self): + return iter(self._stream) + # os module versions of the popen# methods have different return value # order than popen2 functions This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-16 01:11:20
|
Revision: 6667 http://jython.svn.sourceforge.net/jython/?rev=6667&view=rev Author: pjenvey Date: 2009-08-16 01:11:01 +0000 (Sun, 16 Aug 2009) Log Message: ----------- allow Oracle's touchy DML returning ResultSet to be used here Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java Modified: trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java 2009-08-14 00:55:05 UTC (rev 6666) +++ trunk/jython/src/com/ziclix/python/sql/handler/OracleDataHandler.java 2009-08-16 01:11:01 UTC (rev 6667) @@ -141,9 +141,17 @@ break; } - ResultSetMetaData metaData = set.getMetaData(); - int scale = metaData.getScale(col); - int precision = metaData.getPrecision(col); + int scale; + int precision; + // Oracle's DML returning ResultSet doesn't support getMetaData + try { + ResultSetMetaData metaData = set.getMetaData(); + scale = metaData.getScale(col); + precision = metaData.getPrecision(col); + } catch (SQLException sqle) { + scale = precision = 0; + } + if (scale == -127) { if (precision == 0) { // Unspecified precision. Normally an integer from a sequence but This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-14 00:55:11
|
Revision: 6666 http://jython.svn.sourceforge.net/jython/?rev=6666&view=rev Author: fwierzbicki Date: 2009-08-14 00:55:05 +0000 (Fri, 14 Aug 2009) Log Message: ----------- Move ThreadState parameter pass to linkDynamic Modified Paths: -------------- branches/indy/src/org/python/compiler/IndyTest.java Modified: branches/indy/src/org/python/compiler/IndyTest.java =================================================================== --- branches/indy/src/org/python/compiler/IndyTest.java 2009-08-13 02:49:57 UTC (rev 6665) +++ branches/indy/src/org/python/compiler/IndyTest.java 2009-08-14 00:55:05 UTC (rev 6666) @@ -20,9 +20,7 @@ public class IndyTest { public static void run() throws Throwable { - ThreadState ts = Py.getThreadState(); - System.out.println("foo = " + ts.frame.getname("foo")); - PyObject result = InvokeDynamic.<PyObject>foo(ts, new PyInteger(4), Py.None, + PyObject result = InvokeDynamic.<PyObject>foo(new PyInteger(4), Py.None, Py.EmptyObjects, new PyTuple()); System.out.println("result = " + result); } @@ -43,7 +41,7 @@ PyObject.class // closure ); MethodHandle call = MethodHandles.lookup().findVirtual(PyCode.class, "call", oneArgCall); - call = MethodHandles.insertArguments(call, 0, func_code); + call = MethodHandles.insertArguments(call, 0, func_code, ts); call = MethodHandles.convertArguments(call, type); site.setTarget(call); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-13 02:50:10
|
Revision: 6665 http://jython.svn.sourceforge.net/jython/?rev=6665&view=rev Author: fwierzbicki Date: 2009-08-13 02:49:57 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Adjusted BinOp lineno and col_offset to align better with CPython. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-08-13 01:54:15 UTC (rev 6664) +++ trunk/jython/grammar/Python.g 2009-08-13 02:49:57 UTC (rev 6665) @@ -1180,16 +1180,18 @@ shift_expr @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { if (!ops.isEmpty()) { - $shift_expr.tree = actions.makeBinOp($left.tree, ops, $right); + $shift_expr.tree = actions.makeBinOp($left.tree, ops, $right, toks); } } : left=arith_expr ( ( shift_op right+=arith_expr { ops.add($shift_op.op); + toks.add($shift_op.start); } )+ | @@ -1209,16 +1211,18 @@ arith_expr @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { if (!ops.isEmpty()) { - $arith_expr.tree = actions.makeBinOp($left.tree, ops, $right); + $arith_expr.tree = actions.makeBinOp($left.tree, ops, $right, toks); } } : left=term ( (arith_op right+=term { ops.add($arith_op.op); + toks.add($arith_op.start); } )+ | @@ -1246,16 +1250,18 @@ term @init { List ops = new ArrayList(); + List toks = new ArrayList(); } @after { if (!ops.isEmpty()) { - $term.tree = actions.makeBinOp($left.tree, ops, $right); + $term.tree = actions.makeBinOp($left.tree, ops, $right, toks); } } : left=factor ( (term_op right+=factor { ops.add($term_op.op); + toks.add($term_op.start); } )+ | Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-08-13 01:54:15 UTC (rev 6664) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-08-13 02:49:57 UTC (rev 6665) @@ -658,12 +658,12 @@ return current; } - BinOp makeBinOp(PythonTree left, List ops, List rights) { + BinOp makeBinOp(PythonTree left, List ops, List rights, List toks) { BinOp current = new BinOp(left, castExpr(left), (operatorType)ops.get(0), castExpr(rights.get(0))); for (int i = 1; i< rights.size(); i++) { expr right = castExpr(rights.get(i)); operatorType op = (operatorType)ops.get(i); - current = new BinOp(left, current, op, right); + current = new BinOp((Token)toks.get(i), current, op, right); } return current; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-13 01:54:24
|
Revision: 6664 http://jython.svn.sourceforge.net/jython/?rev=6664&view=rev Author: fwierzbicki Date: 2009-08-13 01:54:15 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Better lineno col_offset match with CPython on elif. Modified Paths: -------------- trunk/jython/grammar/Python.g Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-08-12 03:12:07 UTC (rev 6663) +++ trunk/jython/grammar/Python.g 2009-08-13 01:54:15 UTC (rev 6664) @@ -885,23 +885,23 @@ //if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] if_stmt - : IF test[expr_contextType.Load] COLON ifsuite=suite[false] elif_clause[$test.start]? + : IF test[expr_contextType.Load] COLON ifsuite=suite[false] elif_clause? -> ^(IF<If>[$IF, actions.castExpr($test.tree), actions.castStmts($ifsuite.stypes), actions.makeElse($elif_clause.stypes, $elif_clause.tree)]) ; //not in CPython's Grammar file elif_clause - [Token iftest] returns [List stypes] + returns [List stypes] : else_clause { $stypes = $else_clause.stypes; } | ELIF test[expr_contextType.Load] COLON suite[false] - (e2=elif_clause[$iftest] - -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) + (e2=elif_clause + -> ^(ELIF<If>[$test.start, actions.castExpr($test.tree), actions.castStmts($suite.stypes), actions.makeElse($e2.stypes, $e2.tree)]) | - -> ^(ELIF<If>[$iftest, actions.castExpr($test.tree), actions.castStmts($suite.stypes), new ArrayList<stmt>()]) + -> ^(ELIF<If>[$test.start, actions.castExpr($test.tree), actions.castStmts($suite.stypes), new ArrayList<stmt>()]) ) ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-08-12 03:12:32
|
Revision: 6663 http://jython.svn.sourceforge.net/jython/?rev=6663&view=rev Author: pjenvey Date: 2009-08-12 03:12:07 +0000 (Wed, 12 Aug 2009) Log Message: ----------- cleanup/quiet warnings Modified Paths: -------------- trunk/jython/src/com/ziclix/python/sql/PyConnection.java trunk/jython/src/com/ziclix/python/sql/connect/Connectx.java trunk/jython/src/com/ziclix/python/sql/connect/Lookup.java Modified: trunk/jython/src/com/ziclix/python/sql/PyConnection.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/PyConnection.java 2009-08-11 06:45:00 UTC (rev 6662) +++ trunk/jython/src/com/ziclix/python/sql/PyConnection.java 2009-08-12 03:12:07 UTC (rev 6663) @@ -12,13 +12,11 @@ import java.sql.SQLException; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.python.core.ClassDictInit; import org.python.core.Py; import org.python.core.PyBuiltinMethodSet; -import org.python.core.PyClass; import org.python.core.PyInteger; import org.python.core.PyList; import org.python.core.PyObject; @@ -36,39 +34,25 @@ */ public class PyConnection extends PyObject implements ClassDictInit { - /** - * Field closed - */ + /** True if closed. */ protected boolean closed; - /** - * Field connection - */ - protected Connection connection; - - /** - * Field supportsTransactions - */ + /** Whether transactions are supported. */ protected boolean supportsTransactions; - /** - * Field cursors - */ - private Set cursors; + /** The underlying java.sql.Connection. */ + protected Connection connection; - /** - * Field statements - */ - private Set statements; + /** Underlying cursors. */ + private Set<PyCursor> cursors; - /** - * Field __members__ - */ + /** Underlying statements. */ + private Set<PyStatement> statements; + + /** Field __members__ */ protected static PyList __members__; - /** - * Field __methods__ - */ + /** Field __methods__ */ protected static PyList __methods__; static { @@ -101,11 +85,10 @@ * @throws SQLException */ public PyConnection(Connection connection) throws SQLException { - this.closed = false; - this.cursors = new HashSet(); + this.cursors = new HashSet<PyCursor>(); this.connection = connection; - this.statements = new HashSet(); + this.statements = new HashSet<PyStatement>(); this.supportsTransactions = this.connection.getMetaData().supportsTransactions(); if (this.supportsTransactions) { @@ -120,7 +103,6 @@ */ @Override public String toString() { - try { return String.format("<PyConnection object at %s user='%s', url='%s'>", Py.idstr(this), connection.getMetaData().getUserName(), @@ -136,14 +118,20 @@ * @param dict */ static public void classDictInit(PyObject dict) { - + PyObject version = + Py.newString("$Revision$").__getslice__(Py.newInteger(11), + Py.newInteger(-2)); + dict.__setitem__("__version__", version); dict.__setitem__("autocommit", new PyInteger(0)); - dict.__setitem__("__version__", Py.newString("$Revision$").__getslice__(Py.newInteger(11), Py.newInteger(-2), null)); dict.__setitem__("close", new ConnectionFunc("close", 0, 0, 0, zxJDBC.getString("close"))); - dict.__setitem__("commit", new ConnectionFunc("commit", 1, 0, 0, zxJDBC.getString("commit"))); - dict.__setitem__("cursor", new ConnectionFunc("cursor", 2, 0, 4, zxJDBC.getString("cursor"))); - dict.__setitem__("rollback", new ConnectionFunc("rollback", 3, 0, 0, zxJDBC.getString("rollback"))); - dict.__setitem__("nativesql", new ConnectionFunc("nativesql", 4, 1, 1, zxJDBC.getString("nativesql"))); + dict.__setitem__("commit", new ConnectionFunc("commit", 1, 0, 0, + zxJDBC.getString("commit"))); + dict.__setitem__("cursor", new ConnectionFunc("cursor", 2, 0, 4, + zxJDBC.getString("cursor"))); + dict.__setitem__("rollback", new ConnectionFunc("rollback", 3, 0, 0, + zxJDBC.getString("rollback"))); + dict.__setitem__("nativesql", new ConnectionFunc("nativesql", 4, 1, 1, + zxJDBC.getString("nativesql"))); // hide from python dict.__setitem__("initModule", null); @@ -161,8 +149,8 @@ * @param name * @param value */ + @Override public void __setattr__(String name, PyObject value) { - if ("autocommit".equals(name)) { try { if (this.supportsTransactions) { @@ -171,7 +159,6 @@ } catch (SQLException e) { throw zxJDBC.makeException(zxJDBC.DatabaseError, e); } - return; } @@ -184,8 +171,8 @@ * @param name the name of the attribute of interest * @return the value for the attribute of the specified name */ + @Override public PyObject __findattr_ex__(String name) { - if ("autocommit".equals(name)) { try { return connection.getAutoCommit() ? Py.One : Py.Zero; @@ -240,40 +227,31 @@ } /** - * Close the connection now (rather than whenever __del__ is called). - * The connection will be unusable from this point forward; an Error - * (or subclass) exception will be raised if any operation is attempted - * with the connection. The same applies to all cursor objects trying - * to use the connection. + * Close the connection now (rather than whenever __del__ is called). The connection + * will be unusable from this point forward; an Error (or subclass) exception will be + * raised if any operation is attempted with the connection. The same applies to all + * cursor objects trying to use the connection. */ public void close() { - if (closed) { throw zxJDBC.makeException(zxJDBC.ProgrammingError, "connection is closed"); } - // mark ourselves closed now so that any callbacks we - // get from closing down cursors and statements to not - // try and modify our internal sets + // mark ourselves closed now so that any callbacks we get from closing down + // cursors and statements to not try and modify our internal sets this.closed = true; synchronized (this.cursors) { - - // close the cursors - for (Iterator i = this.cursors.iterator(); i.hasNext();) { - ((PyCursor) i.next()).close(); + for (PyCursor cursor: cursors) { + cursor.close(); } - this.cursors.clear(); } synchronized (this.statements) { - - // close the cursors - for (Iterator i = this.statements.iterator(); i.hasNext();) { - ((PyStatement) i.next()).close(); + for (PyStatement statement : statements) { + statement.close(); } - this.statements.clear(); } @@ -285,15 +263,14 @@ } /** - * Commit any pending transaction to the database. Note that if the - * database supports an auto-commit feature, this must be initially - * off. An interface method may be provided to turn it back on. + * Commit any pending transaction to the database. Note that if the database supports + * an auto-commit feature, this must be initially off. An interface method may be + * provided to turn it back on. * <p/> - * Database modules that do not support transactions should implement - * this method with void functionality. + * Database modules that do not support transactions should implement this method with + * void functionality. */ public void commit() { - if (closed) { throw zxJDBC.makeException(zxJDBC.ProgrammingError, "connection is closed"); } @@ -310,16 +287,13 @@ } /** - * <i>This method is optional since not all databases provide transaction - * support.</i> + * <i>This method is optional since not all databases provide transaction support.</i> * <p/> - * In case a database does provide transactions this method causes the database - * to roll back to the start of any pending transaction. Closing a connection - * without committing the changes first will cause an implicit rollback to be - * performed. + * In case a database does provide transactions this method causes the database to + * roll back to the start of any pending transaction. Closing a connection without + * committing the changes first will cause an implicit rollback to be performed. */ public void rollback() { - if (closed) { throw zxJDBC.makeException(zxJDBC.ProgrammingError, "connection is closed"); } @@ -336,10 +310,10 @@ } /** - * Converts the given SQL statement into the system's native SQL grammar. A - * driver may convert the JDBC sql grammar into its system's native SQL grammar - * prior to sending it; this method returns the native form of the statement - * that the driver would have sent. + * Converts the given SQL statement into the system's native SQL grammar. A driver may + * convert the JDBC sql grammar into its system's native SQL grammar prior to sending + * it; this method returns the native form of the statement that the driver would have + * sent. * * @param nativeSQL * @return the native form of this statement @@ -364,9 +338,9 @@ } /** - * Return a new Cursor Object using the connection. If the database does not - * provide a direct cursor concept, the module will have to emulate cursors - * using other means to the extent needed by this specification. + * Return a new Cursor Object using the connection. If the database does not provide a + * direct cursor concept, the module will have to emulate cursors using other means to + * the extent needed by this specification. * * @return a new cursor using this connection */ @@ -375,9 +349,9 @@ } /** - * Return a new Cursor Object using the connection. If the database does not - * provide a direct cursor concept, the module will have to emulate cursors - * using other means to the extent needed by this specification. + * Return a new Cursor Object using the connection. If the database does not provide a + * direct cursor concept, the module will have to emulate cursors using other means to + * the extent needed by this specification. * * @param dynamicFetch if true, dynamically iterate the result * @return a new cursor using this connection @@ -387,9 +361,9 @@ } /** - * Return a new Cursor Object using the connection. If the database does not - * provide a direct cursor concept, the module will have to emulate cursors - * using other means to the extent needed by this specification. + * Return a new Cursor Object using the connection. If the database does not provide a + * direct cursor concept, the module will have to emulate cursors using other means to + * the extent needed by this specification. * * @param dynamicFetch if true, dynamically iterate the result * @param rsType the type of the underlying ResultSet @@ -397,15 +371,12 @@ * @return a new cursor using this connection */ public PyCursor cursor(boolean dynamicFetch, PyObject rsType, PyObject rsConcur) { - if (closed) { throw zxJDBC.makeException(zxJDBC.ProgrammingError, "connection is closed"); } PyCursor cursor = new PyExtendedCursor(this, dynamicFetch, rsType, rsConcur); - this.cursors.add(cursor); - return cursor; } @@ -415,11 +386,9 @@ * @param cursor */ void remove(PyCursor cursor) { - if (closed) { return; } - this.cursors.remove(cursor); } @@ -429,11 +398,9 @@ * @param statement statement */ void add(PyStatement statement) { - if (closed) { return; } - this.statements.add(statement); } @@ -444,20 +411,20 @@ * @return boolean */ boolean contains(PyStatement statement) { - if (closed) { return false; } - return this.statements.contains(statement); } } class ConnectionFunc extends PyBuiltinMethodSet { + ConnectionFunc(String name, int index, int minargs, int maxargs, String doc) { super(name, index, minargs, maxargs, doc, PyConnection.class); } + @Override public PyObject __call__() { PyConnection c = (PyConnection) __self__; switch (index) { @@ -472,11 +439,12 @@ case 3: c.rollback(); return Py.None; - default : + default: throw info.unexpectedCall(0, false); } } + @Override public PyObject __call__(PyObject arg) { PyConnection c = (PyConnection) __self__; switch (index) { @@ -484,21 +452,23 @@ return c.cursor(arg.__nonzero__()); case 4: return c.nativesql(arg); - default : + default: throw info.unexpectedCall(1, false); } } + @Override public PyObject __call__(PyObject arg1, PyObject arg2, PyObject arg3) { PyConnection c = (PyConnection) __self__; switch (index) { case 2: return c.cursor(arg1.__nonzero__(), arg2, arg3); - default : + default: throw info.unexpectedCall(3, false); } } + @Override public PyObject __call__(PyObject[] args, String[] keywords) { PyConnection c = (PyConnection) __self__; PyArgParser parser = new PyArgParser(args, keywords); @@ -514,7 +484,7 @@ return c.cursor(dynamic.__nonzero__(), rstype, rsconcur); - default : + default: throw info.unexpectedCall(args.length, true); } } Modified: trunk/jython/src/com/ziclix/python/sql/connect/Connectx.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/connect/Connectx.java 2009-08-11 06:45:00 UTC (rev 6662) +++ trunk/jython/src/com/ziclix/python/sql/connect/Connectx.java 2009-08-12 03:12:07 UTC (rev 6663) @@ -35,14 +35,11 @@ public class Connectx extends PyObject { private final String SET = "set"; - private final PyString doc = new PyString("establish a connection through a javax.sql.DataSource or javax.sql.ConnectionPooledDataSource"); + private final PyString doc = + new PyString("establish a connection through a javax.sql.DataSource or " + + "javax.sql.ConnectionPooledDataSource"); - /** - * Constructor Connectx - */ - public Connectx() { - } - + @Override public PyObject __findattr_ex__(String name) { if ("__doc__".equals(name)) { return doc; @@ -53,23 +50,21 @@ /** * Construct a javax.sql.DataSource or javax.sql.ConnectionPooledDataSource */ + @Override public PyObject __call__(PyObject[] args, String[] keywords) { - Connection c = null; PyConnection pc = null; Object datasource = null; PyArgParser parser = new PyArgParser(args, keywords); try { - String _class = (String) parser.arg(0).__tojava__(String.class); - - datasource = Class.forName(_class).newInstance(); + String klass = (String) parser.arg(0).__tojava__(String.class); + datasource = Class.forName(klass).newInstance(); } catch (Exception e) { throw zxJDBC.makeException(zxJDBC.DatabaseError, "unable to instantiate datasource"); } String[] kws = parser.kws(); - for (int i = 0; i < kws.length; i++) { String methodName = kws[i]; @@ -78,21 +73,21 @@ } Object value = parser.kw(kws[i]).__tojava__(Object.class); - if (methodName.length() > SET.length()) { if (!SET.equals(methodName.substring(0, SET.length()))) { - // prepend "set" - invoke(datasource, SET + methodName.substring(0, 1).toUpperCase() + methodName.substring(1), value); + invoke(datasource, SET + methodName.substring(0, 1).toUpperCase() + + methodName.substring(1), value); } else { - // starts with "set" so just pass it on invoke(datasource, methodName, value); } } else { // shorter than "set" so it can't be a full method name - invoke(datasource, SET + methodName.substring(0, 1).toUpperCase() + methodName.substring(1), value); + invoke(datasource, + SET + methodName.substring(0, 1).toUpperCase() + methodName.substring(1), + value); } } @@ -107,7 +102,7 @@ } try { - if ((c == null) || c.isClosed()) { + if (c == null || c.isClosed()) { throw zxJDBC.makeException(zxJDBC.DatabaseError, "unable to establish connection"); } @@ -124,8 +119,9 @@ * * @return String */ + @Override public String toString() { - return "<connectx object instance at " + Py.id(this) + ">"; + return String.format("<connectx object at %s>", Py.id(this)); } /** @@ -136,19 +132,17 @@ * @param Object value */ protected void invoke(Object src, String methodName, Object value) { - Method method = null; - StringBuffer exceptionMsg = new StringBuffer("method [").append(methodName).append("] using arg type ["); + StringBuffer exceptionMsg = new StringBuffer("method ["); + exceptionMsg.append(methodName).append("] using arg type ["); + exceptionMsg.append(value.getClass()).append("], value ["); + exceptionMsg.append(value.toString()).append("]"); - exceptionMsg.append(value.getClass()).append("], value [").append(value.toString()).append("]"); - try { method = getMethod(src.getClass(), methodName, value.getClass()); - if (method == null) { throw zxJDBC.makeException("no such " + exceptionMsg); } - method.invoke(src, new Object[]{value}); } catch (IllegalAccessException e) { throw zxJDBC.makeException("illegal access for " + exceptionMsg); @@ -164,25 +158,23 @@ * is perhaps a primitive and attempt to recurse using the primitive type. Failing * that return null. */ - protected Method getMethod(Class srcClass, String methodName, Class valueClass) { - + protected Method getMethod(Class<?> srcClass, String methodName, Class<?> valueClass) { Method method = null; try { method = srcClass.getMethod(methodName, new Class[]{valueClass}); } catch (NoSuchMethodException e) { - Class primitive = null; + Class<?> primitive = null; try { Field f = valueClass.getField("TYPE"); - - primitive = (Class) f.get(valueClass); + primitive = (Class<?>) f.get(valueClass); } catch (NoSuchFieldException ex) { } catch (IllegalAccessException ex) { } catch (ClassCastException ex) { } - if ((primitive != null) && primitive.isPrimitive()) { + if (primitive != null && primitive.isPrimitive()) { return getMethod(srcClass, methodName, primitive); } } Modified: trunk/jython/src/com/ziclix/python/sql/connect/Lookup.java =================================================================== --- trunk/jython/src/com/ziclix/python/sql/connect/Lookup.java 2009-08-11 06:45:00 UTC (rev 6662) +++ trunk/jython/src/com/ziclix/python/sql/connect/Lookup.java 2009-08-12 03:12:07 UTC (rev 6663) @@ -8,20 +8,31 @@ */ package com.ziclix.python.sql.connect; -import java.sql.*; -import java.util.*; import java.lang.reflect.Field; -import javax.sql.*; -import javax.naming.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Hashtable; -import org.python.core.*; -import com.ziclix.python.sql.*; -import com.ziclix.python.sql.util.*; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.sql.ConnectionPoolDataSource; +import javax.sql.DataSource; +import org.python.core.Py; +import org.python.core.PyObject; +import org.python.core.PyString; + +import com.ziclix.python.sql.PyConnection; +import com.ziclix.python.sql.zxJDBC; +import com.ziclix.python.sql.util.PyArgParser; + /** - * Establish a connection through a JNDI lookup. The bound object can be either a <code>DataSource</code>, - * <code>ConnectionPooledDataSource</code>, <code>Connection</code> or a <code>String</code>. If it's a - * <code>String</code> the value is passed to the DriverManager to obtain a connection, otherwise the + * Establish a connection through a JNDI lookup. The bound object can be either a + * <code>DataSource</code>, <code>ConnectionPooledDataSource</code>, + * <code>Connection</code> or a <code>String</code>. If it's a <code>String</code> the + * value is passed to the DriverManager to obtain a connection, otherwise the * <code>Connection</code> is established using the object. * * @author brian zimmer @@ -30,22 +41,17 @@ */ public class Lookup extends PyObject { - private static final PyString _doc = new PyString("establish a connection through a JNDI lookup"); + private static final PyString _doc = + new PyString("establish a connection through a JNDI lookup"); /** - * Constructor Lookup - */ - public Lookup() { - } - - /** * Method __findattr__ * * @param name * @return PyObject */ + @Override public PyObject __findattr_ex__(String name) { - if ("__doc__".equals(name)) { return _doc; } @@ -54,17 +60,18 @@ } /** - * Expects a single PyString argument which is the JNDI name of the bound Connection or DataSource. - * If any keywords are passed, an attempt is made to match the keyword to a static final Field on - * javax.naming.Context. If the Field is found, the value of the Field is substituted as the key - * and the value of the keyword is the value put in the Hashtable environment. If the Field is not - * found, the key is the keyword with no substitutions. + * Expects a single PyString argument which is the JNDI name of the bound Connection + * or DataSource. If any keywords are passed, an attempt is made to match the keyword + * to a static final Field on javax.naming.Context. If the Field is found, the value + * of the Field is substituted as the key and the value of the keyword is the value + * put in the Hashtable environment. If the Field is not found, the key is the + * keyword with no substitutions. */ + @Override public PyObject __call__(PyObject[] args, String[] keywords) { - Object ref = null; Connection connection = null; - Hashtable env = new Hashtable(); + Hashtable<String, Object> env = new Hashtable<String, Object>(); // figure out the correct params PyArgParser parser = new PyArgParser(args, keywords); @@ -95,7 +102,6 @@ } InitialContext context = null; - try { context = new InitialContext(env); ref = context.lookup((String) jndiName); @@ -106,12 +112,14 @@ try { context.close(); } catch (NamingException e) { + // ok } } } if (ref == null) { - throw zxJDBC.makeException(zxJDBC.ProgrammingError, "object [" + jndiName + "] not found in JNDI"); + throw zxJDBC.makeException(zxJDBC.ProgrammingError, + "object [" + jndiName + "] not found in JNDI"); } try { @@ -122,14 +130,15 @@ } else if (ref instanceof DataSource) { connection = ((DataSource) ref).getConnection(); } else if (ref instanceof ConnectionPoolDataSource) { - connection = ((ConnectionPoolDataSource) ref).getPooledConnection().getConnection(); + connection = + ((ConnectionPoolDataSource) ref).getPooledConnection().getConnection(); } } catch (SQLException e) { throw zxJDBC.makeException(zxJDBC.DatabaseError, e); } try { - if ((connection == null) || connection.isClosed()) { + if (connection == null || connection.isClosed()) { throw zxJDBC.makeException(zxJDBC.DatabaseError, "unable to establish connection"); } @@ -144,7 +153,8 @@ * * @return String */ + @Override public String toString() { - return "<lookup object instance at " + Py.id(this) + ">"; + return String.format("<lookup object at %s>", Py.idstr(this)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-08-11 06:45:10
|
Revision: 6662 http://jython.svn.sourceforge.net/jython/?rev=6662&view=rev Author: cgroves Date: 2009-08-11 06:45:00 +0000 (Tue, 11 Aug 2009) Log Message: ----------- Documentation and formatting cleanup Modified Paths: -------------- trunk/jython/src/org/python/core/PyOverridableNew.java trunk/jython/src/org/python/expose/ExposedNew.java trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java trunk/jython/src/org/python/expose/generate/NewExposer.java Modified: trunk/jython/src/org/python/core/PyOverridableNew.java =================================================================== --- trunk/jython/src/org/python/core/PyOverridableNew.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/core/PyOverridableNew.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -1,32 +1,30 @@ package org.python.core; - /** - * A __new__ function that tells its subclasses to just init if __new__ is being - * called on the type the function was defined on. Otherwise, it just leaves - * initting up to the subtype otherwise. + * A __new__ function that tells its subclasses to just init if __new__ is being called on the type + * the function was defined on. Otherwise, it just leaves initting up to the subtype otherwise. */ public abstract class PyOverridableNew extends PyNewWrapper { @Override public PyObject new_impl(boolean init, PyType subtype, PyObject[] args, String[] keywords) { - if (for_type==subtype) { + if (for_type == subtype) { return createOfType(init, args, keywords); } else { return createOfSubtype(subtype); } } - + /** * Called when new is invoked on the type the new was defined on. - * + * * @param init - if the new object should be initted. * @param args - args passed to call * @param keywords - keywords passed to call * @return - the new object. */ public abstract PyObject createOfType(boolean init, PyObject[] args, String[] keywords); - + /** Called when new is invoked on a subtype of for_type. */ public abstract PyObject createOfSubtype(PyType subtype); } Modified: trunk/jython/src/org/python/expose/ExposedNew.java =================================================================== --- trunk/jython/src/org/python/expose/ExposedNew.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/ExposedNew.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -8,23 +8,22 @@ import org.python.core.PyInteger; /** + * <p> * Can appear on two forms of methods to indicate a method should be part of the __new__ object * creation. Can only appear once per exposed type. - * + *<p> * In the first form, the method must be static and take the arguments * <code>PyNewWrapper new_, boolean init, PyType - subtype, PyObject[] args, String[] keywords</code>. - * In this case, the method has full responsibility for creating and initting the object and will be - * invoked for every subtype of this exposed type. Essentially its for object instantation that must - * be called for every instance of that object. See {@link PyInteger#int_new} for an example of this - * type of ExposedNew. - * + subtype, PyObject[] args, String[] keywords</code>. In this case, the method has full + * responsibility for creating and initting the object and will be invoked for every subtype of this + * exposed type. Essentially it's for object instantiation that must be called for every instance of + * that object. See {@link PyInteger#int_new} for an example of this type of ExposedNew. + *<p> * In the second form, the method must be an instance method that takes the standard Jython call * arguments, <code>PyObject[] args, String[] keywords</code>. In this case, the basic new * functionality is handled by PyOverridableNew and the method with ExposedNew is called as __init__ * as part of that process. This allows subtypes to completely redefine new and create objects * however they like. - * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) Modified: trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java =================================================================== --- trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/generate/ExposedTypeProcessor.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -170,13 +170,13 @@ methodExposers, descExposers.values(), newExposer); - for(MethodExposer exposer : methodExposers) { + for (MethodExposer exposer : methodExposers) { addInnerClass(exposer.getGeneratedType()); } - for(DescriptorExposer exposer : descExposers.values()) { + for (DescriptorExposer exposer : descExposers.values()) { addInnerClass(exposer.getGeneratedType()); } - if(newExposer != null) { + if (newExposer != null) { addInnerClass(newExposer.getGeneratedType()); } addInnerClass(typeExposer.getGeneratedType()); Modified: trunk/jython/src/org/python/expose/generate/NewExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/NewExposer.java 2009-08-11 05:00:06 UTC (rev 6661) +++ trunk/jython/src/org/python/expose/generate/NewExposer.java 2009-08-11 06:45:00 UTC (rev 6662) @@ -1,12 +1,8 @@ package org.python.expose.generate; -import java.lang.reflect.Method; - import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.python.core.PyNewWrapper; -import org.python.core.PyObject; -import org.python.core.PyType; public class NewExposer extends Exposer { @@ -18,13 +14,13 @@ super(PyNewWrapper.class, onType.getClassName() + "$exposed___new__"); this.onType = onType; this.name = methodName; - if((access & Opcodes.ACC_STATIC) == 0) { + if ((access & Opcodes.ACC_STATIC) == 0) { throwInvalid("Full methods for @ExposedNew must be static"); } - if(!Type.getReturnType(desc).equals(PYOBJ)) { + if (!Type.getReturnType(desc).equals(PYOBJ)) { throwInvalid("@ExposedNew methods must return PyObject"); } - if(exceptions != null && exceptions.length > 0) { + if (exceptions != null && exceptions.length > 0) { throwInvalid("@ExposedNew methods may not throw checked exceptions"); } } @@ -59,9 +55,5 @@ } public static final String NEW_DESCRIPTOR = Type.getMethodDescriptor(PYOBJ, - new Type[] {PYNEWWRAPPER, - BOOLEAN, - PYTYPE, - APYOBJ, - ASTRING}); + new Type[] {PYNEWWRAPPER, BOOLEAN, PYTYPE, APYOBJ, ASTRING}); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-11 05:00:19
|
Revision: 6661 http://jython.svn.sourceforge.net/jython/?rev=6661&view=rev Author: fwierzbicki Date: 2009-08-11 05:00:06 +0000 (Tue, 11 Aug 2009) Log Message: ----------- Merged revisions 6525-6539,6543-6550,6552-6558,6566-6568,6570-6571,6575,6580-6623,6626-6659 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython Modified Paths: -------------- branches/indy/.classpath branches/indy/CoreExposed.includes branches/indy/Lib/_rawffi.py branches/indy/Lib/codeop.py branches/indy/Lib/datetime.py branches/indy/Lib/dbexts.py branches/indy/Lib/fileinput.py branches/indy/Lib/isql.py branches/indy/Lib/javapath.py branches/indy/Lib/javashell.py branches/indy/Lib/os.py branches/indy/Lib/pawt/__init__.py branches/indy/Lib/pawt/colors.py branches/indy/Lib/pawt/swing.py branches/indy/Lib/pkgutil.py branches/indy/Lib/posixpath.py branches/indy/Lib/readline.py branches/indy/Lib/signal.py branches/indy/Lib/socket.py branches/indy/Lib/subprocess.py branches/indy/Lib/telnetlib.py branches/indy/Lib/test/Graph.py branches/indy/Lib/test/anygui.py branches/indy/Lib/test/jser2_classes.py branches/indy/Lib/test/regrtest.py branches/indy/Lib/test/test_SimpleXMLRPCServer.py branches/indy/Lib/test/test__rawffi.py branches/indy/Lib/test/test_array_jy.py branches/indy/Lib/test/test_ast_jy.py branches/indy/Lib/test/test_bigmem.py branches/indy/Lib/test/test_builtin.py branches/indy/Lib/test/test_builtin_jy.py branches/indy/Lib/test/test_cmath_jy.py branches/indy/Lib/test/test_codeop.py branches/indy/Lib/test/test_codeop_jy.py branches/indy/Lib/test/test_coerce_jy.py branches/indy/Lib/test/test_compile_jy.py branches/indy/Lib/test/test_concat_jy.py branches/indy/Lib/test/test_descr_jy.py branches/indy/Lib/test/test_dict2java.py branches/indy/Lib/test/test_exceptions_jy.py branches/indy/Lib/test/test_float_jy.py branches/indy/Lib/test/test_func_syntax_jy.py branches/indy/Lib/test/test_grammar_jy.py branches/indy/Lib/test/test_import_jy.py branches/indy/Lib/test/test_importhooks.py branches/indy/Lib/test/test_java_integration.py branches/indy/Lib/test/test_java_list_delegate.py branches/indy/Lib/test/test_java_subclasses.py branches/indy/Lib/test/test_java_visibility.py branches/indy/Lib/test/test_javalist.py branches/indy/Lib/test/test_javashell.py branches/indy/Lib/test/test_jbasic.py branches/indy/Lib/test/test_joverload.py branches/indy/Lib/test/test_jser.py branches/indy/Lib/test/test_jy_generators.py branches/indy/Lib/test/test_jy_internals.py branches/indy/Lib/test/test_list_jy.py branches/indy/Lib/test/test_marshal.py branches/indy/Lib/test/test_metaclass_support/simpleclass.py branches/indy/Lib/test/test_module.py branches/indy/Lib/test/test_pbcvm.py branches/indy/Lib/test/test_pythoninterpreter_jy.py branches/indy/Lib/test/test_random.py branches/indy/Lib/test/test_re.py branches/indy/Lib/test/test_re_jy.py branches/indy/Lib/test/test_sax.py branches/indy/Lib/test/test_sax_jy.py branches/indy/Lib/test/test_set_jy.py branches/indy/Lib/test/test_socket.py branches/indy/Lib/test/test_sort.py branches/indy/Lib/test/test_sort_jy.py branches/indy/Lib/test/test_str2unicode.py branches/indy/Lib/test/test_stringmap.py branches/indy/Lib/test/test_subclasses.py branches/indy/Lib/test/test_subclasses_jy.py branches/indy/Lib/test/test_sys_jy.py branches/indy/Lib/test/test_thread_jy.py branches/indy/Lib/test/test_thread_local.py branches/indy/Lib/test/test_threading.py branches/indy/Lib/test/test_threading_jy.py branches/indy/Lib/test/test_timeit.py branches/indy/Lib/test/test_trace.py branches/indy/Lib/test/test_trace_threaded.py branches/indy/Lib/test/test_tuple.py branches/indy/Lib/test/test_unicode_jy.py branches/indy/Lib/test/test_userdict.py branches/indy/Lib/test/test_weakref.py branches/indy/Lib/test/test_with.py branches/indy/Lib/test/test_xml_etree_jy.py branches/indy/Lib/test/test_zipimport_jy.py branches/indy/Lib/test/whrandom.py branches/indy/Lib/test/zxjdbc/dbextstest.py branches/indy/Lib/test/zxjdbc/jndi.py branches/indy/Lib/test/zxjdbc/runner.py branches/indy/Lib/test/zxjdbc/sptest.py branches/indy/Lib/test/zxjdbc/test_zxjdbc_dbapi20.py branches/indy/Lib/test/zxjdbc/zxtest.py branches/indy/Lib/threading.py branches/indy/Lib/unicodedata.py branches/indy/Lib/xml/Uri.py branches/indy/Lib/xml/dom/minidom.py branches/indy/Lib/xml/dom/pulldom.py branches/indy/Lib/xml/parsers/expat.py branches/indy/Lib/xml/sax/_exceptions.py branches/indy/Lib/xml/sax/drivers2/drv_javasax.py branches/indy/Lib/xml/sax/handler.py branches/indy/Lib/xml/sax/saxutils.py branches/indy/Lib/zlib.py branches/indy/NEWS branches/indy/ast/asdl_antlr.py branches/indy/grammar/Base.g branches/indy/grammar/Python.g branches/indy/grammar/PythonPartial.g branches/indy/src/com/xhaus/modjy/ModjyJServlet.java branches/indy/src/com/ziclix/python/sql/DataHandler.java branches/indy/src/com/ziclix/python/sql/Fetch.java branches/indy/src/com/ziclix/python/sql/JDBC20DataHandler.java branches/indy/src/com/ziclix/python/sql/Jython22DataHandler.java branches/indy/src/com/ziclix/python/sql/PyConnection.java branches/indy/src/com/ziclix/python/sql/PyCursor.java branches/indy/src/com/ziclix/python/sql/PyExtendedCursor.java branches/indy/src/com/ziclix/python/sql/PyStatement.java branches/indy/src/com/ziclix/python/sql/handler/InformixDataHandler.java branches/indy/src/com/ziclix/python/sql/handler/MySQLDataHandler.java branches/indy/src/com/ziclix/python/sql/handler/OracleDataHandler.java branches/indy/src/com/ziclix/python/sql/util/PyArgParser.java branches/indy/src/com/ziclix/python/sql/util/Queue.java branches/indy/src/com/ziclix/python/sql/zxJDBC.java branches/indy/src/org/python/antlr/AST.java branches/indy/src/org/python/antlr/BaseParser.java branches/indy/src/org/python/antlr/GrammarActions.java branches/indy/src/org/python/antlr/ParseException.java branches/indy/src/org/python/antlr/PythonErrorNode.java branches/indy/src/org/python/antlr/PythonTokenSource.java branches/indy/src/org/python/antlr/PythonTree.java branches/indy/src/org/python/antlr/PythonTreeAdaptor.java branches/indy/src/org/python/antlr/adapter/AliasAdapter.java branches/indy/src/org/python/antlr/adapter/AstAdapters.java branches/indy/src/org/python/antlr/adapter/CmpopAdapter.java branches/indy/src/org/python/antlr/adapter/ComprehensionAdapter.java branches/indy/src/org/python/antlr/adapter/ExcepthandlerAdapter.java branches/indy/src/org/python/antlr/adapter/ExprAdapter.java branches/indy/src/org/python/antlr/adapter/IdentifierAdapter.java branches/indy/src/org/python/antlr/adapter/KeywordAdapter.java branches/indy/src/org/python/antlr/adapter/SliceAdapter.java branches/indy/src/org/python/antlr/adapter/StmtAdapter.java branches/indy/src/org/python/antlr/ast/Assert.java branches/indy/src/org/python/antlr/ast/Assign.java branches/indy/src/org/python/antlr/ast/Attribute.java branches/indy/src/org/python/antlr/ast/AugAssign.java branches/indy/src/org/python/antlr/ast/BinOp.java branches/indy/src/org/python/antlr/ast/BoolOp.java branches/indy/src/org/python/antlr/ast/Break.java branches/indy/src/org/python/antlr/ast/Call.java branches/indy/src/org/python/antlr/ast/ClassDef.java branches/indy/src/org/python/antlr/ast/Compare.java branches/indy/src/org/python/antlr/ast/Continue.java branches/indy/src/org/python/antlr/ast/Delete.java branches/indy/src/org/python/antlr/ast/Dict.java branches/indy/src/org/python/antlr/ast/Ellipsis.java branches/indy/src/org/python/antlr/ast/ExceptHandler.java branches/indy/src/org/python/antlr/ast/Exec.java branches/indy/src/org/python/antlr/ast/Expr.java branches/indy/src/org/python/antlr/ast/Expression.java branches/indy/src/org/python/antlr/ast/ExtSlice.java branches/indy/src/org/python/antlr/ast/For.java branches/indy/src/org/python/antlr/ast/FunctionDef.java branches/indy/src/org/python/antlr/ast/GeneratorExp.java branches/indy/src/org/python/antlr/ast/Global.java branches/indy/src/org/python/antlr/ast/If.java branches/indy/src/org/python/antlr/ast/IfExp.java branches/indy/src/org/python/antlr/ast/Import.java branches/indy/src/org/python/antlr/ast/ImportFrom.java branches/indy/src/org/python/antlr/ast/Index.java branches/indy/src/org/python/antlr/ast/Interactive.java branches/indy/src/org/python/antlr/ast/Lambda.java branches/indy/src/org/python/antlr/ast/List.java branches/indy/src/org/python/antlr/ast/ListComp.java branches/indy/src/org/python/antlr/ast/Module.java branches/indy/src/org/python/antlr/ast/Name.java branches/indy/src/org/python/antlr/ast/Num.java branches/indy/src/org/python/antlr/ast/Pass.java branches/indy/src/org/python/antlr/ast/Print.java branches/indy/src/org/python/antlr/ast/Raise.java branches/indy/src/org/python/antlr/ast/Repr.java branches/indy/src/org/python/antlr/ast/Return.java branches/indy/src/org/python/antlr/ast/Slice.java branches/indy/src/org/python/antlr/ast/Str.java branches/indy/src/org/python/antlr/ast/Subscript.java branches/indy/src/org/python/antlr/ast/Suite.java branches/indy/src/org/python/antlr/ast/TryExcept.java branches/indy/src/org/python/antlr/ast/TryFinally.java branches/indy/src/org/python/antlr/ast/Tuple.java branches/indy/src/org/python/antlr/ast/UnaryOp.java branches/indy/src/org/python/antlr/ast/While.java branches/indy/src/org/python/antlr/ast/With.java branches/indy/src/org/python/antlr/ast/Yield.java branches/indy/src/org/python/antlr/ast/alias.java branches/indy/src/org/python/antlr/ast/arguments.java branches/indy/src/org/python/antlr/ast/comprehension.java branches/indy/src/org/python/antlr/ast/keyword.java branches/indy/src/org/python/compiler/AdapterMaker.java branches/indy/src/org/python/compiler/ClassConstants.java branches/indy/src/org/python/compiler/ClassFile.java branches/indy/src/org/python/compiler/Code.java branches/indy/src/org/python/compiler/CodeCompiler.java branches/indy/src/org/python/compiler/IndyTest.java branches/indy/src/org/python/compiler/JavaMaker.java branches/indy/src/org/python/compiler/LineNumberTable.java branches/indy/src/org/python/compiler/Module.java branches/indy/src/org/python/compiler/ProxyMaker.java branches/indy/src/org/python/compiler/ScopeInfo.java branches/indy/src/org/python/compiler/ScopesCompiler.java branches/indy/src/org/python/compiler/SymInfo.java branches/indy/src/org/python/core/ArgParser.java branches/indy/src/org/python/core/MakeProxies.java branches/indy/src/org/python/core/ParserFacade.java branches/indy/src/org/python/core/Py.java branches/indy/src/org/python/core/PyFileWriter.java branches/indy/src/org/python/core/PyFinalizableInstance.java branches/indy/src/org/python/core/PyJavaType.java branches/indy/src/org/python/core/PyList.java branches/indy/src/org/python/core/PyObject.java branches/indy/src/org/python/core/PySystemState.java branches/indy/src/org/python/core/PyTuple.java branches/indy/src/org/python/core/PyType.java branches/indy/src/org/python/core/PythonTraceFunction.java branches/indy/src/org/python/core/StdoutWrapper.java branches/indy/src/org/python/core/__builtin__.java branches/indy/src/org/python/core/codecs.java branches/indy/src/org/python/core/imp.java branches/indy/src/org/python/core/util/StringUtil.java branches/indy/src/org/python/expose/generate/ExposeTask.java branches/indy/src/org/python/modules/Setup.java branches/indy/src/org/python/modules/_collections/Collections.java branches/indy/src/org/python/modules/_collections/PyDeque.java branches/indy/src/org/python/util/GlobMatchingTask.java branches/indy/src/org/python/util/JycompileAntTask.java branches/indy/src/org/python/util/PythonInterpreter.java branches/indy/src/org/python/util/jython.java Added Paths: ----------- branches/indy/Lib/test/import_as_java_class.py branches/indy/Lib/test/static_proxy.py branches/indy/Lib/weakref.py branches/indy/extlibs/livetribe-jsr223-2.0.5.jar branches/indy/src/META-INF/ branches/indy/src/META-INF/services/ branches/indy/src/META-INF/services/javax.script.ScriptEngineFactory branches/indy/src/org/python/core/ContextGuard.java branches/indy/src/org/python/core/ContextManager.java branches/indy/src/org/python/core/PyFileReader.java branches/indy/src/org/python/core/util/PlatformUtil.java branches/indy/src/org/python/jsr223/ branches/indy/src/org/python/jsr223/PyScriptEngine.java branches/indy/src/org/python/jsr223/PyScriptEngineFactory.java branches/indy/src/org/python/jsr223/PyScriptEngineScope.java branches/indy/src/org/python/modules/_threading/ branches/indy/src/org/python/modules/_threading/Condition.java branches/indy/src/org/python/modules/_threading/Lock.java branches/indy/src/org/python/modules/_threading/_threading.java branches/indy/src/org/python/util/CompileProxiesTask.java branches/indy/src/org/python/util/FileNameMatchingTask.java branches/indy/tests/java/org/python/jsr223/ branches/indy/tests/java/org/python/jsr223/ScriptEngineIOTest.java branches/indy/tests/java/org/python/jsr223/ScriptEngineTest.java Removed Paths: ------------- branches/indy/Lib/test/test_bugfixes.py branches/indy/src/META-INF/services/ branches/indy/src/META-INF/services/javax.script.ScriptEngineFactory branches/indy/src/org/python/jsr223/PyScriptEngine.java branches/indy/src/org/python/jsr223/PyScriptEngineFactory.java branches/indy/src/org/python/jsr223/PyScriptEngineScope.java branches/indy/src/org/python/modules/_threading/Condition.java branches/indy/src/org/python/modules/_threading/Lock.java branches/indy/src/org/python/modules/_threading/_threading.java branches/indy/tests/java/org/python/jsr223/ScriptEngineIOTest.java branches/indy/tests/java/org/python/jsr223/ScriptEngineTest.java Property Changed: ---------------- branches/indy/ branches/indy/tests/java/org/python/tests/RedundantInterfaceDeclarations.java Property changes on: branches/indy ___________________________________________________________________ Modified: svnmerge-integrated - /branches/pbcvm:1-6045 /trunk/jython:1-6522 + /branches/pbcvm:1-6045 /trunk/jython:1-6660 Modified: svn:mergeinfo - /branches/newstyle-java-types:5564-5663,5666-5729 + /branches/jsr223:6285-6565 /branches/newstyle-java-types:5564-5663,5666-5729 Modified: branches/indy/.classpath =================================================================== --- branches/indy/.classpath 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/.classpath 2009-08-11 05:00:06 UTC (rev 6661) @@ -20,6 +20,7 @@ <classpathentry kind="lib" path="extlibs/constantine-0.4.jar"/> <classpathentry kind="lib" path="extlibs/jna-posix.jar"/> <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/jar/jdom.jar"/> - <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar"/> + <classpathentry kind="lib" path="extlibs/mockrunner-0.4.1/lib/jdk1.5/j2ee1.3/mockrunner-servlet.jar"/> + <classpathentry kind="lib" path="extlibs/jna.jar"/> <classpathentry kind="output" path="bugtests/classes"/> </classpath> Modified: branches/indy/CoreExposed.includes =================================================================== --- branches/indy/CoreExposed.includes 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/CoreExposed.includes 2009-08-11 05:00:06 UTC (rev 6661) @@ -41,25 +41,28 @@ org/python/core/PyType.class org/python/core/PyUnicode.class org/python/core/PyXRange.class +org/python/modules/PyStruct.class +org/python/modules/PyTeeIterator.class +org/python/jsr223/PyScriptEngineScope.class org/python/modules/_codecs$EncodingMap.class +org/python/modules/_collections/PyDefaultDict.class +org/python/modules/_collections/PyDeque.class org/python/modules/_csv/PyDialect.class org/python/modules/_csv/PyReader.class org/python/modules/_csv/PyWriter.class org/python/modules/_functools/PyPartial.class +org/python/modules/_hashlib$Hash.class +org/python/modules/_threading/Condition.class +org/python/modules/_threading/Lock.class org/python/modules/_weakref/CallableProxyType.class +org/python/modules/_weakref/ProxyType.class org/python/modules/_weakref/ReferenceType.class -org/python/modules/_weakref/ProxyType.class -org/python/modules/_hashlib$Hash.class -org/python/modules/_collections/PyDefaultDict.class -org/python/modules/_collections/PyDeque.class org/python/modules/operator$PyAttrGetter.class org/python/modules/operator$PyItemGetter.class org/python/modules/random/PyRandom.class org/python/modules/thread/PyLocal.class org/python/modules/time/PyTimeTuple.class org/python/modules/zipimport/zipimporter.class -org/python/modules/PyStruct.class -org/python/modules/PyTeeIterator.class org/python/antlr/AST.class org/python/antlr/ast/alias.class org/python/antlr/ast/arguments.class Modified: branches/indy/Lib/_rawffi.py =================================================================== --- branches/indy/Lib/_rawffi.py 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/Lib/_rawffi.py 2009-08-11 05:00:06 UTC (rev 6661) @@ -52,6 +52,3 @@ fnp = FuncPtr(fn, name, argtypes, restype) self.cache[key] = fnp return fnp - - - Modified: branches/indy/Lib/codeop.py =================================================================== --- branches/indy/Lib/codeop.py 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/Lib/codeop.py 2009-08-11 05:00:06 UTC (rev 6661) @@ -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: branches/indy/Lib/datetime.py =================================================================== --- branches/indy/Lib/datetime.py 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/Lib/datetime.py 2009-08-11 05:00:06 UTC (rev 6661) @@ -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: @@ -1853,12 +1853,14 @@ calendar.clear() calendar.set(self.year, self.month - 1, self.day, self.hour, self.minute, self.second) - calendar.set(Calendar.MILLISECOND, self.microsecond // 1000) if java_class == Calendar: + calendar.set(Calendar.MILLISECOND, self.microsecond // 1000) return calendar else: - return Timestamp(calendar.getTimeInMillis()) + timestamp = Timestamp(calendar.getTimeInMillis()) + timestamp.setNanos(self.microsecond * 1000) + return timestamp datetime.min = datetime(1, 1, 1) @@ -2074,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: branches/indy/Lib/dbexts.py =================================================================== --- branches/indy/Lib/dbexts.py 2009-08-11 03:00:08 UTC (rev 6660) +++ branches/indy/Lib/dbexts.py 2009-08-11 05:00:06 UTC (rev 6661) @@ -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() - ... [truncated message content] |
From: <fwi...@us...> - 2009-08-11 03:00:16
|
Revision: 6660 http://jython.svn.sourceforge.net/jython/?rev=6660&view=rev Author: fwierzbicki Date: 2009-08-11 03:00:08 +0000 (Tue, 11 Aug 2009) Log Message: ----------- Initialized merge tracking via "svnmerge" with revisions "1-6522" from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython Property Changed: ---------------- branches/indy/ Property changes on: branches/indy ___________________________________________________________________ Modified: svnmerge-integrated - /branches/pbcvm:1-6045 + /branches/pbcvm:1-6045 /trunk/jython:1-6522 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 19:05:19
|
Revision: 6659 http://jython.svn.sourceforge.net/jython/?rev=6659&view=rev Author: fwierzbicki Date: 2009-08-10 19:05:11 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindents. Modified Paths: -------------- trunk/jython/Lib/test/test_builtin.py trunk/jython/Lib/test/test_codeop.py trunk/jython/Lib/test/test_javalist.py trunk/jython/Lib/test/test_re.py trunk/jython/Lib/test/test_sax_jy.py trunk/jython/Lib/test/test_subclasses_jy.py trunk/jython/Lib/test/test_threading.py Modified: trunk/jython/Lib/test/test_builtin.py =================================================================== --- trunk/jython/Lib/test/test_builtin.py 2009-08-10 19:04:35 UTC (rev 6658) +++ trunk/jython/Lib/test/test_builtin.py 2009-08-10 19:05:11 UTC (rev 6659) @@ -215,7 +215,7 @@ from UserList import UserList c = UserList(); c.append(c) self.assertEqual(cmp(a, b), 0) - self.assertEqual(cmp(b, c), 0) + self.assertEqual(cmp(b, c), 0) self.assertEqual(cmp(c, a), 0) self.assertEqual(cmp(a, c), 0) # okay, now break the cycles Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-08-10 19:04:35 UTC (rev 6658) +++ trunk/jython/Lib/test/test_codeop.py 2009-08-10 19:05:11 UTC (rev 6659) @@ -126,7 +126,7 @@ #XXX: works in CPython if not is_jython: - av("@a.b.c\ndef f():\n pass\n") + av("@a.b.c\ndef f():\n pass\n") def test_incomplete(self): ai = self.assertIncomplete Modified: trunk/jython/Lib/test/test_javalist.py =================================================================== --- trunk/jython/Lib/test/test_javalist.py 2009-08-10 19:04:35 UTC (rev 6658) +++ trunk/jython/Lib/test/test_javalist.py 2009-08-10 19:05:11 UTC (rev 6659) @@ -1,35 +1,35 @@ from javatests import ListTest class PyListTest(ListTest): - - def __init__(self): - ListTest.__init__(self) - - def newInstance(self, coll): - if coll is None: - return list() - else: - return list(coll) - - def isReadOnly(self): - return False - + def __init__(self): + ListTest.__init__(self) + + def newInstance(self, coll): + if coll is None: + return list() + else: + return list(coll) + + def isReadOnly(self): + return False + + class PyTupleTest(ListTest): - - def __init__(self): - ListTest.__init__(self) - - def newInstance(self, coll): - if coll is None: - return tuple() - else: - return tuple(coll) - - def isReadOnly(self): - return True + def __init__(self): + ListTest.__init__(self) + def newInstance(self, coll): + if coll is None: + return tuple() + else: + return tuple(coll) + + def isReadOnly(self): + return True + + # these first two tests just verify that we have a good unit test print "ListTest.java driver (test_javalist.py)" print "running test on ArrayList" @@ -45,8 +45,8 @@ print "running test on PyListTest" plt = PyListTest() -plt.testAll() +plt.testAll() print "running test on PyTupleTest" ptt = PyTupleTest() -ptt.testAll() +ptt.testAll() Modified: trunk/jython/Lib/test/test_re.py =================================================================== --- trunk/jython/Lib/test/test_re.py 2009-08-10 19:04:35 UTC (rev 6658) +++ trunk/jython/Lib/test/test_re.py 2009-08-10 19:05:11 UTC (rev 6659) @@ -515,7 +515,7 @@ # non-simple '*?' still used to hit the recursion limit, before the # non-recursive scheme was implemented. - # does not apply for Jython, since we do not implement the + # does not apply for Jython, since we do not implement the # non-recursive scheme # self.assertEqual(re.search('(a|b)*?c', 10000*'ab'+'cd').end(0), 20001) Modified: trunk/jython/Lib/test/test_sax_jy.py =================================================================== --- trunk/jython/Lib/test/test_sax_jy.py 2009-08-10 19:04:35 UTC (rev 6658) +++ trunk/jython/Lib/test/test_sax_jy.py 2009-08-10 19:05:11 UTC (rev 6659) @@ -47,4 +47,3 @@ if __name__ == "__main__": test_main() - Modified: trunk/jython/Lib/test/test_subclasses_jy.py =================================================================== --- trunk/jython/Lib/test/test_subclasses_jy.py 2009-08-10 19:04:35 UTC (rev 6658) +++ trunk/jython/Lib/test/test_subclasses_jy.py 2009-08-10 19:05:11 UTC (rev 6659) @@ -2,17 +2,17 @@ import test.test_support class SubclassInstanceTest(unittest.TestCase): - - def test_subclass_int(self): - try: - class foo(12): pass - except TypeError: - pass - else: - self.fail("expected TypeError for subclassing an int instance") + def test_subclass_int(self): + try: + class foo(12): pass + except TypeError: + pass + else: + self.fail("expected TypeError for subclassing an int instance") + def test_main(): - test.test_support.run_unittest(SubclassInstanceTest) + test.test_support.run_unittest(SubclassInstanceTest) if __name__ == "__main__": - test_main() + test_main() Modified: trunk/jython/Lib/test/test_threading.py =================================================================== --- trunk/jython/Lib/test/test_threading.py 2009-08-10 19:04:35 UTC (rev 6658) +++ trunk/jython/Lib/test/test_threading.py 2009-08-10 19:05:11 UTC (rev 6659) @@ -112,7 +112,7 @@ self.test_various_ops() threading.stack_size(0) - # this test is not applicable to jython since + # this test is not applicable to jython since # 1. Lock is equiv to RLock, so this weird sync behavior won't be seen # 2. We use a weak hash map to map these threads # 3. This behavior doesn't make sense for Jython since any foreign This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 19:04:46
|
Revision: 6658 http://jython.svn.sourceforge.net/jython/?rev=6658&view=rev Author: fwierzbicki Date: 2009-08-10 19:04:35 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Reindent, mostly 8 space -> 4 space. Modified Paths: -------------- trunk/jython/Lib/test/whrandom.py Modified: trunk/jython/Lib/test/whrandom.py =================================================================== --- trunk/jython/Lib/test/whrandom.py 2009-08-10 19:01:48 UTC (rev 6657) +++ trunk/jython/Lib/test/whrandom.py 2009-08-10 19:04:35 UTC (rev 6658) @@ -1,21 +1,21 @@ # WICHMANN-HILL RANDOM NUMBER GENERATOR # # Wichmann, B. A. & Hill, I. D. (1982) -# Algorithm AS 183: +# Algorithm AS 183: # An efficient and portable pseudo-random number generator # Applied Statistics 31 (1982) 188-190 # -# see also: +# see also: # Correction to Algorithm AS 183 -# Applied Statistics 33 (1984) 123 +# Applied Statistics 33 (1984) 123 # # McLeod, A. I. (1985) -# A remark on Algorithm AS 183 +# A remark on Algorithm AS 183 # Applied Statistics 34 (1985),198-200 # # # USE: -# whrandom.random() yields double precision random numbers +# whrandom.random() yields double precision random numbers # uniformly distributed between 0 and 1. # # whrandom.seed(x, y, z) must be called before whrandom.random() @@ -30,60 +30,60 @@ class whrandom: + # + # Initialize an instance. + # Without arguments, initialize from current time. + # With arguments (x, y, z), initialize from them. + # + def __init__(self, x = 0, y = 0, z = 0): + self.seed(x, y, z) + # + # Set the seed from (x, y, z). + # These must be integers in the range [0, 256). + # + def seed(self, x = 0, y = 0, z = 0): + if not type(x) == type(y) == type(z) == type(0): + raise TypeError, 'seeds must be integers' + if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256): + raise ValueError, 'seeds must be in range(0, 256)' + if 0 == x == y == z: + # Initialize from current time + import time + t = long(time.time() * 256) + t = int((t&0xffffff) ^ (t>>24)) + t, x = divmod(t, 256) + t, y = divmod(t, 256) + t, z = divmod(t, 256) + # Zero is a poor seed, so substitute 1 + self._seed = (x or 1, y or 1, z or 1) + # + # Get the next random number in the range [0.0, 1.0). + # + def random(self): + x, y, z = self._seed # - # Initialize an instance. - # Without arguments, initialize from current time. - # With arguments (x, y, z), initialize from them. + x = (171 * x) % 30269 + y = (172 * y) % 30307 + z = (170 * z) % 30323 # - def __init__(self, x = 0, y = 0, z = 0): - self.seed(x, y, z) + self._seed = x, y, z # - # Set the seed from (x, y, z). - # These must be integers in the range [0, 256). - # - def seed(self, x = 0, y = 0, z = 0): - if not type(x) == type(y) == type(z) == type(0): - raise TypeError, 'seeds must be integers' - if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256): - raise ValueError, 'seeds must be in range(0, 256)' - if 0 == x == y == z: - # Initialize from current time - import time - t = long(time.time() * 256) - t = int((t&0xffffff) ^ (t>>24)) - t, x = divmod(t, 256) - t, y = divmod(t, 256) - t, z = divmod(t, 256) - # Zero is a poor seed, so substitute 1 - self._seed = (x or 1, y or 1, z or 1) - # - # Get the next random number in the range [0.0, 1.0). - # - def random(self): - x, y, z = self._seed - # - x = (171 * x) % 30269 - y = (172 * y) % 30307 - z = (170 * z) % 30323 - # - self._seed = x, y, z - # - return (x/30269.0 + y/30307.0 + z/30323.0) % 1.0 - # - # Get a random number in the range [a, b). - # - def uniform(self, a, b): - return a + (b-a) * self.random() - # - # Get a random integer in the range [a, b] including both end points. - # - def randint(self, a, b): - return a + int(self.random() * (b+1-a)) - # - # Choose a random element from a non-empty sequence. - # - def choice(self, seq): - return seq[int(self.random() * len(seq))] + return (x/30269.0 + y/30307.0 + z/30323.0) % 1.0 + # + # Get a random number in the range [a, b). + # + def uniform(self, a, b): + return a + (b-a) * self.random() + # + # Get a random integer in the range [a, b] including both end points. + # + def randint(self, a, b): + return a + int(self.random() * (b+1-a)) + # + # Choose a random element from a non-empty sequence. + # + def choice(self, seq): + return seq[int(self.random() * len(seq))] # Initialize from the current time This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 19:01:55
|
Revision: 6657 http://jython.svn.sourceforge.net/jython/?rev=6657&view=rev Author: fwierzbicki Date: 2009-08-10 19:01:48 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindents. Modified Paths: -------------- trunk/jython/Lib/test/test_bigmem.py trunk/jython/Lib/test/test_compile_jy.py trunk/jython/Lib/test/test_pythoninterpreter_jy.py trunk/jython/Lib/test/test_sax.py trunk/jython/Lib/test/test_sort.py trunk/jython/Lib/test/test_threading_jy.py trunk/jython/Lib/test/test_trace.py trunk/jython/Lib/test/test_unicode_jy.py trunk/jython/Lib/test/test_userdict.py Modified: trunk/jython/Lib/test/test_bigmem.py =================================================================== --- trunk/jython/Lib/test/test_bigmem.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_bigmem.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -519,7 +519,7 @@ # this might make sense for virtually managed collections, # but PyObjectArray is backed by PyObject[], so that's a hard # limitation of the JVM - + # self.assertRaises(IndexError, operator.getitem, s, len(s) + 1<<31) @bigmemtest(minsize=_2G, memuse=2) @@ -549,7 +549,7 @@ # changed for Jython because the hash code of a java.lang.String # of 0x00's is 0 regardless of size - + @bigmemtest(minsize=_2G + 10, memuse=1) def test_hash(self, size): # Not sure if we can do any meaningful tests here... Even if we Modified: trunk/jython/Lib/test/test_compile_jy.py =================================================================== --- trunk/jython/Lib/test/test_compile_jy.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_compile_jy.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -54,4 +54,4 @@ run_unittest(TestMtime) if __name__ == "__main__": - test_main() + test_main() Modified: trunk/jython/Lib/test/test_pythoninterpreter_jy.py =================================================================== --- trunk/jython/Lib/test/test_pythoninterpreter_jy.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_pythoninterpreter_jy.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -13,7 +13,7 @@ from org.python.core import Py from org.python.util import PythonInterpreter from org.python.core import PySystemState - + ps = PySystemState() pi = PythonInterpreter({}, ps) if locals: @@ -47,7 +47,7 @@ # Some language names from wikipedia u'Català · Česky · Dansk · Deutsch · English · Español · Esperanto · Français · Bahasa Indonesia · Italiano · Magyar · Nederlands · 日本語 · Norsk (bokmål) · Polski · Português · Русский · Română · Slovenčina · Suomi · Svenska · Türkçe · Українська · Volapük · 中文', ] - + def f(): global text for x in text: @@ -65,7 +65,7 @@ out = java.io.StringWriter() err = java.io.StringWriter() exec_code_in_pi(f, out, err) - self.assertEquals(u"42\n", out.toString()) + self.assertEquals(u"42\n", out.toString()) def test_more_output(self): def f(): Modified: trunk/jython/Lib/test/test_sax.py =================================================================== --- trunk/jython/Lib/test/test_sax.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_sax.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -157,7 +157,7 @@ def test_xmlgen_escaped_attr(): result = StringIO() gen = XMLGenerator(result) - + gen.startDocument() gen.startElement("doc", {"x": unicode("\\u3042", "unicode-escape")}) gen.endElement("doc") Modified: trunk/jython/Lib/test/test_sort.py =================================================================== --- trunk/jython/Lib/test/test_sort.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_sort.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -275,17 +275,17 @@ TestDecorateSortUndecorate, TestBugs, ) - + # In the following test cases, class obj, which has function that changes # the data upon which sort is invoked, is passed for "key" argument. - # It can not be checked if that function changes data as long as it is - # invoked(e.g. __del__ in SortKiller). so these are currently commented out. + # It can not be checked if that function changes data as long as it is + # invoked(e.g. __del__ in SortKiller). so these are currently commented out. del TestDecorateSortUndecorate.test_key_with_mutating_del del TestDecorateSortUndecorate.test_key_with_mutating_del_and_exception # test_support.run_unittest(*test_classes) - + # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc Modified: trunk/jython/Lib/test/test_threading_jy.py =================================================================== --- trunk/jython/Lib/test/test_threading_jy.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_threading_jy.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -16,21 +16,21 @@ self.assertEqual(t.getName(), '1') t.setName(2) self.assertEqual(t.getName(), '2') - + # make sure activeCount() gets decremented (see issue 1348) def test_activeCount(self): - activeBefore = threading.activeCount() + activeBefore = threading.activeCount() activeCount = 10 for i in range(activeCount): - t = Thread(target=self._sleep, args=(i,)) - t.setDaemon(0) - t.start() + t = Thread(target=self._sleep, args=(i,)) + t.setDaemon(0) + t.start() polls = activeCount while activeCount > activeBefore and polls > 0: time.sleep(1) activeCount = threading.activeCount() polls -= 1 - self.assertTrue(activeCount <= activeBefore, 'activeCount should to be <= %s, instead of %s' % (activeBefore, activeCount)) + self.assertTrue(activeCount <= activeBefore, 'activeCount should to be <= %s, instead of %s' % (activeBefore, activeCount)) def _sleep(self, n): time.sleep(random.random()) Modified: trunk/jython/Lib/test/test_trace.py =================================================================== --- trunk/jython/Lib/test/test_trace.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_trace.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -740,10 +740,10 @@ tests.append(JumpTestCase) else: del TraceTestCase.test_02_arigo - del TraceTestCase.test_05_no_pop_tops - del TraceTestCase.test_07_raise + del TraceTestCase.test_05_no_pop_tops + del TraceTestCase.test_07_raise del TraceTestCase.test_09_settrace_and_raise - del TraceTestCase.test_10_ireturn + del TraceTestCase.test_10_ireturn del TraceTestCase.test_11_tightloop del TraceTestCase.test_12_tighterloop del TraceTestCase.test_13_genexp Modified: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_unicode_jy.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -123,7 +123,7 @@ return f = open(test_support.TESTFN, "w") - self.assertRaises(UnicodeEncodeError, f, write, EURO_SIGN, + self.assertRaises(UnicodeEncodeError, f, write, EURO_SIGN, "Shouldn't be able to write out a Euro sign without first encoding") f.close() @@ -140,7 +140,7 @@ class UnicodeFormatTestCase(unittest.TestCase): - + def test_unicode_mapping(self): assertTrue = self.assertTrue class EnsureUnicode(dict): @@ -158,7 +158,7 @@ class UnicodeStdIOTestCase(unittest.TestCase): - + def setUp(self): self.stdout = sys.stdout Modified: trunk/jython/Lib/test/test_userdict.py =================================================================== --- trunk/jython/Lib/test/test_userdict.py 2009-08-10 18:58:58 UTC (rev 6656) +++ trunk/jython/Lib/test/test_userdict.py 2009-08-10 19:01:48 UTC (rev 6657) @@ -175,7 +175,7 @@ self.assertEqual(eval(`u2`), eval(`d2`)) # end zyasoft ~ - + # Test __cmp__ and __len__ all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2] for a in all: @@ -219,7 +219,7 @@ # zyasoft - changed the following three assertions to use sets # to remove order dependency - + # Test keys, items, values self.assertEqual(set(u2.keys()), set(d2.keys())) self.assertEqual(set(u2.items()), set(d2.items())) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 18:59:06
|
Revision: 6656 http://jython.svn.sourceforge.net/jython/?rev=6656&view=rev Author: fwierzbicki Date: 2009-08-10 18:58:58 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Reindent, mainly 8 space -> 4 space Modified Paths: -------------- trunk/jython/Lib/test/Graph.py Modified: trunk/jython/Lib/test/Graph.py =================================================================== --- trunk/jython/Lib/test/Graph.py 2009-08-10 18:56:57 UTC (rev 6655) +++ trunk/jython/Lib/test/Graph.py 2009-08-10 18:58:58 UTC (rev 6656) @@ -3,60 +3,60 @@ from jarray import array class Graph(awt.Canvas): - def __init__(self): - self.function = None + def __init__(self): + self.function = None - def paint(self, g): - if self.function is None: - return self.error(g) - - sz = self.size - xs = range(0, sz.width, 2) - - xscale = 4*pi/sz.width - xoffset = -2*pi - - yscale = -sz.height/2. - yoffset = sz.height/2. - - ys = [] - for x in xs: - x = xscale*x + xoffset - y = int(yscale*self.function(x)+yoffset) - ys.append(y) - g.drawPolyline(array(xs, 'i'), array(ys, 'i'), len(xs)) + def paint(self, g): + if self.function is None: + return self.error(g) - def error(self, g): - message = "Invalid Expression" - g.font = awt.Font('Serif', awt.Font.BOLD, 20) - width = g.fontMetrics.stringWidth(message) - - x = (self.size.width-width)/2 - y = (self.size.height+g.fontMetrics.height)/2 - g.drawString("Invalid Expression", x, y) - - def setExpression(self, e): - try: - self.function = eval('lambda x: '+e) - except: - self.function = None - self.repaint() - + sz = self.size + xs = range(0, sz.width, 2) + xscale = 4*pi/sz.width + xoffset = -2*pi + + yscale = -sz.height/2. + yoffset = sz.height/2. + + ys = [] + for x in xs: + x = xscale*x + xoffset + y = int(yscale*self.function(x)+yoffset) + ys.append(y) + g.drawPolyline(array(xs, 'i'), array(ys, 'i'), len(xs)) + + def error(self, g): + message = "Invalid Expression" + g.font = awt.Font('Serif', awt.Font.BOLD, 20) + width = g.fontMetrics.stringWidth(message) + + x = (self.size.width-width)/2 + y = (self.size.height+g.fontMetrics.height)/2 + g.drawString("Invalid Expression", x, y) + + def setExpression(self, e): + try: + self.function = eval('lambda x: '+e) + except: + self.function = None + self.repaint() + + if __name__ == '__main__': - def enter(e): - graph.setExpression(expression.text) - expression.caretPosition=0 - expression.selectAll() - - p = awt.Panel(layout=awt.BorderLayout()) - graph = Graph() - p.add(graph, 'Center') - - expression = awt.TextField(text='(sin(3*x)+cos(x))/2', actionPerformed=enter) - p.add(expression, 'South') - - import pawt - pawt.test(p, size=(300,300)) - - enter(None) + def enter(e): + graph.setExpression(expression.text) + expression.caretPosition=0 + expression.selectAll() + + p = awt.Panel(layout=awt.BorderLayout()) + graph = Graph() + p.add(graph, 'Center') + + expression = awt.TextField(text='(sin(3*x)+cos(x))/2', actionPerformed=enter) + p.add(expression, 'South') + + import pawt + pawt.test(p, size=(300,300)) + + enter(None) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 18:57:04
|
Revision: 6655 http://jython.svn.sourceforge.net/jython/?rev=6655&view=rev Author: fwierzbicki Date: 2009-08-10 18:56:57 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Reindent. Modified Paths: -------------- trunk/jython/Lib/test/test__rawffi.py trunk/jython/Lib/test/test_array_jy.py trunk/jython/Lib/test/test_coerce_jy.py trunk/jython/Lib/test/test_func_syntax_jy.py trunk/jython/Lib/test/test_grammar_jy.py trunk/jython/Lib/test/test_java_visibility.py trunk/jython/Lib/test/test_sort_jy.py trunk/jython/Lib/test/test_str2unicode.py trunk/jython/Lib/test/test_stringmap.py trunk/jython/Lib/test/test_with.py Modified: trunk/jython/Lib/test/test__rawffi.py =================================================================== --- trunk/jython/Lib/test/test__rawffi.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test__rawffi.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -3,7 +3,7 @@ # xxx - forces a skip in the case we haven't built ctypes_test module in ant (which is not yet a task as of now) -try: +try: import _rawffi _rawffi.CDLL("ctypes_test") except: Modified: trunk/jython/Lib/test/test_array_jy.py =================================================================== --- trunk/jython/Lib/test/test_array_jy.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_array_jy.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -24,7 +24,7 @@ jStringArr = array(String, [String("a"), String("b"), String("c")]) self.assert_( Arrays.equals(jStringArr.typecode, 'java.lang.String'), - "String array typecode of wrong type, expected %s, found %s" % + "String array typecode of wrong type, expected %s, found %s" % (jStringArr.typecode, str(String))) self.assertEqual(zeros(String, 5), Array.newInstance(String, 5)) Modified: trunk/jython/Lib/test/test_coerce_jy.py =================================================================== --- trunk/jython/Lib/test/test_coerce_jy.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_coerce_jy.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -25,4 +25,3 @@ if __name__ == "__main__": test_main() - Modified: trunk/jython/Lib/test/test_func_syntax_jy.py =================================================================== --- trunk/jython/Lib/test/test_func_syntax_jy.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_func_syntax_jy.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -4,17 +4,17 @@ def parrot(**args): pass class FuncSyntaxTest(unittest.TestCase): - - def test_keywords_before_normal(self): - self.assertRaises(SyntaxError, eval, - "parrot(voltage=.5, \'dead\')") - def test_dup_keywords(self): - self.assertRaises(TypeError, eval, - "complex(imag=4, imag=2)") + def test_keywords_before_normal(self): + self.assertRaises(SyntaxError, eval, + "parrot(voltage=.5, \'dead\')") + def test_dup_keywords(self): + self.assertRaises(TypeError, eval, + "complex(imag=4, imag=2)") + def test_main(): - test.test_support.run_unittest(FuncSyntaxTest) + test.test_support.run_unittest(FuncSyntaxTest) if __name__ == "__main__": - test_main() + test_main() Modified: trunk/jython/Lib/test/test_grammar_jy.py =================================================================== --- trunk/jython/Lib/test/test_grammar_jy.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_grammar_jy.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -6,12 +6,12 @@ class GrammarTest(unittest.TestCase): def test_triple_quote_len(self): - s1 = r""" + s1 = r""" \""" 1.triple-quote \""" 2.triple-quote """ - s2 = r''' + s2 = r''' \""" 1.triple-quote \""" 2.triple-quote ''' Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_java_visibility.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -4,7 +4,7 @@ import sys from test import test_support from java.lang import Byte, Class, Integer -from java.util import ArrayList, Collections, HashMap, LinkedList, Observable, Observer +from java.util import ArrayList, Collections, HashMap, LinkedList, Observable, Observer from org.python.tests import (Coercions, HiddenSuper, InterfaceCombination, Invisible, Matryoshka, OnlySubclassable, OtherSubVisible, SomePyMethods, SubVisible, Visible, VisibleOverride) from org.python.tests import VisibilityResults as Results @@ -81,7 +81,7 @@ self.assertEquals(Results.OVERLOADED_EXTRA_ARG_PUBLIC_METHOD, v.visibleInstance('a', 'b')) self.assertEquals(Results.PUBLIC_STATIC_METHOD, Visible.visibleStatic(0)) - self.assertEquals(Results.OVERLOADED_PUBLIC_STATIC_METHOD, + self.assertEquals(Results.OVERLOADED_PUBLIC_STATIC_METHOD, v.visibleStatic('a')) self.assertEquals(Results.EXTRA_ARG_PUBLIC_STATIC_METHOD, v.visibleStatic(0, 'a')) @@ -103,11 +103,11 @@ self.assertEquals(Results.SUBCLASS_OVERRIDE, s.visibleInstance(3)) self.assertEquals(Results.SUBCLASS_OVERLOAD, s.visibleInstance(3.0, 'a')) self.assertEquals(Results.PACKAGE_METHOD, s.packageMethod()) - # Java methods don't allow direct calling of the superclass method, so it should + # Java methods don't allow direct calling of the superclass method, so it should # return the subclass value here. self.assertEquals(Results.SUBCLASS_OVERRIDE, Visible.visibleInstance(s, 3)) self.assertEquals(Results.PUBLIC_STATIC_FIELD, SubVisible.StaticInner.visibleStaticField) - + self.assertEquals(Results.VISIBLE_SHARED_NAME_FIELD, Visible.sharedNameField) self.assertEquals(Results.SUBVISIBLE_SHARED_NAME_FIELD, SubVisible.sharedNameField) self.assertEquals(Results.VISIBLE_SHARED_NAME_FIELD * 10, Visible().sharedNameField) @@ -129,7 +129,7 @@ "methods from IIFace should be visible on Implementation") self.assertEquals(InterfaceCombination.TWO_ARG_RESULT, i.getValue("one arg", "two arg"), "methods from Base should be visible on Implementation") - self.assertRaises(TypeError, i.getValue, "one arg", "two arg", "three arg", + self.assertRaises(TypeError, i.getValue, "one arg", "two arg", "three arg", "methods defined solely on Implementation shouldn't be visible") self.assertFalse(hasattr(i, "internalMethod"), "methods from private interfaces shouldn't be visible on a private class") Modified: trunk/jython/Lib/test/test_sort_jy.py =================================================================== --- trunk/jython/Lib/test/test_sort_jy.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_sort_jy.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -20,4 +20,4 @@ test_support.run_unittest(SortTest) if __name__ == "__main__": - test_main() + test_main() Modified: trunk/jython/Lib/test/test_str2unicode.py =================================================================== --- trunk/jython/Lib/test/test_str2unicode.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_str2unicode.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -19,7 +19,7 @@ self.assertEquals(unicode, type('%r %r' % (u'x', 'y'))) self.assertEquals(unicode, type('%(x)r' % {'x' : u'x'})) - def test_string_formatting_c(self): + def test_string_formatting_c(self): self.assertEquals(unicode, type('%c' % u'x')) self.assertEquals(unicode, type('%c %c' % (u'x', 'y'))) self.assertEquals(unicode, type('%(x)c' % {'x' : u'x'})) @@ -42,7 +42,7 @@ self.assertEquals(str, type('%r' % 'x')) self.assertEquals(str, type('%r %r' % ('x', 'y'))) self.assertEquals(str, type('%(x)r' % {'x' : 'x'})) - + def test_string_formatting_c(self): self.assertEquals(str, type('%c' % 'x')) self.assertEquals(str, type('%c %c' % ('x', 'y'))) Modified: trunk/jython/Lib/test/test_stringmap.py =================================================================== --- trunk/jython/Lib/test/test_stringmap.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_stringmap.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -12,7 +12,7 @@ class ClassDictTests(StringMapTest): """Check that class dicts conform to the mapping protocol""" - + def _empty_mapping(self): for key in SimpleClass.__dict__.copy(): SimpleClass.__dict__.pop(key) Modified: trunk/jython/Lib/test/test_with.py =================================================================== --- trunk/jython/Lib/test/test_with.py 2009-08-10 18:30:18 UTC (rev 6654) +++ trunk/jython/Lib/test/test_with.py 2009-08-10 18:56:57 UTC (rev 6655) @@ -704,14 +704,14 @@ NonLocalFlowControlTestCase, AssignmentTargetTestCase, ExitSwallowsExceptionTestCase, - ) + ) #XXX: punting NewKeywordsWarningTestCase at least for the # short term making "with" and "as" anything but true # keywords is not easy with the antlr parser though it is # probably doable. Just not a high priority compared to # other problems and in 2.6+ it is a non-problem since # these become true keywords in CPython. - # + # #NewKeywordsWarningTestCase) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 18:30:25
|
Revision: 6654 http://jython.svn.sourceforge.net/jython/?rev=6654&view=rev Author: fwierzbicki Date: 2009-08-10 18:30:18 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Merge test_bugfixes into test_exceptions, since test_bugfixes is a poor name and it was testing exception behaviors. Modified Paths: -------------- trunk/jython/Lib/test/test_exceptions_jy.py Removed Paths: ------------- trunk/jython/Lib/test/test_bugfixes.py Deleted: trunk/jython/Lib/test/test_bugfixes.py =================================================================== --- trunk/jython/Lib/test/test_bugfixes.py 2009-08-10 18:15:24 UTC (rev 6653) +++ trunk/jython/Lib/test/test_bugfixes.py 2009-08-10 18:30:18 UTC (rev 6654) @@ -1,31 +0,0 @@ - -import unittest -from test_support import run_suite - -class C: - def __str__(self): - raise Exception("E") - def __repr__(self): - raise Exception("S") - -class ExceptionHandling(unittest.TestCase): - def testBugFix1149372(self): - try: - c = C() - str(c) - except Exception, e: - assert e.args[0] == "E" - return - unittest.fail("if __str__ raises an exception, re-raise") - -def test_main(): - test_suite = unittest.TestSuite() - test_loader = unittest.TestLoader() - def suite_add(case): - test_suite.addTest(test_loader.loadTestsFromTestCase(case)) - suite_add(ExceptionHandling) - run_suite(test_suite) - -if __name__ == "__main__": - test_main() - Modified: trunk/jython/Lib/test/test_exceptions_jy.py =================================================================== --- trunk/jython/Lib/test/test_exceptions_jy.py 2009-08-10 18:15:24 UTC (rev 6653) +++ trunk/jython/Lib/test/test_exceptions_jy.py 2009-08-10 18:30:18 UTC (rev 6654) @@ -5,6 +5,12 @@ from test import test_support import unittest +class C: + def __str__(self): + raise Exception("E") + def __repr__(self): + raise Exception("S") + class ExceptionsTestCase(unittest.TestCase): def test_keyerror_str(self): @@ -26,6 +32,16 @@ self.assertEquals(r, "dummy") + def testBugFix1149372(self): + try: + c = C() + str(c) + except Exception, e: + assert e.args[0] == "E" + return + unittest.fail("if __str__ raises an exception, re-raise") + + def test_main(): test_support.run_unittest(ExceptionsTestCase) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-08-10 18:15:34
|
Revision: 6653 http://jython.svn.sourceforge.net/jython/?rev=6653&view=rev Author: fwierzbicki Date: 2009-08-10 18:15:24 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindents. Modified Paths: -------------- trunk/jython/Lib/test/test_SimpleXMLRPCServer.py trunk/jython/Lib/test/test_float_jy.py trunk/jython/Lib/test/test_joverload.py trunk/jython/Lib/test/test_list_jy.py trunk/jython/Lib/test/test_random.py trunk/jython/Lib/test/test_socket.py trunk/jython/Lib/test/test_thread_jy.py trunk/jython/Lib/test/test_trace_threaded.py trunk/jython/Lib/test/test_weakref.py Modified: trunk/jython/Lib/test/test_SimpleXMLRPCServer.py =================================================================== --- trunk/jython/Lib/test/test_SimpleXMLRPCServer.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_SimpleXMLRPCServer.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -14,9 +14,9 @@ class MyService: """This test class is going to be used to test an entire class being exposed via XML-RPC.""" - + def _dispatch(self, method, params): - """This method is called whenever a call is made to the + """This method is called whenever a call is made to the service.""" func = getattr(self, 'expose_' + method) return func(*params) @@ -37,7 +37,7 @@ self.server.allow_reuse_address = 1 self.server.handle_request() self.server.server_close() - + class SimpleXMLRPCServerTestCase(unittest.TestCase): """Test case for the Python SimpleXMLRPCServer module.""" def test_exposeLambda(self): Modified: trunk/jython/Lib/test/test_float_jy.py =================================================================== --- trunk/jython/Lib/test/test_float_jy.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_float_jy.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -101,7 +101,7 @@ def test_faux(self): class F(object): def __float__(self): - return 1.6 + return 1.6 self.assertEqual(math.cos(1.6), math.cos(F())) Modified: trunk/jython/Lib/test/test_joverload.py =================================================================== --- trunk/jython/Lib/test/test_joverload.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_joverload.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -12,7 +12,7 @@ def __init__(self,name,meths): self.reflfunc = PyReflectedFunction(meths) - + def __call__(self,inst,args): return self.reflfunc(inst,*args) @@ -21,8 +21,8 @@ names = [ m.name for m in meths] meth_dict = {} for name in names: - if name.startswith('ov_') and not meth_dict.has_key(name): - meth_dict[name] = envl_class(name,[ m for m in meths if m.name == name ]) + if name.startswith('ov_') and not meth_dict.has_key(name): + meth_dict[name] = envl_class(name,[ m for m in meths if m.name == name ]) return meth_dict from javatests import JOverload @@ -58,7 +58,7 @@ (java.io.Serializable) (java.io.Serializable) (java.io.Serializable) -(java.lang.Object) +(java.lang.Object) """) def test_scal_string(self): @@ -115,7 +115,7 @@ (java.io.Serializable) (java.io.Serializable) (java.io.Serializable) -(java.lang.Object) +(java.lang.Object) """) @@ -132,5 +132,3 @@ unittest.main() else: test_support.run_unittest(OverloadedDispatchTests) - - Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_list_jy.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -53,7 +53,7 @@ self.assertEqual([(1,), [1]].count([1]), 1) # http://bugs.jython.org/issue1317 class ThreadSafetyTestCase(unittest.TestCase): - + def run_threads(self, f, num=10): threads = [] for i in xrange(num): Modified: trunk/jython/Lib/test/test_random.py =================================================================== --- trunk/jython/Lib/test/test_random.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_random.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -532,7 +532,7 @@ if test_support.is_jython: del MersenneTwister_TestBasicOps.test_genrandbits - del MersenneTwister_TestBasicOps.test_referenceImplementation + del MersenneTwister_TestBasicOps.test_referenceImplementation del MersenneTwister_TestBasicOps.test_setstate_middle_arg del MersenneTwister_TestBasicOps.test_strong_reference_implementation Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_socket.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -819,12 +819,12 @@ def testBindSpecific(self): self.sock.bind( (self.HOST, self.PORT) ) # Use a specific port actual_port = self.sock.getsockname()[1] - self.failUnless(actual_port == self.PORT, - "Binding to specific port number should have returned same number: %d != %d" % (actual_port, self.PORT)) + self.failUnless(actual_port == self.PORT, + "Binding to specific port number should have returned same number: %d != %d" % (actual_port, self.PORT)) def testBindEphemeral(self): self.sock.bind( (self.HOST, 0) ) # let system choose a free port - self.failUnless(self.sock.getsockname()[1] != 0, "Binding to port zero should have allocated an ephemeral port number") + self.failUnless(self.sock.getsockname()[1] != 0, "Binding to port zero should have allocated an ephemeral port number") def testShutdown(self): self.sock.bind( (self.HOST, self.PORT) ) @@ -1003,7 +1003,7 @@ # AMAK: 20070311 # Introduced a new test for non-blocking connect # Renamed old testConnect to testBlockingConnect - # + # def testBlockingConnect(self): # Testing blocking connect @@ -1032,7 +1032,7 @@ # # AMAK: 20070518 # Introduced a new test for connect with bind to specific local address - # + # def testConnectWithLocalBind(self): # Test blocking connect @@ -1387,7 +1387,7 @@ self.failUnlessRaises(socket.timeout, raise_timeout, "TCP socket recv failed to generate a timeout exception (TCP)") - # Disable this test, but leave it present for documentation purposes + # Disable this test, but leave it present for documentation purposes # socket timeouts only work for read and accept, not for write # http://java.sun.com/j2se/1.4.2/docs/api/java/net/SocketTimeoutException.html def estSendTimeout(self): @@ -1683,11 +1683,11 @@ def test_main(): tests = [ - GeneralModuleTests, + GeneralModuleTests, TestSupportedOptions, TestUnsupportedOptions, - BasicTCPTest, - TCPServerTimeoutTest, + BasicTCPTest, + TCPServerTimeoutTest, TCPClientTimeoutTest, TestExceptions, TestInvalidUsage, Modified: trunk/jython/Lib/test/test_thread_jy.py =================================================================== --- trunk/jython/Lib/test/test_thread_jy.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_thread_jy.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -6,11 +6,11 @@ from java.util.concurrent import CountDownLatch class AllocateLockTest(unittest.TestCase): - + def test_lock_type(self): "thread.LockType should exist" t = thread.LockType - self.assertEquals(t, type(thread.allocate_lock()), + self.assertEquals(t, type(thread.allocate_lock()), "thread.LockType has wrong value") class SynchronizeTest(unittest.TestCase): Modified: trunk/jython/Lib/test/test_trace_threaded.py =================================================================== --- trunk/jython/Lib/test/test_trace_threaded.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_trace_threaded.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -8,47 +8,47 @@ class UntracedThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) - + def run(self): sys.settrace(None) for i in range(10): self.untracedcall() - + def untracedcall(self): pass - + class TracedThread(threading.Thread): def __init__(self, on_trace): threading.Thread.__init__(self) self.on_trace = on_trace - + def trace(self, frame, event, arg): self.on_trace(frame.f_code.co_name) - + def tracedcall(self): pass - + def run(self): sys.settrace(self.trace) for i in range(10): self.tracedcall() - + class TracePerThreadTest(unittest.TestCase): def testTracePerThread(self): called = [] def ontrace(co_name): called.append(str(co_name)) - + untraced = UntracedThread() traced = TracedThread(ontrace) untraced.start() traced.start() untraced.join() traced.join() - + self.assertEquals(10, called.count('tracedcall'), "10 tracedcall should be in %s" % called) - self.assert_('untracedcall' not in called, + self.assert_('untracedcall' not in called, "untracedcall shouldn't be in %s" % called) def test_main(): Modified: trunk/jython/Lib/test/test_weakref.py =================================================================== --- trunk/jython/Lib/test/test_weakref.py 2009-08-10 17:58:16 UTC (rev 6652) +++ trunk/jython/Lib/test/test_weakref.py 2009-08-10 18:15:24 UTC (rev 6653) @@ -659,7 +659,7 @@ weakref.ref(referenced, callback) finally: - # XXX: threshold not applicable to Jython + # XXX: threshold not applicable to Jython if not test_support.is_jython: gc.set_threshold(*thresholds) 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:58:24
|
Revision: 6652 http://jython.svn.sourceforge.net/jython/?rev=6652&view=rev Author: fwierzbicki Date: 2009-08-10 17:58:16 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Reindents. Modified Paths: -------------- trunk/jython/Lib/test/anygui.py trunk/jython/Lib/test/jser2_classes.py trunk/jython/Lib/test/test_cmath_jy.py trunk/jython/Lib/test/test_codeop_jy.py trunk/jython/Lib/test/test_import_jy.py trunk/jython/Lib/test/test_java_integration.py trunk/jython/Lib/test/test_module.py trunk/jython/Lib/test/test_set_jy.py trunk/jython/Lib/test/test_xml_etree_jy.py trunk/jython/Lib/test/test_zipimport_jy.py Modified: trunk/jython/Lib/test/anygui.py =================================================================== --- trunk/jython/Lib/test/anygui.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/anygui.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -27,7 +27,7 @@ candidates = wishlist + candidates for name in candidates: - backend = self.__try_to_get('%sgui' % name) + backend = self.__try_to_get('%sgui' % name) if not backend: raise Exception, 'not able to import any GUI backends' self.__backend = backend Modified: trunk/jython/Lib/test/jser2_classes.py =================================================================== --- trunk/jython/Lib/test/jser2_classes.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/jser2_classes.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -45,4 +45,3 @@ self.__dict__ == other.__dict__) def __ne__(self, other): return not (self == other) - Modified: trunk/jython/Lib/test/test_cmath_jy.py =================================================================== --- trunk/jython/Lib/test/test_cmath_jy.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/test_cmath_jy.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -20,55 +20,55 @@ unittest.TestCase.assertAlmostEqual(self, x.imag, y.imag, places, msg) def test_acos(self): - self.assertAlmostEqual(complex(0.936812, -2.30551), + self.assertAlmostEqual(complex(0.936812, -2.30551), cmath.acos(complex(3, 4))) - + def test_acosh(self): - self.assertAlmostEqual(complex(2.30551, 0.93681), + self.assertAlmostEqual(complex(2.30551, 0.93681), cmath.acosh(complex(3, 4))) def test_asin(self): - self.assertAlmostEqual(complex(0.633984, 2.30551), + self.assertAlmostEqual(complex(0.633984, 2.30551), cmath.asin(complex(3, 4))) def test_asinh(self): - self.assertAlmostEqual(complex(2.29991, 0.917617), + self.assertAlmostEqual(complex(2.29991, 0.917617), cmath.asinh(complex(3, 4))) def test_atan(self): - self.assertAlmostEqual(complex(1.44831, 0.158997), + self.assertAlmostEqual(complex(1.44831, 0.158997), cmath.atan(complex(3, 4))) def test_atanh(self): - self.assertAlmostEqual(complex(0.11750, 1.40992), + self.assertAlmostEqual(complex(0.11750, 1.40992), cmath.atanh(complex(3, 4))) def test_cos(self): - self.assertAlmostEqual(complex(-27.03495, -3.851153), + self.assertAlmostEqual(complex(-27.03495, -3.851153), cmath.cos(complex(3, 4))) def test_cosh(self): - self.assertAlmostEqual(complex(-6.58066, -7.58155), + self.assertAlmostEqual(complex(-6.58066, -7.58155), cmath.cosh(complex(3, 4))) def test_exp(self): - self.assertAlmostEqual(complex(-13.12878, -15.20078), + self.assertAlmostEqual(complex(-13.12878, -15.20078), cmath.exp(complex(3, 4))) def test_log(self): - self.assertAlmostEqual(complex(1.60944, 0.927295), + self.assertAlmostEqual(complex(1.60944, 0.927295), cmath.log(complex(3, 4))) def test_log10(self): - self.assertAlmostEqual(complex(0.69897, 0.40272), + self.assertAlmostEqual(complex(0.69897, 0.40272), cmath.log10(complex(3, 4))) def test_sin(self): - self.assertAlmostEqual(complex(3.853738, -27.01681), + self.assertAlmostEqual(complex(3.853738, -27.01681), cmath.sin(complex(3, 4))) def test_sinh(self): - self.assertAlmostEqual(complex(-6.54812, -7.61923), + self.assertAlmostEqual(complex(-6.54812, -7.61923), cmath.sinh(complex(3, 4))) def test_sqrt_real_positive(self): @@ -78,7 +78,7 @@ def test_sqrt_real_zero(self): self.assertAlmostEqual(complex(1.41421, 1.41421), cmath.sqrt(complex(0, 4))) - + def test_sqrt_real_negative(self): self.assertAlmostEqual(complex(1, 2), cmath.sqrt(complex(-3, 4))) @@ -92,11 +92,11 @@ cmath.sqrt(complex(-3, -4))) def test_tan(self): - self.assertAlmostEqual(complex(-0.000187346, 0.999356), + self.assertAlmostEqual(complex(-0.000187346, 0.999356), cmath.tan(complex(3, 4))) def test_tanh(self): - self.assertAlmostEqual(complex(1.00071, 0.00490826), + self.assertAlmostEqual(complex(1.00071, 0.00490826), cmath.tanh(complex(3, 4))) def test_main(): @@ -104,6 +104,3 @@ if __name__ == "__main__": test_main() - - - Modified: trunk/jython/Lib/test/test_codeop_jy.py =================================================================== --- trunk/jython/Lib/test/test_codeop_jy.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/test_codeop_jy.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -16,14 +16,14 @@ '''succeed iff str is a valid piece of code''' code = compile_(str, "<input>", symbol) if values: - d = {} + d = {} exec code in d self.assertEquals(d,values) elif value is not None: self.assertEquals(eval(code,self.eval_d),value) else: self.assert_(code) - + def assertInvalid(self, str, symbol='single', is_syntax=1): '''succeed iff str is the start of an invalid piece of code''' try: @@ -58,7 +58,7 @@ # can be deleted. def test_invalid(self): ai = self.assertInvalid - + ai("del 1") ai("del ()") ai("del (1,)") Modified: trunk/jython/Lib/test/test_import_jy.py =================================================================== --- trunk/jython/Lib/test/test_import_jy.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/test_import_jy.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -181,7 +181,7 @@ module = os.path.basename(sym) module_obj = __import__(module) self.assertEquals(module_obj.test, 'imported') - + finally: shutil.rmtree(test_support.TESTFN) test_support.unlink(sym) Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/test_java_integration.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -4,7 +4,7 @@ import subprocess import sys import re - + from test import test_support from java.lang import (ClassCastException, ExceptionInInitializerError, String, Runnable, System, @@ -62,7 +62,7 @@ self.assertEquals(1, len(called)) m.fireComponentHidden(ComponentEvent(Container(), 0)) self.assertEquals(2, len(called)) - + def test_bean_interface(self): b = BeanImplementation() self.assertEquals("name", b.getName()) @@ -111,7 +111,7 @@ f = open(test_support.TESTFN) self.assertEquals('hello', f.read()) f.close() - + class IOTest(unittest.TestCase): def test_io_errors(self): "Check that IOException isn't mangled into an IOError" @@ -132,11 +132,11 @@ def test_system_in(self): s = System.in self.assert_("java.io.BufferedInputStream" in str(s)) - + def test_runtime_exec(self): e = Runtime.getRuntime().exec self.assert_(re.search("method .*exec", str(e)) is not None) - + def test_byte_class(self): b = Byte(10) self.assert_("java.lang.Byte" in str(b.class)) @@ -183,7 +183,7 @@ def test_in(self): self.assertEquals(self.kws.in(), "in") - + def test_exec(self): self.assertEquals(self.kws.exec(), "exec") @@ -284,7 +284,7 @@ def test_static_fields(self): self.assertEquals(Color(255, 0, 0), Color.RED) - # The bean accessor for getRed should be active on instances, but the static field red + # The bean accessor for getRed should be active on instances, but the static field red # should be visible on the class self.assertEquals(255, Color.red.red) self.assertEquals(Color(0, 0, 255), Color.blue) @@ -416,7 +416,7 @@ self.assertTrue(not x.equals(z)) self.assertNotEquals(x, z) self.assertTrue(not (x == z)) - + class SecurityManagerTest(unittest.TestCase): def test_nonexistent_import_with_security(self): script = test_support.findfile("import_nonexistent.py") @@ -452,13 +452,13 @@ self.assertEquals(7, m.held["initial"], "Existing fields should still be accessible") self.assertEquals(7, m.initial) self.assertEquals(None, m.nonexistent, "Nonexistent fields should be passed on to the Map") - - def test_adding_on_interface(self): + + def test_adding_on_interface(self): GetitemAdder.addPredefined() class UsesInterfaceMethod(FirstPredefinedGetitem): pass self.assertEquals("key", UsesInterfaceMethod()["key"]) - + def test_add_on_mro_conflict(self): """Adding same-named methods to Java classes with MRO conflicts produces TypeError""" GetitemAdder.addPredefined() @@ -479,8 +479,8 @@ self.assertEqual(date_list, unserializer.readObject()) def test_main(): - test_support.run_unittest(InstantiationTest, - BeanTest, + test_support.run_unittest(InstantiationTest, + BeanTest, SysIntegrationTest, IOTest, JavaReservedNamesTest, Modified: trunk/jython/Lib/test/test_module.py =================================================================== --- trunk/jython/Lib/test/test_module.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/test_module.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -12,7 +12,7 @@ pass else: raise TestFailed, "__name__ = %s" % repr(s) -# __doc__ is None by default in CPython but not in Jython. +# __doc__ is None by default in CPython but not in Jython. # We're not worrying about that now. #vereq(foo.__doc__, module.__doc__) Modified: trunk/jython/Lib/test/test_set_jy.py =================================================================== --- trunk/jython/Lib/test/test_set_jy.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/test_set_jy.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -20,7 +20,7 @@ self.assertEqual(s & foo, 'rand') self.assertEqual(s ^ foo, 'rxor') - + class SetInJavaTestCase(unittest.TestCase): """Tests for derived dict behaviour""" Modified: trunk/jython/Lib/test/test_xml_etree_jy.py =================================================================== --- trunk/jython/Lib/test/test_xml_etree_jy.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/test_xml_etree_jy.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -110,7 +110,7 @@ >>> parser = expat.ParserCreate(namespace_separator='!') >>> HANDLER_NAMES = [ ... 'StartElementHandler', 'EndElementHandler', - ... 'CharacterDataHandler', + ... 'CharacterDataHandler', ... 'ProcessingInstructionHandler', ... 'UnparsedEntityDeclHandler', 'NotationDeclHandler', ... 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler', @@ -451,9 +451,9 @@ def test_entity(): """ - + TODO: need a fallback for entity-resolver so that empty source is returned. - + >>> xml = ''' <!DOCTYPE doc SYSTEM "external.dtd" [ ... <!ENTITY ext-entity SYSTEM "external-entity"> ... ]> Modified: trunk/jython/Lib/test/test_zipimport_jy.py =================================================================== --- trunk/jython/Lib/test/test_zipimport_jy.py 2009-08-10 17:39:21 UTC (rev 6651) +++ trunk/jython/Lib/test/test_zipimport_jy.py 2009-08-10 17:58:16 UTC (rev 6652) @@ -27,5 +27,3 @@ if __name__ == "__main__": test_main() - - 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:39:29
|
Revision: 6651 http://jython.svn.sourceforge.net/jython/?rev=6651&view=rev Author: fwierzbicki Date: 2009-08-10 17:39:21 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Trivial reindents. Modified Paths: -------------- trunk/jython/Lib/test/test_builtin_jy.py trunk/jython/Lib/test/test_concat_jy.py trunk/jython/Lib/test/test_descr_jy.py trunk/jython/Lib/test/test_importhooks.py trunk/jython/Lib/test/test_java_subclasses.py trunk/jython/Lib/test/test_jser.py trunk/jython/Lib/test/test_pbcvm.py trunk/jython/Lib/test/test_re_jy.py trunk/jython/Lib/test/test_subclasses.py trunk/jython/Lib/test/test_sys_jy.py Modified: trunk/jython/Lib/test/test_builtin_jy.py =================================================================== --- trunk/jython/Lib/test/test_builtin_jy.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_builtin_jy.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -7,7 +7,7 @@ from codecs import BOM_UTF8 class BuiltinTest(unittest.TestCase): - + def test_in_sys_modules(self): self.assert_("__builtin__" in sys.modules, "__builtin__ not found in sys.modules") @@ -79,7 +79,7 @@ def test_unbound(self): "Unbound methods indicated properly in repr" class Foo: - def bar(s): + def bar(s): pass self.failUnless(repr(Foo.bar).startswith('<unbound method')) @@ -210,8 +210,8 @@ self.assertEqual(eval('locals()', g, d), d) # Verify locals stores (used by list comps) - eval('[locals() for i in (2,3)]', g, d) - eval('[locals() for i in (2,3)]', g, UserDict.UserDict()) + eval('[locals() for i in (2,3)]', g, d) + eval('[locals() for i in (2,3)]', g, UserDict.UserDict()) class SpreadSheet: "Sample application showing nested, calculated lookups." Modified: trunk/jython/Lib/test/test_concat_jy.py =================================================================== --- trunk/jython/Lib/test/test_concat_jy.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_concat_jy.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -83,8 +83,8 @@ def test_main(): - test.test_support.run_unittest(StrUnicodeConcatTestCase, - StrUnicodeConcatOverridesTestCase) + test.test_support.run_unittest(StrUnicodeConcatTestCase, + StrUnicodeConcatOverridesTestCase) if __name__ == "__main__": - test_main() + test_main() Modified: trunk/jython/Lib/test/test_descr_jy.py =================================================================== --- trunk/jython/Lib/test/test_descr_jy.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_descr_jy.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -230,7 +230,7 @@ pass class Bar(object): def __radd__(self, other): - return 3 + return 3 self.assertEqual(Foo() + Bar(), 3) def test_int_mul(self): Modified: trunk/jython/Lib/test/test_importhooks.py =================================================================== --- trunk/jython/Lib/test/test_importhooks.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_importhooks.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -212,4 +212,3 @@ if __name__ == "__main__": test_main() - Modified: trunk/jython/Lib/test/test_java_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_java_subclasses.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_java_subclasses.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -45,7 +45,7 @@ c = ComparableRunner() c.compareTo(None) c.run() - self.assertEquals(calls, ["ComparableRunner.compareTo", "Runner.run"]) + self.assertEquals(calls, ["ComparableRunner.compareTo", "Runner.run"]) class TableModelTest(unittest.TestCase): def test_class_coercion(self): @@ -56,19 +56,19 @@ def getColumnCount(self): return len(self.columnNames) - + def getRowCount(self): return len(self.data) - + def getColumnName(self, col): return self.columnNames[col] def getValueAt(self, row, col): return self.data[row][col] - + def getColumnClass(self, c): return Object.getClass(self.getValueAt(0, c)) - + def isCellEditable(self, row, col): return col >= 2 @@ -127,13 +127,13 @@ def method(self): return "SubDateMethod" - def toString(self): + def toString(self): s = Date.toString(self) return 'SubDate -> Date' class SubSubDate(SubDate, Runnable): def toString(self): - return 'SubSubDate -> ' + SubDate.toString(self) + return 'SubSubDate -> ' + SubDate.toString(self) self.assertEquals("SubDate -> Date", SubDate().toString()) self.assertEquals("SubSubDate -> SubDate -> Date", SubSubDate().toString()) @@ -175,7 +175,7 @@ class A(Component): pass A() - + def test_return_proxy(self): "Jython proxies properly return back from Java code" class FooVector(Vector): @@ -256,7 +256,7 @@ class AbstractOnSyspathTest(unittest.TestCase): '''Subclasses an abstract class that isn't on the startup classpath. - + Checks for http://jython.org/bugs/1861985 ''' def setUp(self): @@ -272,7 +272,7 @@ def test_can_subclass_abstract(self): import Abstract - + class A(Abstract): def method(self): pass @@ -297,7 +297,7 @@ """.decode('base64').decode('zlib') class ContextClassloaderTest(unittest.TestCase): '''Classes on the context classloader should be importable and subclassable. - + http://bugs.jython.org/issue1216''' def setUp(self): self.orig_context = Thread.currentThread().contextClassLoader @@ -360,7 +360,7 @@ import static_proxy # Use the existing environment with the proxy dir added on the classpath - env = dict(os.environ) + env = dict(os.environ) env["CLASSPATH"] = sys.javaproxy_dir script = test_support.findfile("import_as_java_class.py") self.assertEquals(subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", Modified: trunk/jython/Lib/test/test_jser.py =================================================================== --- trunk/jython/Lib/test/test_jser.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_jser.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -8,8 +8,8 @@ object1 = 42 object2 = ['a', 1, 1.0] class Foo: - def bar(self): - return 'bar' + def bar(self): + return 'bar' object3 = Foo() object3.baz = 99 Modified: trunk/jython/Lib/test/test_pbcvm.py =================================================================== --- trunk/jython/Lib/test/test_pbcvm.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_pbcvm.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -49,7 +49,7 @@ def test_regrtest_pyc(self): for test in ( # change the names a bit so we don't have to worry about module unloading or spawning a separate JVM - # however, this testing approach too limits the tests that can be run, so we should rewrite to + # however, this testing approach too limits the tests that can be run, so we should rewrite to # use subprocess asap 'test_types_pyc', 'test_exceptions_pyc'): @@ -61,9 +61,9 @@ # typical unsafe ops we have to do in testing... test_support.verbose = self.old_verbosity sys.path.pop(0) - sys.meta_path.pop(0) - + sys.meta_path.pop(0) + def test_main(): test_support.run_unittest(PyBytecodeTest, AdhocRegrtest) Modified: trunk/jython/Lib/test/test_re_jy.py =================================================================== --- trunk/jython/Lib/test/test_re_jy.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_re_jy.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -25,14 +25,14 @@ result = re.sub('bar', 'baz', Foo2('bar')) self.assertEqual(result, Foo2('baz')) self.assert_(isinstance(result, Foo2)) - + def test_unkown_groupname(self): self.assertRaises(IndexError, re.match("(?P<int>\d+)\.(\d*)", '3.14').group, "misspelled") def test_main(): - test.test_support.run_unittest(ReTest) + test.test_support.run_unittest(ReTest) if __name__ == "__main__": - test_main() + test_main() Modified: trunk/jython/Lib/test/test_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_subclasses.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_subclasses.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -1,7 +1,7 @@ from test import test_support import unittest import pickle - + #myint and its test taken from pickletester, the other "my" classes and tests # are based on it. class myint(int): @@ -82,7 +82,7 @@ self.assertEqual(Spam(), 0L) self.assertEqual(str(Spam()), "hi") - + def test_tuple(self): class Spam(tuple): def __str__(self): @@ -181,7 +181,7 @@ s = pickle.dumps(picklee) y = pickle.loads(s) self.assertEqual(picklee, y) - + def test_pickle_builtins(self): #ignores cPickle for now. Modified: trunk/jython/Lib/test/test_sys_jy.py =================================================================== --- trunk/jython/Lib/test/test_sys_jy.py 2009-08-10 17:35:54 UTC (rev 6650) +++ trunk/jython/Lib/test/test_sys_jy.py 2009-08-10 17:39:21 UTC (rev 6651) @@ -75,12 +75,12 @@ from org.python.core import Py from org.python.util import PythonInterpreter from org.python.core import PySystemState - + ps = PySystemState() pi = PythonInterpreter({}, ps) if not sharing: ps.shadow() - ps.builtins = ps.builtins.copy() + ps.builtins = ps.builtins.copy() pi.exec(function.func_code) import threading @@ -94,7 +94,7 @@ import test.sys_jy_test_module # used as a probe # can't use 'foo', test_with wants to have that undefined - sys.builtins['test_sys_jy_foo'] = 42 + sys.builtins['test_sys_jy_foo'] = 42 def set_shadow(): @@ -127,8 +127,8 @@ def test_sys_modules_per_instance(self): import sys self.assertTrue('sys_jy_test_module' not in sys.modules, "sys.modules should be per PySystemState instance") - + def test_main(): test.test_support.run_unittest(SysTest, ShadowingTest) 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:36:03
|
Revision: 6650 http://jython.svn.sourceforge.net/jython/?rev=6650&view=rev Author: fwierzbicki Date: 2009-08-10 17:35:54 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Reindents. Modified Paths: -------------- trunk/jython/Lib/test/test_dict2java.py trunk/jython/Lib/test/test_javashell.py trunk/jython/Lib/test/test_jbasic.py trunk/jython/Lib/test/test_jy_generators.py trunk/jython/Lib/test/test_marshal.py trunk/jython/Lib/test/test_thread_local.py trunk/jython/Lib/test/test_tuple.py Modified: trunk/jython/Lib/test/test_dict2java.py =================================================================== --- trunk/jython/Lib/test/test_dict2java.py 2009-08-10 17:32:50 UTC (rev 6649) +++ trunk/jython/Lib/test/test_dict2java.py 2009-08-10 17:35:54 UTC (rev 6650) @@ -45,7 +45,7 @@ self.checksize(oldlen + 3) self.checkvalues(('e', '1'), ('f', None), ('g', '2')) - # test Map.get method, get "g" and "d" test will throw an exception if fail + # test Map.get method, get "g" and "d" test will throw an exception if fail self.failUnless(self.testmap.test_get_gd()) # remove elements with keys "a" and "c" with the Map.remove method Modified: trunk/jython/Lib/test/test_javashell.py =================================================================== --- trunk/jython/Lib/test/test_javashell.py 2009-08-10 17:32:50 UTC (rev 6649) +++ trunk/jython/Lib/test/test_javashell.py 2009-08-10 17:35:54 UTC (rev 6650) @@ -41,12 +41,12 @@ # should print 'testKey=' on 95 before initialization, # and 'testKey=testValue' after ("echo %s=%%%s%%" % (key,key), - "(%s=)" % (key,)), + "(%s=)" % (key,)), # should print PATH (on Unix) ( "echo PATH=$PATH", "PATH=.*" ), # should print 'testKey=testValue' on Unix after initialization ( "echo %s=$%s" % (key,key), - "(%s=$%s)|(%s=)|(%s=%s)" % (key, key, key, key, value ) ), + "(%s=$%s)|(%s=)|(%s=%s)" % (key, key, key, key, value ) ), # should output quotes on NT but not on Unix ( 'echo "hello there"', '"?hello there"?' ), # should print 'why' to stdout. @@ -138,4 +138,3 @@ if __name__ == "__main__": test_main() - Modified: trunk/jython/Lib/test/test_jbasic.py =================================================================== --- trunk/jython/Lib/test/test_jbasic.py 2009-08-10 17:32:50 UTC (rev 6649) +++ trunk/jython/Lib/test/test_jbasic.py 2009-08-10 17:35:54 UTC (rev 6650) @@ -28,12 +28,12 @@ vec = Vector() items = range(10) for i in items: - vec.addElement(i) + vec.addElement(i) expected = 0 for i in vec: - assert i == expected, 'testing __iter__ on java.util.Vector' - expected = expected+1 + assert i == expected, 'testing __iter__ on java.util.Vector' + expected = expected+1 expected = 0 for i in iter(vec): @@ -76,11 +76,11 @@ #Make sure non-existent fields fail try: - print d.foo + print d.foo except AttributeError: - pass + pass else: - raise AssertionError, 'd.foo should throw type error' + raise AssertionError, 'd.foo should throw type error' print 'get/set bean properties' @@ -94,8 +94,8 @@ # Test bean event properties - single and multiple flag = 0 def testAction(event): - global flag - flag = flag + 1 + global flag + flag = flag + 1 from java.awt.event import ActionEvent Modified: trunk/jython/Lib/test/test_jy_generators.py =================================================================== --- trunk/jython/Lib/test/test_jy_generators.py 2009-08-10 17:32:50 UTC (rev 6649) +++ trunk/jython/Lib/test/test_jy_generators.py 2009-08-10 17:35:54 UTC (rev 6650) @@ -43,7 +43,7 @@ try: for i in range(3): try: - try: + try: 1//0 finally: yield i @@ -85,7 +85,7 @@ finally: for k in range(j): try: - try: + try: 1//0 finally: yield (i, j, k) @@ -98,7 +98,7 @@ 1//0 finally: for k in range(3): - try: + try: 1//0 finally: yield (j, k) @@ -115,7 +115,7 @@ 1//0 finally: for k in range(3): - try: + try: 1//0 finally: yield (i, j, k) @@ -127,7 +127,7 @@ self.assertEquals([0, 1, 2], list(self.genPass())) self.assertEquals([1], list(self.genLocal())) self.assertEquals( - [1, 2, 1, 2, 0, 1], + [1, 2, 1, 2, 0, 1], list(self.genConditional())) self.assertEquals([0, 1, 2, 3], list(self.genTryExceptAroundFinally())) self.assertEquals( @@ -137,7 +137,7 @@ [(0, 0), (0, 1), (1, 0), (1, 1)], list(self.genNestedReversed())) self.assertEquals( - [(2, 1, 0), (3, 1, 0), (3, 2, 0), (3, 2, 1)], + [(2, 1, 0), (3, 1, 0), (3, 2, 0), (3, 2, 1)], list(self.genNestedDeeply())) self.assertEquals( [(0, 0), (1, 0), (2, 0)], @@ -162,4 +162,3 @@ if __name__ == "__main__": unittest.main() - Modified: trunk/jython/Lib/test/test_marshal.py =================================================================== --- trunk/jython/Lib/test/test_marshal.py 2009-08-10 17:32:50 UTC (rev 6649) +++ trunk/jython/Lib/test/test_marshal.py 2009-08-10 17:35:54 UTC (rev 6650) @@ -18,8 +18,8 @@ with open(test_support.TESTFN, "rb") as test_file: got = marshal.load(test_file) return got - + class IntTestCase(unittest.TestCase): def test_ints(self): # Test the full range of Python ints. Modified: trunk/jython/Lib/test/test_thread_local.py =================================================================== --- trunk/jython/Lib/test/test_thread_local.py 2009-08-10 17:32:50 UTC (rev 6649) +++ trunk/jython/Lib/test/test_thread_local.py 2009-08-10 17:35:54 UTC (rev 6650) @@ -1,12 +1,12 @@ #! /usr/bin/env python -""" Simple test script for Thread.local +""" Simple test script for Thread.local """ from thread import _local as local import unittest from test import test_support import threading -class ThreadLocalTestCase(unittest.TestCase): +class ThreadLocalTestCase(unittest.TestCase): def test_two_locals(self): '''Ensures that two locals in the same thread have separate dicts.''' @@ -20,19 +20,19 @@ def test_local(self): mydata = local() mydata.number = 42 - self.assertEqual(mydata.number,42) + self.assertEqual(mydata.number,42) self.assertEqual(mydata.__dict__,{'number': 42}) mydata.__dict__.setdefault('widgets', []) self.assertEqual(mydata.widgets,[]) log=[] - - def f(): - items = mydata.__dict__.items() - items.sort() + + def f(): + items = mydata.__dict__.items() + items.sort() log.append(items) - mydata.number = 11 - log.append(mydata.number) - + mydata.number = 11 + log.append(mydata.number) + thread = threading.Thread(target=f) thread.start() thread.join() @@ -40,12 +40,12 @@ self.assertEqual(mydata.number,42) def test_subclass_local(self): - def f(): - items = mydata.__dict__.items() - items.sort() + def f(): + items = mydata.__dict__.items() + items.sort() log.append(items) - mydata.number = 11 - log.append(mydata.number) + mydata.number = 11 + log.append(mydata.number) class MyLocal(local): number = 2 @@ -54,13 +54,13 @@ if self.initialized: raise SystemError('__init__ called too many times') self.initialized = True - self.__dict__.update(kw) + self.__dict__.update(kw) def squared(self): return self.number ** 2 - + class SubSubLocal(MyLocal): pass - + mydata = MyLocal(color='red') self.assertEqual(mydata.number,2) self.assertEqual(mydata.color,'red') Modified: trunk/jython/Lib/test/test_tuple.py =================================================================== --- trunk/jython/Lib/test/test_tuple.py 2009-08-10 17:32:50 UTC (rev 6649) +++ trunk/jython/Lib/test/test_tuple.py 2009-08-10 17:35:54 UTC (rev 6650) @@ -48,7 +48,7 @@ except OutOfMemoryError, oome: oome.printStackTrace() raise - + def _test_hash(self): # See SF bug 942952: Weakness in tuple hash # The hash should: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |