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: brian z. <bz...@us...> - 2002-01-08 05:39:35
|
Update of /cvsroot/jython/jython/Lib/test/zxjdbc In directory usw-pr-cvs1:/tmp/cvs-serv18246/Lib/test/zxjdbc Modified Files: zxtest.py Log Message: implemented iteration protocol Index: zxtest.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/test/zxjdbc/zxtest.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** zxtest.py 2002/01/07 02:59:00 1.7 --- zxtest.py 2002/01/08 05:39:32 1.8 *************** *** 100,103 **** --- 100,118 ---- c.close() + def testIteration(self): + """testing the iteration protocol""" + c = self.cursor() + try: + c.execute("select * from zxtesting") + cnt = 0 + for a in c: + assert a is not None, "row is None" + self.assertEquals(3, len(a)) + cnt += 1 + self.assertEquals(7, cnt) + c.execute("select * from zxtesting") + finally: + c.close() + def testColumns(self): """testing cursor.columns()""" *************** *** 358,361 **** --- 373,377 ---- def testUpdateCount(self): + """testing update count functionality""" c = self.cursor() try: *************** *** 559,563 **** def testRowid(self): ! """test the autoincrement facilities of the different handlers""" assert self.has_table("autoincrementtable"), "no autoincrement table" --- 575,579 ---- def testRowid(self): ! """testing the autoincrement facilities of the different handlers""" assert self.has_table("autoincrementtable"), "no autoincrement table" |
From: brian z. <bz...@us...> - 2002-01-08 04:28:52
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv5767/org/python/core Modified Files: CollectionIter2.java Log Message: dictionaries return the keys in an iteration, not the (key,value) mapping Index: CollectionIter2.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/CollectionIter2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CollectionIter2.java 2002/01/07 20:13:44 1.1 --- CollectionIter2.java 2002/01/08 04:28:49 1.2 *************** *** 11,15 **** PyObject findCollection(Object object) { if (object instanceof Map) { ! return new IteratorIter(((Map)object).entrySet().iterator()); } if (object instanceof Collection) { --- 11,15 ---- PyObject findCollection(Object object) { if (object instanceof Map) { ! return new IteratorIter(((Map)object).keySet().iterator()); } if (object instanceof Collection) { |
From: Finn B. <bc...@us...> - 2002-01-07 20:13:49
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv10920 Added Files: CollectionIter.java CollectionIter2.java Log Message: Support iteration over java instances. --- NEW FILE: CollectionIter.java --- // Copyright (c) Finn Bock package org.python.core; import java.util.*; class CollectionIter extends PyObject { PyObject findCollection(Object object) { if (object instanceof Vector) { return new EnumerationIter(((Vector)object).elements()); } if (object instanceof Enumeration) { return new EnumerationIter(((Enumeration)object)); } if (object instanceof Dictionary) { return new EnumerationIter(((Dictionary)object).keys()); } return null; } public PyObject next() { PyObject ret = __iternext__(); if (ret == null) throw Py.StopIteration(null); return ret; } } class EnumerationIter extends CollectionIter { private Enumeration proxy; public EnumerationIter(Enumeration proxy) { this.proxy = proxy; } public PyObject __iternext__() { if (!proxy.hasMoreElements()) return null; return Py.java2py(proxy.nextElement()); } } --- NEW FILE: CollectionIter2.java --- // Copyright (c) Finn Bock package org.python.core; import java.util.*; class CollectionIter2 extends CollectionIter { CollectionIter2() throws Exception { Class.forName("java.util.Collection"); } PyObject findCollection(Object object) { if (object instanceof Map) { return new IteratorIter(((Map)object).entrySet().iterator()); } if (object instanceof Collection) { return new IteratorIter(((Collection)object).iterator()); } if (object instanceof Iterator) { return new IteratorIter(((Iterator)object)); } return null; } } class IteratorIter extends CollectionIter { private Iterator proxy; public IteratorIter(Iterator proxy) { this.proxy = proxy; } public PyObject __iternext__() { if (!proxy.hasNext()) return null; return Py.java2py(proxy.next()); } } |
From: Finn B. <bc...@us...> - 2002-01-07 20:07:58
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv9016 Modified Files: PyInstance.java Log Message: Support iteration over java instances. Index: PyInstance.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyInstance.java,v retrieving revision 2.29 retrieving revision 2.30 diff -C2 -d -r2.29 -r2.30 *** PyInstance.java 2002/01/06 21:19:13 2.29 --- PyInstance.java 2002/01/07 20:07:53 2.30 *************** *** 2,5 **** --- 2,6 ---- package org.python.core; import java.util.Hashtable; + import java.util.StringTokenizer; import java.io.Serializable; *************** *** 602,605 **** --- 603,610 ---- public PyObject __iter__() { + PyObject iter = getCollectionIter(); + if (iter != null) { + return iter; + } PyObject func = __findattr__("__iter__"); if (func != null) *************** *** 623,626 **** --- 628,665 ---- } throw Py.TypeError("instance has no next() method"); + } + + private static CollectionIter[] iterFactories = null; + + private PyObject getCollectionIter() { + if (iterFactories == null) + initializeIterators(); + for (int i = 0; iterFactories[i] != null; i++) { + PyObject iter = iterFactories[i].findCollection(javaProxy); + if (iter != null) + return iter; + } + return null; + } + + private static synchronized void initializeIterators() { + if (iterFactories != null) + return; + String factories = "org.python.core.CollectionIter," + + "org.python.core.CollectionIter2," + + Py.getSystemState().registry.getProperty( + "python.collections", ""); + int i = 0; + StringTokenizer st = new StringTokenizer(factories, ","); + iterFactories = new CollectionIter[st.countTokens() + 1]; + while (st.hasMoreTokens()) { + String s = st.nextToken(); + try { + Class factoryClass = Class.forName(s); + CollectionIter factory = + (CollectionIter)factoryClass.newInstance(); + iterFactories[i++] = factory; + } catch (Throwable t) { } + } } |
From: Finn B. <bc...@us...> - 2002-01-07 20:00:13
|
Update of /cvsroot/jython/jython/Tools/jythonc In directory usw-pr-cvs1:/tmp/cvs-serv6014 Modified Files: SimpleCompiler.py Log Message: Support for the __iter__ protocol. Index: SimpleCompiler.py =================================================================== RCS file: /cvsroot/jython/jython/Tools/jythonc/SimpleCompiler.py,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** SimpleCompiler.py 2001/12/07 12:58:17 2.18 --- SimpleCompiler.py 2002/01/07 20:00:10 2.19 *************** *** 696,711 **** def for_stmt(self, index, sequence, body, else_body=None): ! counter = self.frame.gettemp('int') item = self.factory.makePyObject(self.frame.gettemp("PyObject")) ! seq = self.frame.gettemp("PyObject") init = [] ! init.append( jast.Set(counter, jast.IntegerConstant(0)) ) ! init.append( jast.Set(seq, self.visit(sequence).asAny()) ) ! ! counter_inc = jast.PostOperation(counter, '++') ! test = jast.Set(item.asAny(), jast.Invoke(seq, "__finditem__", ! [counter_inc])) test = jast.Operation('!=', test, jast.Identifier('null')) --- 696,707 ---- def for_stmt(self, index, sequence, body, else_body=None): ! iter = self.frame.gettemp('PyObject') item = self.factory.makePyObject(self.frame.gettemp("PyObject")) ! seq = self.visit(sequence).asAny() init = [] ! init.append(jast.Set(iter, jast.Invoke(seq, "__iter__", []))) ! test = jast.Set(item.asAny(), jast.Invoke(iter, "__iternext__", [])) test = jast.Operation('!=', test, jast.Identifier('null')) |
From: Finn B. <bc...@us...> - 2002-01-07 12:01:23
|
Update of /cvsroot/jython/jython/Lib In directory usw-pr-cvs1:/tmp/cvs-serv5486 Modified Files: javaos.py Log Message: Define "extsep". Index: javaos.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/javaos.py,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** javaos.py 2001/11/28 17:31:50 2.12 --- javaos.py 2002/01/07 12:00:49 2.13 *************** *** 45,48 **** --- 45,52 ---- defpath = '.' linesep = java.lang.System.getProperty('line.separator') + if sep=='.': + extsep = '/' + else: + extsep = '.' def _exit(n=0): |
From: Finn B. <bc...@us...> - 2002-01-07 11:58:29
|
Update of /cvsroot/jython/jython/Lib In directory usw-pr-cvs1:/tmp/cvs-serv4891 Modified Files: string.py Log Message: Define the new 2.2 names. This closes patch: "[ #500267 ] add missing attributes to string.py". Index: string.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/string.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** string.py 2000/09/30 10:40:20 1.8 --- string.py 2002/01/07 11:58:26 1.9 *************** *** 14,20 **** --- 14,28 ---- uppercase -- a string containing all characters considered uppercase letters letters -- a string containing all characters considered letters + ascii_lowercase -- a string containing all characters considered lowercase + letters that is not locale-dependent and will not change. + ascii_uppercase -- a string containing all characters considered uppercase + letters that is not locale-dependent and will not change. + ascii_letters -- The concatenation of the ascii_lowercase and ascii_uppercase + constants described below. This value is not locale-dependent. digits -- a string containing all characters considered decimal digits hexdigits -- a string containing all characters considered hexadecimal digits octdigits -- a string containing all characters considered octal digits + punctuation -- a string containing all characters considered punctuation + printable -- a string containing all characters considered printable """ *************** *** 28,31 **** --- 36,47 ---- hexdigits = digits + 'abcdef' + 'ABCDEF' octdigits = '01234567' + punctuation = """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~""" + printable = digits + letters + punctuation + whitespace + + # not set to 'lowercase' or 'uppercase' because they can change + ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz' + ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + ascii_letters = ascii_lowercase + ascii_uppercase + # Case conversion helpers |
From: brian z. <bz...@us...> - 2002-01-07 05:00:15
|
Update of /cvsroot/jython/jython/Lib In directory usw-pr-cvs1:/tmp/cvs-serv19120/Lib Modified Files: isql.py Log Message: added update count status Index: isql.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/isql.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** isql.py 2001/11/20 04:55:18 1.1 --- isql.py 2002/01/07 05:00:12 1.2 *************** *** 10,13 **** --- 10,15 ---- __version__ = "$Revision$"[11:-2] + class IsqlExit(Exception): pass + class Prompt: """ *************** *** 63,69 **** """\nPrints table meta-data. If no table name, prints all tables.\n""" if len(arg.strip()): ! apply(self.db.table, (arg,), self.kw) else: ! apply(self.db.table, (None,), self.kw) return None --- 65,71 ---- """\nPrints table meta-data. If no table name, prints all tables.\n""" if len(arg.strip()): ! self.db.table(arg, **self.kw) else: ! self.db.table(None, **self.kw) return None *************** *** 71,77 **** """\nPrints store procedure meta-data.\n""" if len(arg.strip()): ! apply(self.db.proc, (arg,), self.kw) else: ! apply(self.db.proc, (None,), self.kw) return None --- 73,79 ---- """\nPrints store procedure meta-data.\n""" if len(arg.strip()): ! self.db.proc(arg, **self.kw) else: ! self.db.proc(None, **self.kw) return None *************** *** 95,98 **** --- 97,109 ---- def do_set(self, arg): """\nSet a parameter. Some examples:\n set owner = 'informix'\n set types = ['VIEW', 'TABLE']\nThe right hand side is evaluated using `eval()`\n""" + if len(arg.strip()) == 0: + items = self.kw.items() + if len(items): + print + # format the results but don't include how many rows affected + for a in dbexts.console(items, ("key", "value"))[:-1]: + print a + print + return None d = filter(lambda x: len(x) > 0, map(lambda x: x.strip(), arg.split("="))) if len(d) == 1: *************** *** 112,117 **** self.sqlbuffer.append(token[:-1 * len(self.delimiter)]) if self.sqlbuffer: ! self.db.isql(" ".join(self.sqlbuffer)) self.sqlbuffer = [] return None if token: --- 123,135 ---- self.sqlbuffer.append(token[:-1 * len(self.delimiter)]) if self.sqlbuffer: ! self.db.isql(" ".join(self.sqlbuffer), **self.kw) self.sqlbuffer = [] + if self.db.updatecount: + print + if self.db.updatecount == 1: + print "1 row affected" + else: + print "%d rows affected" % (self.db.updatecount) + print return None if token: *************** *** 125,128 **** --- 143,149 ---- return None + def postloop(self): + raise IsqlExit() + if __name__ == '__main__': import getopt *************** *** 143,145 **** intro = "\nisql - interactive sql (%s)\n" % (__version__) ! IsqlCmd(dbname).cmdloop(intro) --- 164,176 ---- intro = "\nisql - interactive sql (%s)\n" % (__version__) ! isql = IsqlCmd(dbname) ! while 1: ! try: ! isql.cmdloop(intro) ! except IsqlExit, e: ! break ! except Exception, e: ! print ! print e ! print ! intro = "" |
From: brian z. <bz...@us...> - 2002-01-07 04:59:54
|
Update of /cvsroot/jython/jython/Lib In directory usw-pr-cvs1:/tmp/cvs-serv18975/Lib Modified Files: dbexts.py Log Message: removed dependence on string mod Index: dbexts.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/dbexts.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dbexts.py 2001/12/29 18:00:15 1.4 --- dbexts.py 2002/01/07 04:59:50 1.5 *************** *** 46,50 **** """ ! import os, string, re __author__ = "brian zimmer (bz...@zi...)" --- 46,50 ---- """ ! import os, re __author__ = "brian zimmer (bz...@zi...)" *************** *** 77,81 **** # Check row entry lengths output = [] ! headers = map(string.upper, list(map(lambda x: x or "", headers))) collen = map(len,headers) output.append(headers) --- 77,81 ---- # 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) *************** *** 101,105 **** for j in range(len(row)): l.append('%-*s' % (collen[j],row[j])) ! output[i] = string.join(l, " | ") # Insert header separator --- 101,105 ---- for j in range(len(row)): l.append('%-*s' % (collen[j],row[j])) ! output[i] = " | ".join(l) # Insert header separator *************** *** 127,131 **** comments = lambda x: re.compile("{.*?}", re.S).sub("", x, 0) ! class ex_proxy: """Wraps mxODBC to provide proxy support for zxJDBC's additional parameters.""" def __init__(self, c): --- 127,131 ---- 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): *************** *** 171,175 **** class dbexts: ! def __init__(self, dbname=None, cfg=None, formatter=console, autocommit=1, jndiname=None, out=None): self.verbose = 1 self.results = None --- 171,175 ---- class dbexts: ! def __init__(self, dbname=None, cfg=None, formatter=console, autocommit=0, jndiname=None, out=None): self.verbose = 1 self.results = None *************** *** 203,207 **** if t.has_key("datahandler"): try: ! datahandlerclass = string.split(t['datahandler'], ".")[-1] self.datahandler = __import__(t['datahandler'], globals(), locals(), datahandlerclass) except: --- 203,207 ---- if t.has_key("datahandler"): try: ! datahandlerclass = t['datahandler'].split(".")[-1] self.datahandler = __import__(t['datahandler'], globals(), locals(), datahandlerclass) except: *************** *** 214,218 **** else: self.db = database.lookup(jndiname) ! self.db.autocommit = 0 elif __OS__ == 'nt': --- 214,218 ---- else: self.db = database.lookup(jndiname) ! self.db.autocommit = self.autocommit elif __OS__ == 'nt': *************** *** 231,234 **** --- 231,235 ---- 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) *************** *** 256,260 **** if self.datahandler: c.datahandler = self.datahandler(c.datahandler) else: ! c = ex_proxy(c) return c --- 257,261 ---- if self.datahandler: c.datahandler = self.datahandler(c.datahandler) else: ! c = mxODBCProxy(c) return c *************** *** 270,276 **** if f: self.results = choose(self.results is None, [], self.results) + f s = cursor.nextset() ! if hasattr(cursor, "lastrowid"): self.lastrowid = cursor.lastrowid ! if hasattr(cursor, "updatecount"): self.updatecount = cursor.updatecount ! if self.autocommit or cursor is None: self.db.commit() if cursor: cursor.close() --- 271,279 ---- if f: self.results = choose(self.results is None, [], self.results) + f 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: self.db.commit() if cursor: cursor.close() *************** *** 313,317 **** results = [] if comments: sql = comments(sql) ! statements = filter(lambda x: len(x) > 0, map(string.strip, string.split(sql, delim))) for a in statements: self.__execute__(a, params, bindings, maxrows=maxrows) --- 316,321 ---- results = [] if comments: sql = comments(sql) ! statements = filter(lambda x: len(x) > 0, ! map(lambda statement: statement.strip(), sql.split(delim))) for a in statements: self.__execute__(a, params, bindings, maxrows=maxrows) *************** *** 431,436 **** self.bindings = {} ! include = map(lambda x: string.lower(x), include) ! exclude = map(lambda x: string.lower(x), exclude) _verbose = self.dst.verbose --- 435,440 ---- self.bindings = {} ! include = map(lambda x: x.lower(), include) ! exclude = map(lambda x: x.lower(), exclude) _verbose = self.dst.verbose *************** *** 464,468 **** def __filter__(self, values, include, exclude): ! cols = map(string.lower, values) if exclude: cols = filter(lambda x, ex=exclude: x not in ex, cols) --- 468,472 ---- 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) *************** *** 491,495 **** def transfer(self, src, where="(1=1)", params=[]): ! sql = "select %s from %s where %s" % (string.join(self.columns, ", "), self.table, where) h, d = src.raw(sql, params) if d: --- 495,499 ---- 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: *************** *** 519,526 **** w = open(self.filename, mode) if self.includeheaders: ! w.write("%s\n" % (string.join(map(lambda x: x[0], headers), self.delimiter))) if results: for a in results: ! w.write("%s\n" % (string.join(map(self.format, a), self.delimiter))) w.flush() w.close() --- 523,530 ---- w = open(self.filename, mode) if self.includeheaders: ! w.write("%s\n" % (self.delimiter.join(map(lambda x: x[0], headers)))) if results: for a in results: ! w.write("%s\n" % (self.delimiter.join(map(self.format, a)))) w.flush() w.close() *************** *** 577,581 **** idxdict = {} # mxODBC returns a row of None's, so filter it out ! idx = map(lambda x: (x[3], string.strip(x[5]), x[6], x[7], x[8]), filter(lambda x: x[5], self.db.results)) def cckmp(x, y): c = cmp(x[1], y[1]) --- 581,585 ---- idxdict = {} # mxODBC returns a row of None's, so filter it out ! idx = map(lambda x: (x[3], x[5].strip(), x[6], x[7], x[8]), filter(lambda x: x[5], self.db.results)) def cckmp(x, y): c = cmp(x[1], y[1]) *************** *** 612,618 **** for a in self.indices: unique = choose(a[0][0], "non-unique", "unique") ! cname = string.join(map(lambda x: x[4], a), ", ") d.append(" %s index {%s} on (%s)" % (unique, a[0][1], cname)) ! return string.join(d, "\n") class IniParser: --- 616,622 ---- for a in self.indices: unique = choose(a[0][0], "non-unique", "unique") ! cname = ", ".join(map(lambda x: x[4], a)) d.append(" %s index {%s} on (%s)" % (unique, a[0][1], cname)) ! return "\n".join(d) class IniParser: *************** *** 629,633 **** data = fp.readlines() fp.close() ! lines = filter(lambda x: len(x) > 0 and x[0] not in ['#', ';'], map(string.strip, data)) current = None for i in range(len(lines)): --- 633,637 ---- data = fp.readlines() fp.close() ! lines = filter(lambda x: len(x) > 0 and x[0] not in ['#', ';'], map(lambda x: x.strip(), data)) current = None for i in range(len(lines)): *************** *** 658,662 **** d.append(chr(int(100 * random.random()) % 26 + ord('A'))) i += 1 ! return string.join(d, "") class ResultSetRow: --- 662,666 ---- d.append(chr(int(100 * random.random()) % 26 + ord('A'))) i += 1 ! return "".join(d) class ResultSetRow: *************** *** 682,686 **** self.results = results def index(self, i): ! return self.headers.index(string.upper(i)) def __getitem__(self, i): return ResultSetRow(self, self.results[i]) --- 686,690 ---- self.results = results def index(self, i): ! return self.headers.index(i.upper()) def __getitem__(self, i): return ResultSetRow(self, self.results[i]) |
From: brian z. <bz...@us...> - 2002-01-07 02:59:03
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql In directory usw-pr-cvs1:/tmp/cvs-serv31681/com/ziclix/python/sql Modified Files: PyCursor.java Log Message: updatecount is None if stmt.getUpdateCount() < 0 Index: PyCursor.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/PyCursor.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyCursor.java 2001/12/29 18:00:14 1.12 --- PyCursor.java 2002/01/07 02:59:00 1.13 *************** *** 488,492 **** this.lastrowid = this.datahandler.getRowId(this.sqlStatement); ! this.updatecount = Py.newInteger(this.sqlStatement.getUpdateCount()); addWarning(this.sqlStatement.getWarnings()); --- 488,495 ---- this.lastrowid = this.datahandler.getRowId(this.sqlStatement); ! ! int uc = this.sqlStatement.getUpdateCount(); ! ! this.updatecount = (uc < 0) ? Py.None : Py.newInteger(uc); addWarning(this.sqlStatement.getWarnings()); |
From: brian z. <bz...@us...> - 2002-01-07 02:59:03
|
Update of /cvsroot/jython/jython/Lib/test/zxjdbc In directory usw-pr-cvs1:/tmp/cvs-serv31681/Lib/test/zxjdbc Modified Files: zxtest.py Log Message: updatecount is None if stmt.getUpdateCount() < 0 Index: zxtest.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/test/zxjdbc/zxtest.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** zxtest.py 2002/01/07 02:12:37 1.6 --- zxtest.py 2002/01/07 02:59:00 1.7 *************** *** 31,35 **** c = self.db.cursor(dynamic) if hasattr(self, "datahandler"): ! c.datahandler.__class__ = self.datahandler(c.datahandler.__class__) return c --- 31,35 ---- c = self.db.cursor(dynamic) if hasattr(self, "datahandler"): ! c.datahandler = self.datahandler(c.datahandler) return c *************** *** 357,361 **** c.close() ! def testUpdateCount(self, insert_only=0): c = self.cursor() try: --- 357,361 ---- c.close() ! def testUpdateCount(self): c = self.cursor() try: *************** *** 363,367 **** assert c.updatecount == 1, "expected [1], got [%d]" % (c.updatecount) c.execute("select * from zxtesting") ! assert c.updatecount == -1, "expected updatecount to be -1 after query" # there's a *feature* in the mysql engine where it returns 0 for delete if there is no # where clause, regardless of the actual value. using a where clause forces it to calculate --- 363,367 ---- assert c.updatecount == 1, "expected [1], got [%d]" % (c.updatecount) c.execute("select * from zxtesting") ! self.assertEquals(None, c.updatecount) # there's a *feature* in the mysql engine where it returns 0 for delete if there is no # where clause, regardless of the actual value. using a where clause forces it to calculate *************** *** 369,372 **** --- 369,374 ---- c.execute("delete from zxtesting where 1>0") assert c.updatecount == 8, "expected [8], got [%d]" % (c.updatecount) + c.execute("update zxtesting set name = 'nothing'") + self.assertEquals(0, c.updatecount) finally: c.close() |
From: brian z. <bz...@us...> - 2002-01-07 02:16:28
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql In directory usw-pr-cvs1:/tmp/cvs-serv26197/com/ziclix/python/sql Modified Files: JDBC20DataHandler.java Log Message: delegate to DataHandler if getBigDecimal() fails Index: JDBC20DataHandler.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/JDBC20DataHandler.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JDBC20DataHandler.java 2001/11/20 04:55:18 1.1 --- JDBC20DataHandler.java 2002/01/07 02:16:25 1.2 *************** *** 114,120 **** // in JDBC 2.0, use of a scale is deprecated ! BigDecimal bd = set.getBigDecimal(col); ! obj = (bd == null) ? Py.None : Py.newFloat(bd.doubleValue()); break; --- 114,124 ---- // in JDBC 2.0, use of a scale is deprecated ! try { ! BigDecimal bd = set.getBigDecimal(col); ! obj = (bd == null) ? Py.None : Py.newFloat(bd.doubleValue()); ! } catch (SQLException e) { ! obj = super.getPyObject(set, col, type); ! } break; |
From: brian z. <bz...@us...> - 2002-01-07 02:12:39
|
Update of /cvsroot/jython/jython/Lib/test/zxjdbc In directory usw-pr-cvs1:/tmp/cvs-serv25617/Lib/test/zxjdbc Modified Files: zxtest.py Log Message: use the cursor's datahandler Index: zxtest.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/test/zxjdbc/zxtest.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** zxtest.py 2001/12/29 18:00:14 1.5 --- zxtest.py 2002/01/07 02:12:37 1.6 *************** *** 31,35 **** c = self.db.cursor(dynamic) if hasattr(self, "datahandler"): ! c.datahandler = self.datahandler(c.datahandler) return c --- 31,35 ---- c = self.db.cursor(dynamic) if hasattr(self, "datahandler"): ! c.datahandler.__class__ = self.datahandler(c.datahandler.__class__) return c *************** *** 38,43 **** def setUp(self): zxCoreTestCase.setUp(self) - self.db = self.connect() - self.db.autocommit = 0 c = self.cursor() --- 38,41 ---- *************** *** 728,732 **** c.close() ! dbSource = DBSource(src, self.datahandler, "zxtesting", None, None, None) cnt = Pipe().pipe(dbSource, csvSink) - 1 # ignore the header row --- 726,730 ---- c.close() ! dbSource = DBSource(src, c.datahandler.__class__, "zxtesting", None, None, None) cnt = Pipe().pipe(dbSource, csvSink) - 1 # ignore the header row *************** *** 750,754 **** xmlSink = XMLSink(writer) ! dbSource = DBSource(src, self.datahandler, "zxtesting", None, None, None) cnt = Pipe().pipe(dbSource, xmlSink) - 1 # ignore the header row --- 748,752 ---- xmlSink = XMLSink(writer) ! dbSource = DBSource(src, c.datahandler.__class__, "zxtesting", None, None, None) cnt = Pipe().pipe(dbSource, xmlSink) - 1 # ignore the header row *************** *** 776,781 **** c.close() ! dbSource = DBSource(src, self.datahandler, "zxtesting", None, None, None) ! dbSink = DBSink(dst, self.datahandler, "zxtestingbcp", None, None, 1) cnt = Pipe().pipe(dbSource, dbSink) - 1 # ignore the header row --- 774,779 ---- c.close() ! dbSource = DBSource(src, c.datahandler.__class__, "zxtesting", None, None, None) ! dbSink = DBSink(dst, c.datahandler.__class__, "zxtestingbcp", None, None, 1) cnt = Pipe().pipe(dbSource, dbSink) - 1 # ignore the header row *************** *** 794,799 **** # all the rows queried (based on the fact no columns exist) but rows were fetched # also make sure (eg, Oracle) that the column name case is ignored ! dbSource = DBSource(src, self.datahandler, "zxtesting", None, ["id"], None) ! dbSink = DBSink(dst, self.datahandler, "zxtestingbcp", ["id"], None, 1) self.assertRaises(zxJDBC.Error, Pipe().pipe, dbSource, dbSink) --- 792,797 ---- # all the rows queried (based on the fact no columns exist) but rows were fetched # also make sure (eg, Oracle) that the column name case is ignored ! dbSource = DBSource(src, c.datahandler.__class__, "zxtesting", None, ["id"], None) ! dbSink = DBSink(dst, c.datahandler.__class__, "zxtestingbcp", ["id"], None, 1) self.assertRaises(zxJDBC.Error, Pipe().pipe, dbSource, dbSink) *************** *** 801,806 **** params = [(4,)] ! dbSource = DBSource(src, self.datahandler, "zxtesting", "id > ?", None, params) ! dbSink = DBSink(dst, self.datahandler, "zxtestingbcp", None, None, 1) cnt = Pipe().pipe(dbSource, dbSink) - 1 # ignore the header row --- 799,804 ---- params = [(4,)] ! dbSource = DBSource(src, c.datahandler.__class__, "zxtesting", "id > ?", None, params) ! dbSink = DBSink(dst, c.datahandler.__class__, "zxtestingbcp", None, None, 1) cnt = Pipe().pipe(dbSource, dbSink) - 1 # ignore the header row |
From: brian z. <bz...@us...> - 2002-01-07 02:11:22
|
Update of /cvsroot/jython/jython/com/ziclix/python/sql In directory usw-pr-cvs1:/tmp/cvs-serv25479/com/ziclix/python/sql Modified Files: Procedure.java Log Message: close the statement IF NOT null Index: Procedure.java =================================================================== RCS file: /cvsroot/jython/jython/com/ziclix/python/sql/Procedure.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Procedure.java 2001/12/29 07:16:20 1.4 --- Procedure.java 2002/01/07 02:11:19 1.5 *************** *** 126,130 **** registerOutParameters(statement); } catch (SQLException e) { ! if (statement == null) { try { statement.close(); --- 126,130 ---- registerOutParameters(statement); } catch (SQLException e) { ! if (statement != null) { try { statement.close(); |
From: Finn B. <bc...@us...> - 2002-01-06 21:19:17
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv15999/core Modified Files: Py.java PyArray.java PyClass.java PyDictionary.java PyInstance.java PyObject.java PySequence.java PyString.java PyStringMap.java __builtin__.java codecs.java exceptions.java imp.java Added Files: PyCallIter.java PySequenceIter.java Log Message: Support for the __iter__ protocol. With this change, all loops over sequences will use the __iter__() method to get a iterator object and all builtin sequence objects will ofcourse define the __iter__() method. --- NEW FILE: PyCallIter.java --- package org.python.core; public class PyCallIter extends PyObject { private PyObject callable; private PyObject sentinel; private int idx; public PyCallIter(PyObject callable, PyObject sentinel) { this.callable = callable; this.sentinel = sentinel; } public PyObject __iter__() { return this; } public PyObject __iternext__() { PyObject val = null; try { val = callable.__call__(); } catch (PyException exc) { if (Py.matchException(exc, Py.StopIteration)) return null; throw exc; } if (val._eq(sentinel).__nonzero__()) return null; return val; } public PyObject next() { return __iternext__(); } // __class__ boilerplate -- see PyObject for details public static PyClass __class__; protected PyClass getPyClass() { return __class__; } } --- NEW FILE: PySequenceIter.java --- package org.python.core; public class PySequenceIter extends PyObject { private PyObject seq; private int idx; public PySequenceIter(PyObject seq) { this.seq = seq; this.idx = 0; } public PyObject __iter__() { return this; } public PyObject __iternext__() { return seq.__finditem__(idx++); } public PyObject next() { return __iternext__(); } // __class__ boilerplate -- see PyObject for details public static PyClass __class__; protected PyClass getPyClass() { return __class__; } } Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.63 retrieving revision 2.64 diff -C2 -d -r2.63 -r2.64 *** Py.java 2002/01/06 16:12:52 2.63 --- Py.java 2002/01/06 21:19:13 2.64 *************** *** 184,190 **** } ! public static PyObject StopIterator; ! public static PyException StopIterator(String message) { ! return new PyException(Py.StopIterator, message); } --- 184,190 ---- } ! public static PyObject StopIteration; ! public static PyException StopIteration(String message) { ! return new PyException(Py.StopIteration, message); } *************** *** 537,541 **** Exception = initExc("Exception", exc, dict); SystemExit = initExc("SystemExit", exc, dict); ! StopIterator = initExc("StopIterator", exc, dict); StandardError = initExc("StandardError", exc, dict); KeyboardInterrupt = initExc("KeyboardInterrupt", exc, dict); --- 537,541 ---- Exception = initExc("Exception", exc, dict); SystemExit = initExc("SystemExit", exc, dict); ! StopIteration = initExc("StopIteration", exc, dict); StandardError = initExc("StandardError", exc, dict); KeyboardInterrupt = initExc("KeyboardInterrupt", exc, dict); *************** *** 1628,1631 **** --- 1628,1641 ---- } return ret; + } + + public static PyObject iter(PyObject seq, String message) { + try { + return seq.__iter__(); + } catch (PyException exc) { + if (Py.matchException(exc, Py.TypeError)) + throw Py.TypeError(message); + throw exc; + } } Index: PyArray.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyArray.java,v retrieving revision 2.7 retrieving revision 2.8 diff -C2 -d -r2.7 -r2.8 *** PyArray.java 2001/10/28 17:13:43 2.7 --- PyArray.java 2002/01/06 21:19:13 2.8 *************** *** 33,39 **** public static PyArray array(PyObject seq, Class ctype) { PyArray array = new PyArray(ctype, seq.__len__()); ! PyObject o; ! for(int i=0; (o=seq.__finditem__(i)) != null; i++) { ! array.set(i, o); } return array; --- 33,40 ---- public static PyArray array(PyObject seq, Class ctype) { PyArray array = new PyArray(ctype, seq.__len__()); ! PyObject iter = seq.__iter__(); ! PyObject item = null; ! for (int i = 0; (item = iter.__iternext__()) != null; i++) { ! array.set(i, item); } return array; Index: PyClass.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyClass.java,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -d -r2.28 -r2.29 *** PyClass.java 2001/11/27 19:07:21 2.28 --- PyClass.java 2002/01/06 21:19:13 2.29 *************** *** 133,143 **** PyObject snames = superDict.__finditem__("__supernames__"); if (snames != null) { ! PyObject sname; ! int i; ! for (i = 0; (sname = snames.__finditem__(i)) != null; i++) { ! if (__dict__.__finditem__(sname) == null) { ! PyObject superFunc = superDict.__finditem__(sname); if (superFunc != null) ! __dict__.__setitem__(sname, superFunc); } } --- 133,142 ---- PyObject snames = superDict.__finditem__("__supernames__"); if (snames != null) { ! PyObject iter = snames.__iter__(); ! for (PyObject item; (item = iter.__iternext__()) != null; ) { ! if (__dict__.__finditem__(item) == null) { ! PyObject superFunc = superDict.__finditem__(item); if (superFunc != null) ! __dict__.__setitem__(item, superFunc); } } Index: PyDictionary.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyDictionary.java,v retrieving revision 2.17 retrieving revision 2.18 diff -C2 -d -r2.17 -r2.18 *** PyDictionary.java 2001/10/28 17:13:43 2.17 --- PyDictionary.java 2002/01/06 21:19:13 2.18 *************** *** 3,6 **** --- 3,7 ---- import java.util.Hashtable; + import java.util.Enumeration; *************** *** 192,195 **** --- 193,200 ---- } + public PyObject __iter__() { + return new PyDictionaryIter(this, table.keys()); + } + public String toString() { ThreadState ts = Py.getThreadState(); *************** *** 317,322 **** public void update(PyStringMap d) { PyObject keys = d.keys(); ! PyObject key; ! for (int i = 0; (key = keys.__finditem__(i)) != null; i++) __setitem__(key, d.__getitem__(key)); } --- 322,327 ---- public void update(PyStringMap d) { PyObject keys = d.keys(); ! PyObject iter = keys.__iter__(); ! for (PyObject key; (key = iter.__iternext__()) != null; ) __setitem__(key, d.__getitem__(key)); } *************** *** 408,409 **** --- 413,429 ---- } } + + class PyDictionaryIter extends PyObject { + private Enumeration enumeration; + + public PyDictionaryIter(PyObject dict, Enumeration e) { + enumeration = e; + } + + public PyObject __iternext__() { + if (!enumeration.hasMoreElements()) + return null; + return (PyObject) enumeration.nextElement(); + } + } + Index: PyInstance.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyInstance.java,v retrieving revision 2.28 retrieving revision 2.29 diff -C2 -d -r2.28 -r2.29 *** PyInstance.java 2001/12/16 13:04:02 2.28 --- PyInstance.java 2002/01/06 21:19:13 2.29 *************** *** 601,604 **** --- 601,628 ---- } + public PyObject __iter__() { + PyObject func = __findattr__("__iter__"); + if (func != null) + return func.__call__(); + func = __findattr__("__getitem__"); + if (func == null) + return super.__iter__(); + return new PySequenceIter(this); + } + + public PyObject __iternext__() { + PyObject func = __findattr__("next"); + if (func != null) { + try { + return func.__call__(); + } catch (PyException exc) { + if (Py.matchException(exc, Py.StopIteration)) + return null; + throw exc; + } + } + throw Py.TypeError("instance has no next() method"); + } + public boolean __contains__(PyObject o) { PyObject func = __findattr__("__contains__"); Index: PyObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyObject.java,v retrieving revision 2.26 retrieving revision 2.27 diff -C2 -d -r2.26 -r2.27 *** PyObject.java 2001/10/28 17:13:43 2.26 --- PyObject.java 2002/01/06 21:19:13 2.27 *************** *** 602,606 **** --- 602,648 ---- } + /*The basic functions to implement an iterator */ + + + /** + * Return an iterator that is used to iterate the element of this + * sequence. + * From version 2.2, this method is the primary protocol for looping + * over sequences. + * <p> + * If a PyObject subclass should support iteration based in the + * __finditem__() method, it must supply an implementation of __iter__() + * like this: + * <pre> + * public PyObject __iter__() { + * return new PySequenceIter(this); + * } + * </pre> + * + * When iterating over a python sequence from java code, it should be + * done with code like this: + * <pre> + * PyObject iter = seq.__iter__(); + * for (PyObject item; (item = iter.__next__()) != null; { + * // Do somting with item + * } + * </pre> + * + * @since 2.2 + */ + public PyObject __iter__() { + throw Py.TypeError("iteration over non-sequence"); + } + /** + * Return the next element of the sequence that this is an iterator + * for. Returns null when the end of the sequence is reached. + * + * @since 2.2 + */ + public PyObject __iternext__() { + return null; + } + /*The basic functions to implement a namespace*/ *************** *** 1262,1270 **** **/ public boolean __contains__(PyObject o) { ! PyObject tmp; ! int i = 0; ! ! while ((tmp = __finditem__(i++)) != null) { ! if (o._eq(tmp).__nonzero__()) return true; } --- 1304,1310 ---- **/ public boolean __contains__(PyObject o) { ! PyObject iter = __iter__(); ! for (PyObject item = null; (item = iter.__iternext__()) != null; ) { ! if (o._eq(item).__nonzero__()) return true; } Index: PySequence.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PySequence.java,v retrieving revision 2.18 retrieving revision 2.19 diff -C2 -d -r2.18 -r2.19 *** PySequence.java 2001/10/28 17:13:43 2.18 --- PySequence.java 2002/01/06 21:19:13 2.19 *************** *** 186,189 **** --- 186,193 ---- } + public PyObject __iter__() { + return new PySequenceIter(this); + } + public synchronized PyObject __eq__(PyObject o) { if (o.__class__ != __class__) *************** *** 273,281 **** throw Py.TypeError(msg); - int n = seq.__len__(); - PyList list = new PyList(); ! PyObject item; ! for (int i = 0; (item = list.__finditem__(i)) != null; i++) { list.append(item); } --- 277,283 ---- throw Py.TypeError(msg); PyList list = new PyList(); ! PyObject iter = Py.iter(seq, msg); ! for (PyObject item = null; (item = iter.__iternext__()) != null; ) { list.append(item); } Index: PyString.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyString.java,v retrieving revision 2.53 retrieving revision 2.54 diff -C2 -d -r2.53 -r2.54 *** PyString.java 2001/12/07 14:15:18 2.53 --- PyString.java 2002/01/06 21:19:13 2.54 *************** *** 1461,1466 **** StringBuffer buf = new StringBuffer(); ! PyObject obj; ! for (int i=0; (obj = seq.__finditem__(i)) != null; i++) { if (!(obj instanceof PyString)) throw Py.TypeError( --- 1461,1467 ---- StringBuffer buf = new StringBuffer(); ! PyObject iter = seq.__iter__(); ! PyObject obj = null; ! for (int i = 0; (obj = iter.__iternext__()) != null; i++) { if (!(obj instanceof PyString)) throw Py.TypeError( Index: PyStringMap.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyStringMap.java,v retrieving revision 2.12 retrieving revision 2.13 diff -C2 -d -r2.12 -r2.13 *** PyStringMap.java 2001/10/28 17:13:43 2.12 --- PyStringMap.java 2002/01/06 21:19:13 2.13 *************** *** 128,131 **** --- 128,135 ---- } + public PyObject __iter__() { + return new PyStringMapIter(keys, values); + } + private final void insertkey(String key, PyObject value) { String[] table = keys; *************** *** 542,543 **** --- 546,578 ---- } } + + class PyStringMapIter extends PyObject { + String[] keyTable; + PyObject[] valTable; + private int idx; + + public PyStringMapIter(String[] keys, PyObject[] values) { + this.keyTable = keys; + this.valTable = values; + this.idx = 0; + } + + public PyObject __iternext__() { + int n = keyTable.length; + + for (; idx < n; idx++) { + String key = keyTable[idx]; + if (key == null || key == "<deleted key>" || valTable[idx] == null) + continue; + idx++; + return Py.newString(key); + } + return null; + } + + // __class__ boilerplate -- see PyObject for details + public static PyClass __class__; + protected PyClass getPyClass() { return __class__; } + } + + Index: __builtin__.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/__builtin__.java,v retrieving revision 2.41 retrieving revision 2.42 diff -C2 -d -r2.41 -r2.42 *** __builtin__.java 2001/12/20 22:45:11 2.41 --- __builtin__.java 2002/01/06 21:19:13 2.42 *************** *** 336,351 **** public static PyObject filter(PyObject f, PyObject l) { - int i=0; - PyObject element; PyList list = new PyList(); ! while ((element = l.__finditem__(i++)) != null) { if (f == Py.None) { ! if (!element.__nonzero__()) continue; } else { ! if (!f.__call__(element).__nonzero__()) continue; } ! list.append(element); } return list; --- 336,350 ---- public static PyObject filter(PyObject f, PyObject l) { PyList list = new PyList(); ! PyObject iter = l.__iter__(); ! for (PyObject item = null; (item = iter.__iternext__()) != null; ) { if (f == Py.None) { ! if (!item.__nonzero__()) continue; } else { ! if (!f.__call__(item).__nonzero__()) continue; } ! list.append(item); } return list; *************** *** 502,506 **** public static PyObject map(PyObject[] argstar) { - int i=0; int n = argstar.length-1; if (n < 1) --- 501,504 ---- *************** *** 510,517 **** PyList list = new PyList(); PyObject[] args = new PyObject[n]; while (true) { boolean any_items = false; ! for(int j=0; j<n; j++) { ! if ((element = argstar[j+1].__finditem__(i)) != null) { args[j] = element; any_items = true; --- 508,522 ---- PyList list = new PyList(); PyObject[] args = new PyObject[n]; + PyObject[] iters = new PyObject[n]; + + for (int j = 0; j < n; j++) { + iters[j] = Py.iter(argstar[j+1], "argument " + j + "to map() " + + "must support iteration"); + } + while (true) { boolean any_items = false; ! for(int j = 0; j < n; j++) { ! if ((element = iters[j].__iternext__()) != null) { args[j] = element; any_items = true; *************** *** 531,539 **** list.append(f.__call__(args)); } - i = i+1; } return list; } // I've never been happy with max and min builtin's... --- 536,544 ---- list.append(f.__call__(args)); } } return list; } + // I've never been happy with max and min builtin's... *************** *** 545,557 **** private static PyObject max(PyObject o) { ! PyObject max = o.__finditem__(0); if (max == null) throw Py.ValueError("max of empty sequence"); - PyObject element; - int i=1; - while ((element = o.__finditem__(i++)) != null) { - if (element._gt(max).__nonzero__()) - max = element; - } return max; } --- 550,561 ---- private static PyObject max(PyObject o) { ! PyObject max = null; ! PyObject iter = o.__iter__(); ! for (PyObject item; (item = iter.__iternext__()) != null; ) { ! if (max == null || item._gt(max).__nonzero__()) ! max = item; ! } if (max == null) throw Py.ValueError("max of empty sequence"); return max; } *************** *** 564,576 **** private static PyObject min(PyObject o) { ! PyObject min = o.__finditem__(0); if (min == null) throw Py.ValueError("min of empty sequence"); - PyObject element; - int i=1; - while ((element = o.__finditem__(i++)) != null) { - if (element._lt(min).__nonzero__()) - min = element; - } return min; } --- 568,579 ---- private static PyObject min(PyObject o) { ! PyObject min = null; ! PyObject iter = o.__iter__(); ! for (PyObject item; (item = iter.__iternext__()) != null; ) { ! if (min == null || item._lt(min).__nonzero__()) ! min = item; ! } if (min == null) throw Py.ValueError("min of empty sequence"); return min; } *************** *** 763,778 **** public static PyObject reduce(PyObject f, PyObject l, PyObject z) { ! int i=0; ! PyObject element, result; ! result = z; if (result == null) { ! result = l.__finditem__(i++); ! if (result == null) { ! throw Py.TypeError( "reduce of empty sequence with no initial value"); - } - } - while ((element = l.__finditem__(i++)) != null) { - result = f.__call__(result, element); } return result; --- 766,781 ---- public static PyObject reduce(PyObject f, PyObject l, PyObject z) { ! PyObject result = z; ! PyObject iter = Py.iter(l, "reduce() arg 2 must support iteration"); ! ! for (PyObject item; (item = iter.__iternext__()) != null; ) { ! if (result == null) ! result = item; ! else ! result = f.__call__(result, item); ! } if (result == null) { ! throw Py.TypeError( "reduce of empty sequence with no initial value"); } return result; *************** *** 828,831 **** --- 831,841 ---- } + public static PyObject iter(PyObject obj) { + return obj.__iter__(); + } + + public static PyObject iter(PyObject callable, PyObject sentinel) { + return new PyCallIter(callable, sentinel); + } public static PyString str(PyObject o) { *************** *** 987,991 **** for(int i=0; i<n; i++) { ! objs[i] = o.__finditem__(i); } return objs; --- 997,1001 ---- for(int i=0; i<n; i++) { ! objs[i] = o.__finditem__(i); // XXX: convert to __iter__! } return objs; Index: codecs.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/codecs.java,v retrieving revision 2.11 retrieving revision 2.12 diff -C2 -d -r2.11 -r2.12 *** codecs.java 2001/08/06 20:04:12 2.11 --- codecs.java 2002/01/06 21:19:13 2.12 *************** *** 50,56 **** "can't find encoding"); ! int i = 0; PyObject func = null; ! for (; (func = searchPath.__finditem__(i)) != null; i++) { result = func.__call__(v); if (result == Py.None) --- 50,56 ---- "can't find encoding"); ! PyObject iter = searchPath.__iter__(); PyObject func = null; ! while ((func = iter.__iternext__()) != null) { result = func.__call__(v); if (result == Py.None) *************** *** 61,65 **** break; } ! if (i == searchPath.__len__()) throw new PyException(Py.LookupError, "unknown encoding " + encoding); --- 61,65 ---- break; } ! if (func == null) throw new PyException(Py.LookupError, "unknown encoding " + encoding); Index: exceptions.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/exceptions.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** exceptions.java 2002/01/06 16:11:06 1.11 --- exceptions.java 2002/01/06 21:19:13 1.12 *************** *** 210,214 **** "Request to exit from the interpreter."); ! buildClass(dict, "StopIterator", "Exception", "empty__init__", "Signal the end from iterator.next()."); --- 210,214 ---- "Request to exit from the interpreter."); ! buildClass(dict, "StopIteration", "Exception", "empty__init__", "Signal the end from iterator.next()."); Index: imp.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/imp.java,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -d -r2.59 -r2.60 *** imp.java 2001/12/21 00:20:17 2.59 --- imp.java 2002/01/06 21:19:13 2.60 *************** *** 13,17 **** public class imp { ! public static final int APIVersion = 9; private imp() { ; } --- 13,17 ---- public class imp { ! public static final int APIVersion = 10; private imp() { ; } *************** *** 744,750 **** PyObject locals, boolean filter) { ! int i=0; ! PyObject name; ! while ((name=names.__finditem__(i++)) != null) { String sname = ((PyString)name).internedString(); if (filter && sname.startsWith("_")) { --- 744,749 ---- PyObject locals, boolean filter) { ! PyObject iter = names.__iter__(); ! for (PyObject name; (name = iter.__iternext__()) != null; ) { String sname = ((PyString)name).internedString(); if (filter && sname.startsWith("_")) { |
From: Finn B. <bc...@us...> - 2002-01-06 21:19:17
|
Update of /cvsroot/jython/jython/org/python/modules/sre In directory usw-pr-cvs1:/tmp/cvs-serv15999/modules/sre Modified Files: PatternObject.java Log Message: Support for the __iter__ protocol. With this change, all loops over sequences will use the __iter__() method to get a iterator object and all builtin sequence objects will ofcourse define the __iter__() method. Index: PatternObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/PatternObject.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PatternObject.java 2002/01/06 15:53:25 1.8 --- PatternObject.java 2002/01/06 21:19:14 1.9 *************** *** 293,297 **** - /* Enable "finditer" when iter support is added. public PyObject finditer(String string) { return finditer(string, 0, Integer.MAX_VALUE); --- 293,296 ---- *************** *** 305,311 **** ScannerObject scanner = scanner(string, start, end); PyObject search = scanner.__findattr__("search"); ! return new PyCallIterator(search, Py.None); } - */ public ScannerObject scanner(String string) { --- 304,309 ---- ScannerObject scanner = scanner(string, start, end); PyObject search = scanner.__findattr__("search"); ! return new PyCallIter(search, Py.None); } public ScannerObject scanner(String string) { |
From: Finn B. <bc...@us...> - 2002-01-06 21:19:17
|
Update of /cvsroot/jython/jython/org/python/parser In directory usw-pr-cvs1:/tmp/cvs-serv15999/parser Modified Files: JJTPythonGrammarState.java PythonGrammarTreeConstants.java Log Message: Support for the __iter__ protocol. With this change, all loops over sequences will use the __iter__() method to get a iterator object and all builtin sequence objects will ofcourse define the __iter__() method. Index: JJTPythonGrammarState.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/JJTPythonGrammarState.java,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -d -r2.1 -r2.2 *** JJTPythonGrammarState.java 1999/03/03 21:42:24 2.1 --- JJTPythonGrammarState.java 2002/01/06 21:19:14 2.2 *************** *** 1,3 **** ! /* Generated By:JJTree: Do not edit this line. JJTPythonGrammarState.java */ package org.python.parser; --- 1,3 ---- ! /* Generated By:JJTree: Do not edit this line. D:/jython/CVS/org/python/parser\JJTPythonGrammarState.java */ package org.python.parser; Index: PythonGrammarTreeConstants.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/parser/PythonGrammarTreeConstants.java,v retrieving revision 2.6 retrieving revision 2.7 diff -C2 -d -r2.6 -r2.7 *** PythonGrammarTreeConstants.java 2000/10/18 13:03:10 2.6 --- PythonGrammarTreeConstants.java 2002/01/06 21:19:14 2.7 *************** *** 1,3 **** ! /* Generated By:JJTree: Do not edit this line. PythonGrammarTreeConstants.java */ package org.python.parser; --- 1,3 ---- ! /* Generated By:JJTree: Do not edit this line. D:/jython/CVS/org/python/parser\PythonGrammarTreeConstants.java */ package org.python.parser; |
From: Finn B. <bc...@us...> - 2002-01-06 21:19:17
|
Update of /cvsroot/jython/jython/org/python/modules In directory usw-pr-cvs1:/tmp/cvs-serv15999/modules Modified Files: cStringIO.java xreadlines.java Log Message: Support for the __iter__ protocol. With this change, all loops over sequences will use the __iter__() method to get a iterator object and all builtin sequence objects will ofcourse define the __iter__() method. Index: cStringIO.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/cStringIO.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** cStringIO.java 2001/11/27 13:51:37 1.12 --- cStringIO.java 2002/01/06 21:19:13 1.13 *************** *** 76,79 **** --- 76,83 ---- } + public PyObject __iter__() { + return new PyCallIter(__getattr__("readline"), Py.newString("")); + } + /** * Free the memory buffer. Index: xreadlines.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/xreadlines.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** xreadlines.java 2001/11/05 13:51:29 1.1 --- xreadlines.java 2002/01/06 21:19:13 1.2 *************** *** 29,32 **** --- 29,36 ---- } + public PyObject __iter__() { + return new PySequenceIter(this); + } + public PyObject __finditem__(PyObject idx) { return __finditem__(idx.__int__().getValue()); |
From: Finn B. <bc...@us...> - 2002-01-06 21:19:15
|
Update of /cvsroot/jython/jython/org/python/compiler In directory usw-pr-cvs1:/tmp/cvs-serv15999/compiler Modified Files: CodeCompiler.java Log Message: Support for the __iter__ protocol. With this change, all loops over sequences will use the __iter__() method to get a iterator object and all builtin sequence objects will ofcourse define the __iter__() method. Index: CodeCompiler.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/CodeCompiler.java,v retrieving revision 2.23 retrieving revision 2.24 diff -C2 -d -r2.23 -r2.24 *** CodeCompiler.java 2001/11/27 19:07:21 2.23 --- CodeCompiler.java 2002/01/06 21:19:13 2.24 *************** *** 934,938 **** } ! public int safe_getitem=0; public Object for_stmt(SimpleNode node) throws Exception { --- 934,939 ---- } ! public int iter=0; ! public int iternext=0; public Object for_stmt(SimpleNode node) throws Exception { *************** *** 944,948 **** int list_tmp = code.getLocal(); ! int index_tmp = code.getLocal(); int expr_tmp = code.getLocal(); --- 945,949 ---- int list_tmp = code.getLocal(); ! int iter_tmp = code.getLocal(); int expr_tmp = code.getLocal(); *************** *** 953,959 **** code.astore(list_tmp); ! //set up the loop counter ! code.iconst(0); ! code.istore(index_tmp); //do check at end of loop. Saves one opcode ;-) --- 954,967 ---- code.astore(list_tmp); ! //set up the loop iterator ! ! code.aload(list_tmp); ! if (mrefs.iter == 0) { ! mrefs.iter = code.pool.Methodref( ! "org/python/core/PyObject", ! "__iter__", "()" + $pyObj); ! } ! code.invokevirtual(mrefs.iter); ! code.astore(iter_tmp); //do check at end of loop. Saves one opcode ;-) *************** *** 961,965 **** start_loop.setPosition(); ! //set index variable to current entry in list set(node.getChild(0), expr_tmp); --- 969,973 ---- start_loop.setPosition(); ! //set iter variable to current entry in list set(node.getChild(0), expr_tmp); *************** *** 968,985 **** continue_loop.setPosition(); - //increment counter - code.iinc(index_tmp, 1); next_loop.setPosition(); setline(node); //get the next element from the list ! code.aload(list_tmp); ! code.iload(index_tmp); ! if (mrefs.safe_getitem == 0) { ! mrefs.safe_getitem = code.pool.Methodref( "org/python/core/PyObject", ! "__finditem__", "(I)" + $pyObj); } ! code.invokevirtual(mrefs.safe_getitem); code.astore(expr_tmp); code.aload(expr_tmp); --- 976,990 ---- continue_loop.setPosition(); next_loop.setPosition(); setline(node); //get the next element from the list ! code.aload(iter_tmp); ! if (mrefs.iternext == 0) { ! mrefs.iternext = code.pool.Methodref( "org/python/core/PyObject", ! "__iternext__", "()" + $pyObj); } ! code.invokevirtual(mrefs.iternext); code.astore(expr_tmp); code.aload(expr_tmp); *************** *** 997,1001 **** code.freeLocal(list_tmp); ! code.freeLocal(index_tmp); code.freeLocal(expr_tmp); --- 1002,1006 ---- code.freeLocal(list_tmp); ! code.freeLocal(iter_tmp); code.freeLocal(expr_tmp); |
From: Finn B. <bc...@us...> - 2002-01-06 16:12:55
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv24718 Modified Files: Py.java Log Message: Added 2.2 exceptions. Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.62 retrieving revision 2.63 diff -C2 -d -r2.62 -r2.63 *** Py.java 2001/12/18 12:50:27 2.62 --- Py.java 2002/01/06 16:12:52 2.63 *************** *** 124,127 **** --- 124,132 ---- } + public static PyObject ReferenceError; + public static PyException ReferenceError(String message) { + return new PyException(Py.ReferenceError, message); + } + public static PyObject SystemError; public static PyException SystemError(String message) { *************** *** 179,182 **** --- 184,191 ---- } + public static PyObject StopIterator; + public static PyException StopIterator(String message) { + return new PyException(Py.StopIterator, message); + } public static PyObject ImportError; *************** *** 240,243 **** --- 249,257 ---- } + public static PyObject OverflowWarning; + public static void OverflowWarning(String message) { + warning(OverflowWarning, message); + } + public static PyObject RuntimeWarning; public static void RuntimeWarning(String message) { *************** *** 523,526 **** --- 537,541 ---- Exception = initExc("Exception", exc, dict); SystemExit = initExc("SystemExit", exc, dict); + StopIterator = initExc("StopIterator", exc, dict); StandardError = initExc("StandardError", exc, dict); KeyboardInterrupt = initExc("KeyboardInterrupt", exc, dict); *************** *** 549,552 **** --- 564,568 ---- ValueError = initExc("ValueError", exc, dict); UnicodeError = initExc("UnicodeError", exc, dict); + ReferenceError = initExc("ReferenceError", exc, dict); SystemError = initExc("SystemError", exc, dict); MemoryError = initExc("MemoryError", exc, dict); *************** *** 555,558 **** --- 571,575 ---- DeprecationWarning = initExc("DeprecationWarning", exc, dict); SyntaxWarning = initExc("SyntaxWarning", exc, dict); + OverflowWarning = initExc("OverflowWarning", exc, dict); RuntimeWarning = initExc("RuntimeWarning", exc, dict); } |
From: Finn B. <bc...@us...> - 2002-01-06 16:11:09
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv24355 Modified Files: exceptions.java Log Message: Added 2.2 exceptions. Index: exceptions.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/exceptions.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** exceptions.java 2001/11/27 19:07:21 1.10 --- exceptions.java 2002/01/06 16:11:06 1.11 *************** *** 25,28 **** --- 25,29 ---- " |\n" + " +-- SystemExit\n" + + " +-- StopIteration\n" + " +-- StandardError\n" + " | |\n" + *************** *** 69,72 **** --- 70,74 ---- " | | +-- UnicodeError\n" + " | |\n" + + " | +-- ReferenceError\n" + " | +-- SystemError\n" + " | +-- MemoryError\n" + *************** *** 77,80 **** --- 79,83 ---- " +-- DeprecationWarning\n" + " +-- SyntaxWarning\n" + + " +-- OverflowWarning\n" + " +-- RuntimeWarning"; *************** *** 143,146 **** --- 146,152 ---- "platform and version."); + buildClass(dict, "ReferenceError", "StandardError", "empty__init__", + "Weak ref proxy used after referent went away."); + buildClass(dict, "EOFError", "StandardError", "empty__init__", "Read beyond end of file."); *************** *** 204,207 **** --- 210,216 ---- "Request to exit from the interpreter."); + buildClass(dict, "StopIterator", "Exception", "empty__init__", + "Signal the end from iterator.next()."); + buildClass(dict, "Warning", "Exception", "empty__init__", "Base class for warning categories."); *************** *** 218,221 **** --- 227,234 ---- buildClass(dict, "RuntimeWarning", "Warning", "empty__init__", "Base class for warnings about dubious runtime behavior."); + + buildClass(dict, "OverflowWarning", "Warning", "empty__init__", + "Base class for warnings about numeric overflow."); + ts.frame = ts.frame.f_back; } |
From: Finn B. <bc...@us...> - 2002-01-06 15:53:27
|
Update of /cvsroot/jython/jython/org/python/modules/sre In directory usw-pr-cvs1:/tmp/cvs-serv21026/sre Modified Files: PatternObject.java SRE_STATE.java ScannerObject.java Log Message: CPython-2.2's sre changes to MAGIC==20010701. Index: PatternObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/PatternObject.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PatternObject.java 2001/11/27 19:07:22 1.7 --- PatternObject.java 2002/01/06 15:53:25 1.8 *************** *** 27,30 **** --- 27,31 ---- public int flags; org.python.core.PyObject indexgroup; + public int codesize; *************** *** 32,38 **** int groups, PyObject groupindex, PyObject indexgroup) { ! this.pattern = pattern.toString(); this.flags = flags; this.code = code; this.groups = groups; this.groupindex = groupindex; --- 33,41 ---- int groups, PyObject groupindex, PyObject indexgroup) { ! if (pattern != null) ! this.pattern = pattern.toString(); this.flags = flags; this.code = code; + this.codesize = code.length; this.groups = groups; this.groupindex = groupindex; *************** *** 82,93 **** int count = ap.getInt(2, 0); ! return call("_sub", new PyObject[] { ! Py.java2py(this), ! template, ! Py.newString(string), ! Py.newInteger(count) }); } public PyObject subn(PyObject[] args, String[] kws) { ArgParser ap = new ArgParser("subn", args, kws, --- 85,93 ---- int count = ap.getInt(2, 0); ! return subx(template, string, count, false); } + public PyObject subn(PyObject[] args, String[] kws) { ArgParser ap = new ArgParser("subn", args, kws, *************** *** 97,105 **** int count = ap.getInt(2, 0); ! return call("_subn", new PyObject[] { ! Py.java2py(this), ! template, ! Py.newString(string), ! Py.newInteger(count) }); } --- 97,183 ---- int count = ap.getInt(2, 0); ! return subx(template, string, count, true); ! } ! ! ! private PyObject subx(PyObject template, String string, int count, ! boolean subn) ! { ! PyObject filter = null; ! boolean filter_is_callable = false; ! if (template.isCallable()) { ! filter = template; ! filter_is_callable = true; ! } else { ! boolean literal = false; ! if (template instanceof PyString) { ! literal = template.toString().indexOf('\\') < 0; ! } ! if (literal) { ! filter = template; ! filter_is_callable = false; ! } else { ! filter = call("sre", "_subx", new PyObject[] { ! this, template}); ! filter_is_callable = filter.isCallable(); ! } ! } ! ! SRE_STATE state = new SRE_STATE(string, 0, Integer.MAX_VALUE, flags); ! ! StringBuffer buf = new StringBuffer(); ! ! int n = 0; ! int i = 0; ! ! while (count == 0 || n < count) { ! state.state_reset(); ! state.ptr = state.start; ! int status = state.SRE_SEARCH(code, 0); ! if (status <= 0) { ! if (status == 0) ! break; ! _error(status); ! } ! int b = state.start; ! int e = state.ptr; ! ! if (i < b) { ! /* get segment before this match */ ! buf.append(string.substring(i, b)); ! } ! if (! (i == b && i == e && n > 0)) { ! PyObject item; ! if (filter_is_callable) { ! /* pass match object through filter */ ! MatchObject match = _pattern_new_match(state, string, 1); ! item = filter.__call__(match); ! } else { ! item = filter; ! } ! ! if (item != Py.None) { ! buf.append(item.toString()); ! } ! i = e; ! n++; ! } ! ! /* move on */ ! if (state.ptr == state.start) ! state.start = state.ptr + 1; ! else ! state.start = state.ptr; ! } ! if (i < state.endpos) { ! buf.append(string.substring(i, state.endpos)); ! } ! ! if (subn) ! return new PyTuple(new PyObject[] { ! Py.newString(buf.toString()), Py.newInteger(n) ! }); ! else ! return Py.newString(buf.toString()); } *************** *** 109,122 **** "source", "maxsplit"); String string = ap.getString(0); ! int count = ap.getInt(1, 0); ! return call("_split", new PyObject[] { ! Py.java2py(this), ! Py.newString(string), ! Py.newInteger(count) }); } ! private PyObject call(String function, PyObject[] args) { ! PyObject sre = imp.importName("sre", true); return sre.invoke(function, args); } --- 187,238 ---- "source", "maxsplit"); String string = ap.getString(0); ! int maxsplit = ap.getInt(1, 0); ! SRE_STATE state = new SRE_STATE(string, 0, Integer.MAX_VALUE, flags); ! ! PyList list = new PyList(); ! ! int n = 0; ! int last = state.start; ! while (maxsplit == 0 || n < maxsplit) { ! state.state_reset(); ! state.ptr = state.start; ! int status = state.SRE_SEARCH(code, 0); ! if (status <= 0) { ! if (status == 0) ! break; ! _error(status); ! } ! if (state.start == state.ptr) { ! if (last == state.end) ! break; ! /* skip one character */ ! state.start = state.ptr + 1; ! continue; ! } ! ! /* get segment before this match */ ! PyObject item = Py.newString(string.substring(last, state.start)); ! list.append(item); ! ! for (int i = 0; i < groups; i++) { ! String s = state.getslice(i+1, string, false); ! if (s != null) ! list.append(Py.newString(s)); ! else ! list.append(Py.None); ! } ! n += 1; ! last = state.start = state.ptr; ! } ! ! PyObject item = Py.newString(string.substring(last, state.endpos)); ! list.append(item); ! ! return list; } ! private PyObject call(String module, String function, PyObject[] args) { ! PyObject sre = imp.importName(module, true); return sre.invoke(function, args); } *************** *** 149,158 **** break; case 1: ! item = Py.newString(state.getslice(1, string)); break; default: PyObject[] t = new PyObject[groups]; for (int i = 0; i < groups; i++) ! t[i] = Py.newString(state.getslice(i+1, string)); item = new PyTuple(t); break; --- 265,274 ---- break; case 1: ! item = Py.newString(state.getslice(1, string, true)); break; default: PyObject[] t = new PyObject[groups]; for (int i = 0; i < groups; i++) ! t[i] = Py.newString(state.getslice(i+1, string, true)); item = new PyTuple(t); break; *************** *** 176,179 **** --- 292,311 ---- } + + /* Enable "finditer" when iter support is added. + public PyObject finditer(String string) { + return finditer(string, 0, Integer.MAX_VALUE); + } + + public PyObject finditer(String string, int start) { + return finditer(string, start, Integer.MAX_VALUE); + } + + public PyObject finditer(String string, int start, int end) { + ScannerObject scanner = scanner(string, start, end); + PyObject search = scanner.__findattr__("search"); + return new PyCallIterator(search, Py.None); + } + */ public ScannerObject scanner(String string) { Index: SRE_STATE.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/SRE_STATE.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SRE_STATE.java 2001/11/27 19:07:22 1.7 --- SRE_STATE.java 2002/01/06 15:53:25 1.8 *************** *** 41,62 **** public static final int SRE_OP_CATEGORY = 9; public static final int SRE_OP_CHARSET = 10; ! public static final int SRE_OP_GROUPREF = 11; ! public static final int SRE_OP_GROUPREF_IGNORE = 12; ! public static final int SRE_OP_IN = 13; ! public static final int SRE_OP_IN_IGNORE = 14; ! public static final int SRE_OP_INFO = 15; ! public static final int SRE_OP_JUMP = 16; ! public static final int SRE_OP_LITERAL = 17; ! public static final int SRE_OP_LITERAL_IGNORE = 18; ! public static final int SRE_OP_MARK = 19; ! public static final int SRE_OP_MAX_UNTIL = 20; ! public static final int SRE_OP_MIN_UNTIL = 21; ! public static final int SRE_OP_NOT_LITERAL = 22; ! public static final int SRE_OP_NOT_LITERAL_IGNORE = 23; ! public static final int SRE_OP_NEGATE = 24; ! public static final int SRE_OP_RANGE = 25; ! public static final int SRE_OP_REPEAT = 26; ! public static final int SRE_OP_REPEAT_ONE = 27; ! public static final int SRE_OP_SUBPATTERN = 28; public static final int SRE_AT_BEGINNING = 0; --- 41,63 ---- public static final int SRE_OP_CATEGORY = 9; public static final int SRE_OP_CHARSET = 10; ! public static final int SRE_OP_BIGCHARSET = 11; ! public static final int SRE_OP_GROUPREF = 12; ! public static final int SRE_OP_GROUPREF_IGNORE = 13; ! public static final int SRE_OP_IN = 14; ! public static final int SRE_OP_IN_IGNORE = 15; ! public static final int SRE_OP_INFO = 16; ! public static final int SRE_OP_JUMP = 17; ! public static final int SRE_OP_LITERAL = 18; ! public static final int SRE_OP_LITERAL_IGNORE = 19; ! public static final int SRE_OP_MARK = 20; ! public static final int SRE_OP_MAX_UNTIL = 21; ! public static final int SRE_OP_MIN_UNTIL = 22; ! public static final int SRE_OP_NOT_LITERAL = 23; ! public static final int SRE_OP_NOT_LITERAL_IGNORE = 24; ! public static final int SRE_OP_NEGATE = 25; ! public static final int SRE_OP_RANGE = 26; ! public static final int SRE_OP_REPEAT = 27; ! public static final int SRE_OP_REPEAT_ONE = 28; ! public static final int SRE_OP_SUBPATTERN = 29; public static final int SRE_AT_BEGINNING = 0; *************** *** 329,332 **** --- 330,344 ---- break; + case SRE_OP_BIGCHARSET: + /* <BIGCHARSET> <blockcount> <256 blockindices> <blocks> */ + int count = set[setidx++]; + int block = set[ch >> 8]; + setidx += 128; + int idx = block*16 + ((ch & 255)>>4); + if ((set[setidx + idx] & (1 << (ch & 15))) != 0) + return ok; + setidx += count*16; + break; + case SRE_OP_CATEGORY: /* <CATEGORY> <code> */ *************** *** 816,819 **** --- 828,832 ---- return i; mark_restore(0, lastmark); + this.lastmark = lastmark; rp.count = count - 1; this.ptr = ptr; *************** *** 859,872 **** /* see if the tail matches */ this.repeat = rp.prev; ! if (pattern[rp.pidx + 2] == 65535) { ! /* unbounded repeat */ ! for (;;) { ! i = SRE_MATCH(pattern, pidx, level + 1); ! if (i != 0 || ptr >= end) ! break; ! this.ptr = ++ptr; ! } ! } else ! i = SRE_MATCH(pattern, pidx, level + 1); if (i != 0) return i; --- 872,876 ---- /* see if the tail matches */ this.repeat = rp.prev; ! i = SRE_MATCH(pattern, pidx, level + 1); if (i != 0) return i; *************** *** 991,994 **** --- 995,1000 ---- this.start = ptr; this.ptr = ++ptr; + if ((flags & SRE_INFO_LITERAL) != 0) + return 1; status = SRE_MATCH(pattern, pidx + 2, 1); if (status != 0) *************** *** 1028,1035 **** - - - - final boolean sre_category(char category, char ch) { switch (category) { --- 1034,1037 ---- *************** *** 1175,1179 **** ! String getslice(int index, String string) { int i, j; --- 1177,1181 ---- ! String getslice(int index, String string, boolean empty) { int i, j; *************** *** 1181,1185 **** if (string == null || mark[index] == -1 || mark[index+1] == -1) { ! i = j = 0; } else { i = mark[index]; --- 1183,1192 ---- if (string == null || mark[index] == -1 || mark[index+1] == -1) { ! if (empty) { ! /* want empty string */ ! i = j = 0; ! } else { ! return null; ! } } else { i = mark[index]; Index: ScannerObject.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/sre/ScannerObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ScannerObject.java 2001/11/27 13:51:37 1.3 --- ScannerObject.java 2002/01/06 15:53:25 1.4 *************** *** 16,20 **** package org.python.modules.sre; ! public class ScannerObject { PatternObject pattern; String string; --- 16,22 ---- package org.python.modules.sre; ! import org.python.core.*; ! ! public class ScannerObject extends PyObject { PatternObject pattern; String string; |
From: Finn B. <bc...@us...> - 2002-01-06 15:53:27
|
Update of /cvsroot/jython/jython/org/python/modules In directory usw-pr-cvs1:/tmp/cvs-serv21026 Modified Files: _sre.java Log Message: CPython-2.2's sre changes to MAGIC==20010701. Index: _sre.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/modules/_sre.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** _sre.java 2001/04/04 19:08:21 1.6 --- _sre.java 2002/01/06 15:53:24 1.7 *************** *** 23,27 **** public class _sre { // update when constants are added or removed ! public static int MAGIC = 20010320; --- 23,27 ---- public class _sre { // update when constants are added or removed ! public static int MAGIC = 20010701; |
From: Finn B. <bc...@us...> - 2002-01-06 15:50:25
|
Update of /cvsroot/jython/jython/org/python/core In directory usw-pr-cvs1:/tmp/cvs-serv20481 Modified Files: PySystemState.java Log Message: Post 2.1 version number. Index: PySystemState.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PySystemState.java,v retrieving revision 2.74 retrieving revision 2.75 diff -C2 -d -r2.74 -r2.75 *** PySystemState.java 2001/12/31 11:18:18 2.74 --- PySystemState.java 2002/01/06 15:50:22 2.75 *************** *** 18,27 **** * The current version of JPython. */ ! public static String version = "2.1"; private static int PY_MAJOR_VERSION = 2; ! private static int PY_MINOR_VERSION = 1; private static int PY_MICRO_VERSION = 0; ! private static int PY_RELEASE_LEVEL = 0xF; private static int PY_RELEASE_SERIAL = 0; --- 18,27 ---- * The current version of JPython. */ ! public static String version = "2.1+"; private static int PY_MAJOR_VERSION = 2; ! private static int PY_MINOR_VERSION = 2; private static int PY_MICRO_VERSION = 0; ! private static int PY_RELEASE_LEVEL = 0xA; private static int PY_RELEASE_SERIAL = 0; |
From: Finn B. <bc...@us...> - 2001-12-31 13:43:55
|
Update of /cvsroot/jython/htdocs/docs In directory usw-pr-cvs1:/tmp/cvs-serv19724/docs Modified Files: links.h Log Message: Updated links to 2.1 downloads. Index: links.h =================================================================== RCS file: /cvsroot/jython/htdocs/docs/links.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** links.h 2001/12/21 22:25:48 1.8 --- links.h 2001/12/31 13:43:52 1.9 *************** *** 3,8 **** <li><a href="../index.html">Overview</a> <li><a href="../license.html">License</a> ! <li><a href="../download.html">Jython 2.0</a> ! <li><a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=66632">Jython 2.1b2</a> <li><a href="../install.html">Installing</a> <li><a href="../platform.html">JVM Compatibility</a> --- 3,8 ---- <li><a href="../index.html">Overview</a> <li><a href="../license.html">License</a> ! <li><a href="http://sourceforge.net/project/showfiles.php?group_id=12867&release_id=21045">Jython 2.0</a> ! <li><a href="../download.html">Jython 2.1</a> <li><a href="../install.html">Installing</a> <li><a href="../platform.html">JVM Compatibility</a> |