From: brian z. <bz...@us...> - 2003-09-30 20:06:04
|
Update of /cvsroot/jython/jython/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv16470 Modified Files: dbexts.py Log Message: handle broken databasemetedata Index: dbexts.py =================================================================== RCS file: /cvsroot/jython/jython/Lib/dbexts.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dbexts.py 31 Dec 2002 20:16:06 -0000 1.11 --- dbexts.py 30 Sep 2003 20:05:59 -0000 1.12 *************** *** 235,240 **** setattr(self, database.sqltype[a], a) for a in dir(database): - p = getattr(database, a) try: if issubclass(p, Exception): setattr(self, a, p) --- 235,240 ---- setattr(self, database.sqltype[a], a) for a in dir(database): try: + p = getattr(database, a) if issubclass(p, Exception): setattr(self, a, p) *************** *** 600,622 **** if self.sort: self.primarykeys.sort(lambda x, y: cmp(x[1], y[1])) ! self.db.stat(self.table) ! # (non-unique, name, type, pos, column name, asc) ! self.indices = [] ! if self.db.results: ! idxdict = {} ! # mxODBC returns a row of None's, so filter it out ! idx = map(lambda x: (x[3], x[5].strip(), x[6], x[7], x[8]), filter(lambda x: x[5], self.db.results)) ! def cckmp(x, y): ! c = cmp(x[1], y[1]) ! if c == 0: c = cmp(x[3], y[3]) ! return c ! # sort this regardless, this gets the indicies lined up ! idx.sort(cckmp) ! for a in idx: ! if not idxdict.has_key(a[1]): ! idxdict[a[1]] = [] ! idxdict[a[1]].append(a) ! self.indices = idxdict.values() ! if self.sort: self.indices.sort(lambda x, y: cmp(x[0][1], y[0][1])) def __str__(self): --- 600,626 ---- if self.sort: self.primarykeys.sort(lambda x, y: cmp(x[1], y[1])) ! try: ! self.indices = None ! self.db.stat(self.table) ! self.indices = [] ! # (non-unique, name, type, pos, column name, asc) ! if self.db.results: ! idxdict = {} ! # mxODBC returns a row of None's, so filter it out ! idx = map(lambda x: (x[3], x[5].strip(), x[6], x[7], x[8]), filter(lambda x: x[5], self.db.results)) ! def cckmp(x, y): ! c = cmp(x[1], y[1]) ! if c == 0: c = cmp(x[3], y[3]) ! return c ! # sort this regardless, this gets the indicies lined up ! idx.sort(cckmp) ! for a in idx: ! if not idxdict.has_key(a[1]): ! idxdict[a[1]] = [] ! idxdict[a[1]].append(a) ! self.indices = idxdict.values() ! if self.sort: self.indices.sort(lambda x, y: cmp(x[0][1], y[0][1])) ! except: ! pass def __str__(self): *************** *** 639,646 **** d.append(" %-20s %s(%s), %s" % (a[0], a[1], a[2], nullable)) d.append("\nIndices") ! 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) --- 643,653 ---- d.append(" %-20s %s(%s), %s" % (a[0], a[1], a[2], nullable)) d.append("\nIndices") ! if self.indices is None: ! d.append(" (failed)") ! else: ! for a in self.indices: ! unique = choose(a[0][0], "non-unique", "unique") ! cname = ", ".join(map(lambda x: x[4], a)) ! d.append(" %s index {%s} on (%s)" % (unique, a[0][1], cname)) return "\n".join(d) |