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: <pj...@us...> - 2008-07-12 00:33:23
|
Revision: 4896 http://jython.svn.sourceforge.net/jython/?rev=4896&view=rev Author: pjenvey Date: 2008-07-11 17:33:21 -0700 (Fri, 11 Jul 2008) Log Message: ----------- fix java exception names being prefixed with <unknown> in Python tracebacks Modified Paths: -------------- branches/asm/src/org/python/core/Py.java Modified: branches/asm/src/org/python/core/Py.java =================================================================== --- branches/asm/src/org/python/core/Py.java 2008-07-12 00:13:15 UTC (rev 4895) +++ branches/asm/src/org/python/core/Py.java 2008-07-12 00:33:21 UTC (rev 4896) @@ -999,7 +999,10 @@ } PyObject moduleName = type.__findattr__("__module__"); if (moduleName == null) { - buf.append("<unknown>"); + // XXX: Workaround the fact that PyClass lacks __module__ + if (!(type instanceof PyClass)) { + buf.append("<unknown>"); + } } else { String moduleStr = moduleName.toString(); if (!moduleStr.equals("exceptions")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-12 00:13:18
|
Revision: 4895 http://jython.svn.sourceforge.net/jython/?rev=4895&view=rev Author: pjenvey Date: 2008-07-11 17:13:15 -0700 (Fri, 11 Jul 2008) Log Message: ----------- fix some odder 2.5 tests of string count/find/rfind. rewrite join to act like CPython's, mainly so: a.join([b]) is b Modified Paths: -------------- branches/asm/src/org/python/core/PyString.java Modified: branches/asm/src/org/python/core/PyString.java =================================================================== --- branches/asm/src/org/python/core/PyString.java 2008-07-12 00:10:28 UTC (rev 4894) +++ branches/asm/src/org/python/core/PyString.java 2008-07-12 00:13:15 UTC (rev 4895) @@ -1409,6 +1409,9 @@ int[] indices = translateIndices(start, end); int n = sub.length(); if(n == 0) { + if (start > string.length()) { + return 0; + } return indices[1] - indices[0] + 1; } int count = 0; @@ -1439,8 +1442,9 @@ final int str_find(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); int index = string.indexOf(sub, indices[0]); - if (index > indices[1]) + if (index < start || index > indices[1]) { return -1; + } return index; } @@ -1460,8 +1464,9 @@ final int str_rfind(String sub, int start, PyObject end) { int[] indices = translateIndices(start, end); int index = string.lastIndexOf(sub, indices[1] - sub.length()); - if(index < indices[0]) + if (index < start) { return -1; + } return index; } @@ -1800,27 +1805,53 @@ } @ExposedMethod - final PyString str_join(PyObject seq) { - StringBuilder buf = new StringBuilder(); + final PyString str_join(PyObject obj) { + // Similar to CPython's abstract::PySequence_Fast + PySequence seq; + if (obj instanceof PySequence) { + seq = (PySequence)obj; + } else { + seq = new PyList(obj.__iter__()); + } - PyObject iter = seq.__iter__(); - PyObject obj = null; + PyObject item; + int seqlen = seq.__len__(); + if (seqlen == 0) { + return createInstance(""); + } + if (seqlen == 1) { + item = seq.pyget(0); + if (item.getType() == PyUnicode.TYPE || + (item.getType() == PyString.TYPE && getType() == PyString.TYPE)) { + return (PyString)item; + } + } + boolean needsUnicode = false; - for (int i = 0; (obj = iter.__iternext__()) != null; i++) { - if (!(obj instanceof PyString)){ - throw Py.TypeError( - "sequence item " + i + ": expected string, " + - obj.getType().fastGetName() + " found"); + long joinedSize = 0; + StringBuilder buf = new StringBuilder(); + for (int i = 0; i < seqlen; i++) { + item = seq.pyget(i); + if (!(item instanceof PyString)) { + throw Py.TypeError(String.format("sequence item %d: expected string, %.80s found", + i, item.getType().fastGetName())); } - if(obj instanceof PyUnicode){ + if (item instanceof PyUnicode) { needsUnicode = true; } - if (i > 0){ + if (i > 0) { buf.append(string); + joinedSize += string.length(); } - buf.append(((PyString)obj).string); + String itemString = ((PyString)item).string; + buf.append(itemString); + joinedSize += itemString.length(); + if (joinedSize > Integer.MAX_VALUE) { + throw Py.OverflowError("join() result is too long for a Python string"); + } } - if(needsUnicode){ + + if (needsUnicode){ return new PyUnicode(buf.toString()); } return createInstance(buf.toString()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-12 00:10:31
|
Revision: 4894 http://jython.svn.sourceforge.net/jython/?rev=4894&view=rev Author: pjenvey Date: 2008-07-11 17:10:28 -0700 (Fri, 11 Jul 2008) Log Message: ----------- fix unicode(str_subclass) not using its __unicode__ method Modified Paths: -------------- branches/asm/src/org/python/core/PyUnicode.java Modified: branches/asm/src/org/python/core/PyUnicode.java =================================================================== --- branches/asm/src/org/python/core/PyUnicode.java 2008-07-11 20:16:53 UTC (rev 4893) +++ branches/asm/src/org/python/core/PyUnicode.java 2008-07-12 00:10:28 UTC (rev 4894) @@ -156,6 +156,9 @@ return new PyUnicode(((PyUnicode) S).string); } if (S instanceof PyString) { + if (S.getType() != PyString.TYPE && encoding == null && errors == null) { + return S.__unicode__(); + } PyObject decoded = codecs.decode((PyString) S, encoding, errors); if (decoded instanceof PyUnicode) { return new PyUnicode((PyUnicode) decoded); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-11 20:17:08
|
Revision: 4893 http://jython.svn.sourceforge.net/jython/?rev=4893&view=rev Author: pjenvey Date: 2008-07-11 13:16:53 -0700 (Fri, 11 Jul 2008) Log Message: ----------- o re-integrate workarounds for string_tests o add rsplit fixes #1023 thanks Nimish Telang Modified Paths: -------------- branches/asm/Lib/test/string_tests.py branches/asm/src/org/python/core/PyString.java Modified: branches/asm/Lib/test/string_tests.py =================================================================== --- branches/asm/Lib/test/string_tests.py 2008-07-11 20:10:32 UTC (rev 4892) +++ branches/asm/Lib/test/string_tests.py 2008-07-11 20:16:53 UTC (rev 4893) @@ -936,7 +936,12 @@ self.checkequal('abc', 'abc', '__mul__', 1) self.checkequal('abcabcabc', 'abc', '__mul__', 3) self.checkraises(TypeError, 'abc', '__mul__') - self.checkraises(TypeError, 'abc', '__mul__', '') + # CPython specific; pypy tests via the operator module instead + if not test_support.is_jython: + self.checkraises(TypeError, 'abc', '__mul__', '') + else: + import operator + self.checkraises(TypeError, operator, '__mul__', 'abc', '') # XXX: on a 64-bit system, this doesn't raise an overflow error, # but either raises a MemoryError, or succeeds (if you have 54TiB) #self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000) @@ -1027,7 +1032,7 @@ # unicodeobject.c uses a 120 byte buffer and switches from # 'f' formatting to 'g' at precision 50, so we expect # OverflowErrors for the ranges x < 50 and prec >= 67. - if x < 50 and prec >= 67: + if not test_support.is_jython and x < 50 and prec >= 67: self.checkraises(OverflowError, format, "__mod__", value) else: self.checkcall(format, "__mod__", value) Modified: branches/asm/src/org/python/core/PyString.java =================================================================== --- branches/asm/src/org/python/core/PyString.java 2008-07-11 20:10:32 UTC (rev 4892) +++ branches/asm/src/org/python/core/PyString.java 2008-07-11 20:16:53 UTC (rev 4893) @@ -1072,6 +1072,76 @@ return list; } + public PyList rsplit() { + return str_rsplit(null, -1); + } + + public PyList rsplit(String sep) { + return str_rsplit(sep, -1); + } + + public PyList rsplit(String sep, int maxsplit) { + return str_rsplit(sep, maxsplit); + } + + @ExposedMethod(defaults = {"null", "-1"}) + final PyList str_rsplit(String sep, int maxsplit) { + if (sep != null) { + if (sep.length() == 0) { + throw Py.ValueError("empty separator"); + } + PyList list = rsplitfields(sep, maxsplit); + list.reverse(); + return list; + } + + PyList list = new PyList(); + char[] chars = string.toCharArray(); + + if (maxsplit < 0) { + maxsplit = chars.length; + } + + int splits = 0; + int i = chars.length - 1; + + while (i > -1 && Character.isWhitespace(chars[i])) { + i--; + } + if (i == -1) { + return list; + } + + while (splits < maxsplit) { + while (i > -1 && Character.isWhitespace(chars[i])) { + i--; + } + if (i == -1) { + break; + } + + int nextWsChar = i; + while (nextWsChar > -1 && !Character.isWhitespace(chars[nextWsChar])) { + nextWsChar--; + } + if (nextWsChar == -1) { + break; + } + + splits++; + list.add(fromSubstring(nextWsChar + 1, i + 1)); + i = nextWsChar; + } + while (i > -1 && Character.isWhitespace(chars[i])) { + i--; + } + if (i > -1) { + list.add(fromSubstring(0,i+1)); + } + list.reverse(); + return list; + } + public PyTuple partition(PyObject sepObj) { return str_partition(sepObj); } @@ -1206,6 +1276,37 @@ return list; } + private PyList rsplitfields(String sep, int maxsplit) { + PyList list = new PyList(); + + int length = string.length(); + if (maxsplit < 0) { + maxsplit = length + 1; + } + + int lastbreak = length; + int splits = 0; + int index = length; + int sepLength = sep.length(); + + while (index > 0 && splits < maxsplit) { + int i = string.lastIndexOf(sep, index - sepLength); + if (i == index) { + i -= sepLength; + } + if (i < 0) { + break; + } + splits++; + list.append(fromSubstring(i + sepLength, lastbreak)); + lastbreak = i; + index = i; + + } + list.append(fromSubstring(0, lastbreak)); + return list; + } + public PyList splitlines() { return str_splitlines(false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-11 20:10:35
|
Revision: 4892 http://jython.svn.sourceforge.net/jython/?rev=4892&view=rev Author: pjenvey Date: 2008-07-11 13:10:32 -0700 (Fri, 11 Jul 2008) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/string_tests.py@55878 Modified Paths: -------------- branches/asm/Lib/test/string_tests.py Modified: branches/asm/Lib/test/string_tests.py =================================================================== --- branches/asm/Lib/test/string_tests.py 2008-07-11 19:37:19 UTC (rev 4891) +++ branches/asm/Lib/test/string_tests.py 2008-07-11 20:10:32 UTC (rev 4892) @@ -2,7 +2,7 @@ Common tests shared by test_str, test_unicode, test_userstring and test_string. """ -import unittest, string, sys +import unittest, string, sys, struct from test import test_support from UserList import UserList @@ -80,6 +80,15 @@ args = self.fixtype(args) getattr(object, methodname)(*args) + def test_hash(self): + # SF bug 1054139: += optimization was not invalidating cached hash value + a = self.type2test('DNSSEC') + b = self.type2test('') + for c in a: + b += c + hash(b) + self.assertEqual(hash(a), hash(b)) + def test_capitalize(self): self.checkequal(' hello ', ' hello ', 'capitalize') self.checkequal('Hello ', 'Hello ','capitalize') @@ -97,28 +106,97 @@ self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(0, 'aaa', 'count', 'b') + self.checkequal(2, 'aaa', 'count', 'a', 1) + self.checkequal(0, 'aaa', 'count', 'a', 10) self.checkequal(1, 'aaa', 'count', 'a', -1) self.checkequal(3, 'aaa', 'count', 'a', -10) + self.checkequal(1, 'aaa', 'count', 'a', 0, 1) + self.checkequal(3, 'aaa', 'count', 'a', 0, 10) self.checkequal(2, 'aaa', 'count', 'a', 0, -1) self.checkequal(0, 'aaa', 'count', 'a', 0, -10) + self.checkequal(3, 'aaa', 'count', '', 1) + self.checkequal(1, 'aaa', 'count', '', 3) + self.checkequal(0, 'aaa', 'count', '', 10) + self.checkequal(2, 'aaa', 'count', '', -1) + self.checkequal(4, 'aaa', 'count', '', -10) self.checkraises(TypeError, 'hello', 'count') self.checkraises(TypeError, 'hello', 'count', 42) + # For a variety of combinations, + # verify that str.count() matches an equivalent function + # replacing all occurrences and then differencing the string lengths + charset = ['', 'a', 'b'] + digits = 7 + base = len(charset) + teststrings = set() + for i in xrange(base ** digits): + entry = [] + for j in xrange(digits): + i, m = divmod(i, base) + entry.append(charset[m]) + teststrings.add(''.join(entry)) + teststrings = list(teststrings) + for i in teststrings: + i = self.fixtype(i) + n = len(i) + for j in teststrings: + r1 = i.count(j) + if j: + r2, rem = divmod(n - len(i.replace(j, '')), len(j)) + else: + r2, rem = len(i)+1, 0 + if rem or r1 != r2: + self.assertEqual(rem, 0, '%s != 0 for %s' % (rem, i)) + self.assertEqual(r1, r2, '%s != %s for %s' % (r1, r2, i)) + def test_find(self): self.checkequal(0, 'abcdefghiabc', 'find', 'abc') self.checkequal(9, 'abcdefghiabc', 'find', 'abc', 1) self.checkequal(-1, 'abcdefghiabc', 'find', 'def', 4) + self.checkequal(0, 'abc', 'find', '', 0) + self.checkequal(3, 'abc', 'find', '', 3) + self.checkequal(-1, 'abc', 'find', '', 4) + self.checkraises(TypeError, 'hello', 'find') self.checkraises(TypeError, 'hello', 'find', 42) + # For a variety of combinations, + # verify that str.find() matches __contains__ + # and that the found substring is really at that location + charset = ['', 'a', 'b', 'c'] + digits = 5 + base = len(charset) + teststrings = set() + for i in xrange(base ** digits): + entry = [] + for j in xrange(digits): + i, m = divmod(i, base) + entry.append(charset[m]) + teststrings.add(''.join(entry)) + teststrings = list(teststrings) + for i in teststrings: + i = self.fixtype(i) + for j in teststrings: + loc = i.find(j) + r1 = (loc != -1) + r2 = j in i + if r1 != r2: + self.assertEqual(r1, r2) + if loc != -1: + self.assertEqual(i[loc:loc+len(j)], j) + def test_rfind(self): self.checkequal(9, 'abcdefghiabc', 'rfind', 'abc') self.checkequal(12, 'abcdefghiabc', 'rfind', '') self.checkequal(0, 'abcdefghiabc', 'rfind', 'abcd') self.checkequal(-1, 'abcdefghiabc', 'rfind', 'abcz') + self.checkequal(3, 'abc', 'rfind', '', 0) + self.checkequal(3, 'abc', 'rfind', '', 3) + self.checkequal(-1, 'abc', 'rfind', '', 4) + self.checkraises(TypeError, 'hello', 'rfind') self.checkraises(TypeError, 'hello', 'rfind', 42) @@ -169,26 +247,191 @@ self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs') self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8) self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4) + self.checkequal(' a\n b', ' \ta\n\tb', 'expandtabs', 1) self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42) + # This test is only valid when sizeof(int) == sizeof(void*) == 4. + if sys.maxint < (1 << 32) and struct.calcsize('P') == 4: + self.checkraises(OverflowError, + '\ta\n\tb', 'expandtabs', sys.maxint) def test_split(self): self.checkequal(['this', 'is', 'the', 'split', 'function'], 'this is the split function', 'split') - self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') - self.checkequal(['a', 'b', 'c|d'], 'a|b|c|d', 'split', '|', 2) + + # by whitespace + self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'split') self.checkequal(['a', 'b c d'], 'a b c d', 'split', None, 1) self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 3) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, + sys.maxint-1) self.checkequal(['a b c d'], 'a b c d', 'split', None, 0) + self.checkequal(['a b c d'], ' a b c d', 'split', None, 0) self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) - self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'split') + + self.checkequal([], ' ', 'split') + self.checkequal(['a'], ' a ', 'split') + self.checkequal(['a', 'b'], ' a b ', 'split') + self.checkequal(['a', 'b '], ' a b ', 'split', None, 1) + self.checkequal(['a', 'b c '], ' a b c ', 'split', None, 1) + self.checkequal(['a', 'b', 'c '], ' a b c ', 'split', None, 2) + self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'split') + aaa = ' a '*20 + self.checkequal(['a']*20, aaa, 'split') + self.checkequal(['a'] + [aaa[4:]], aaa, 'split', None, 1) + self.checkequal(['a']*19 + ['a '], aaa, 'split', None, 19) + + # by a char + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|') + self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0) + self.checkequal(['a', 'b|c|d'], 'a|b|c|d', 'split', '|', 1) + self.checkequal(['a', 'b', 'c|d'], 'a|b|c|d', 'split', '|', 2) + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 3) + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', + sys.maxint-2) + self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0) + self.checkequal(['a', '', 'b||c||d'], 'a||b||c||d', 'split', '|', 2) + self.checkequal(['endcase ', ''], 'endcase |', 'split', '|') + self.checkequal(['', ' startcase'], '| startcase', 'split', '|') + self.checkequal(['', 'bothcase', ''], '|bothcase|', 'split', '|') + self.checkequal(['a', '', 'b\x00c\x00d'], 'a\x00\x00b\x00c\x00d', 'split', '\x00', 2) + + self.checkequal(['a']*20, ('a|'*20)[:-1], 'split', '|') + self.checkequal(['a']*15 +['a|a|a|a|a'], + ('a|'*20)[:-1], 'split', '|', 15) + + # by string self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//') - #self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test') + self.checkequal(['a', 'b//c//d'], 'a//b//c//d', 'split', '//', 1) + self.checkequal(['a', 'b', 'c//d'], 'a//b//c//d', 'split', '//', 2) + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 3) + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', + sys.maxint-10) + self.checkequal(['a//b//c//d'], 'a//b//c//d', 'split', '//', 0) + self.checkequal(['a', '', 'b////c////d'], 'a////b////c////d', 'split', '//', 2) + self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test') + self.checkequal(['', ' begincase'], 'test begincase', 'split', 'test') + self.checkequal(['', ' bothcase ', ''], 'test bothcase test', + 'split', 'test') + self.checkequal(['a', 'bc'], 'abbbc', 'split', 'bb') + self.checkequal(['', ''], 'aaa', 'split', 'aaa') + self.checkequal(['aaa'], 'aaa', 'split', 'aaa', 0) + self.checkequal(['ab', 'ab'], 'abbaab', 'split', 'ba') + self.checkequal(['aaaa'], 'aaaa', 'split', 'aab') + self.checkequal([''], '', 'split', 'aaa') + self.checkequal(['aa'], 'aa', 'split', 'aaa') + self.checkequal(['A', 'bobb'], 'Abbobbbobb', 'split', 'bbobb') + self.checkequal(['A', 'B', ''], 'AbbobbBbbobb', 'split', 'bbobb') + self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH') + self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'split', 'BLAH', 19) + self.checkequal(['a']*18 + ['aBLAHa'], ('aBLAH'*20)[:-4], + 'split', 'BLAH', 18) + + # mixed use of str and unicode + self.checkequal([u'a', u'b', u'c d'], 'a b c d', 'split', u' ', 2) + + # argument type self.checkraises(TypeError, 'hello', 'split', 42, 42, 42) + # null case + self.checkraises(ValueError, 'hello', 'split', '') + self.checkraises(ValueError, 'hello', 'split', '', 0) + + def test_rsplit(self): + self.checkequal(['this', 'is', 'the', 'rsplit', 'function'], + 'this is the rsplit function', 'rsplit') + + # by whitespace + self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'rsplit') + self.checkequal(['a b c', 'd'], 'a b c d', 'rsplit', None, 1) + self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2) + self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3) + self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, + sys.maxint-20) + self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0) + self.checkequal(['a b c d'], 'a b c d ', 'rsplit', None, 0) + self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2) + + self.checkequal([], ' ', 'rsplit') + self.checkequal(['a'], ' a ', 'rsplit') + self.checkequal(['a', 'b'], ' a b ', 'rsplit') + self.checkequal([' a', 'b'], ' a b ', 'rsplit', None, 1) + self.checkequal([' a b','c'], ' a b c ', 'rsplit', + None, 1) + self.checkequal([' a', 'b', 'c'], ' a b c ', 'rsplit', + None, 2) + self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'rsplit', None, 88) + aaa = ' a '*20 + self.checkequal(['a']*20, aaa, 'rsplit') + self.checkequal([aaa[:-4]] + ['a'], aaa, 'rsplit', None, 1) + self.checkequal([' a a'] + ['a']*18, aaa, 'rsplit', None, 18) + + + # by a char + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|') + self.checkequal(['a|b|c', 'd'], 'a|b|c|d', 'rsplit', '|', 1) + self.checkequal(['a|b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 2) + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 3) + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', + sys.maxint-100) + self.checkequal(['a|b|c|d'], 'a|b|c|d', 'rsplit', '|', 0) + self.checkequal(['a||b||c', '', 'd'], 'a||b||c||d', 'rsplit', '|', 2) + self.checkequal(['', ' begincase'], '| begincase', 'rsplit', '|') + self.checkequal(['endcase ', ''], 'endcase |', 'rsplit', '|') + self.checkequal(['', 'bothcase', ''], '|bothcase|', 'rsplit', '|') + + self.checkequal(['a\x00\x00b', 'c', 'd'], 'a\x00\x00b\x00c\x00d', 'rsplit', '\x00', 2) + + self.checkequal(['a']*20, ('a|'*20)[:-1], 'rsplit', '|') + self.checkequal(['a|a|a|a|a']+['a']*15, + ('a|'*20)[:-1], 'rsplit', '|', 15) + + # by string + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//') + self.checkequal(['a//b//c', 'd'], 'a//b//c//d', 'rsplit', '//', 1) + self.checkequal(['a//b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 2) + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 3) + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 4) + self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', + sys.maxint-5) + self.checkequal(['a//b//c//d'], 'a//b//c//d', 'rsplit', '//', 0) + self.checkequal(['a////b////c', '', 'd'], 'a////b////c////d', 'rsplit', '//', 2) + self.checkequal(['', ' begincase'], 'test begincase', 'rsplit', 'test') + self.checkequal(['endcase ', ''], 'endcase test', 'rsplit', 'test') + self.checkequal(['', ' bothcase ', ''], 'test bothcase test', + 'rsplit', 'test') + self.checkequal(['ab', 'c'], 'abbbc', 'rsplit', 'bb') + self.checkequal(['', ''], 'aaa', 'rsplit', 'aaa') + self.checkequal(['aaa'], 'aaa', 'rsplit', 'aaa', 0) + self.checkequal(['ab', 'ab'], 'abbaab', 'rsplit', 'ba') + self.checkequal(['aaaa'], 'aaaa', 'rsplit', 'aab') + self.checkequal([''], '', 'rsplit', 'aaa') + self.checkequal(['aa'], 'aa', 'rsplit', 'aaa') + self.checkequal(['bbob', 'A'], 'bbobbbobbA', 'rsplit', 'bbobb') + self.checkequal(['', 'B', 'A'], 'bbobbBbbobbA', 'rsplit', 'bbobb') + + self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH') + self.checkequal(['a']*20, ('aBLAH'*20)[:-4], 'rsplit', 'BLAH', 19) + self.checkequal(['aBLAHa'] + ['a']*18, ('aBLAH'*20)[:-4], + 'rsplit', 'BLAH', 18) + + # mixed use of str and unicode + self.checkequal([u'a b', u'c', u'd'], 'a b c d', 'rsplit', u' ', 2) + + # argument type + self.checkraises(TypeError, 'hello', 'rsplit', 42, 42, 42) + + # null case + self.checkraises(ValueError, 'hello', 'rsplit', '') + self.checkraises(ValueError, 'hello', 'rsplit', '', 0) + def test_strip(self): self.checkequal('hello', ' hello ', 'strip') self.checkequal('hello ', ' hello ', 'lstrip') @@ -227,7 +470,7 @@ self.checkequal('abc ', 'abc', 'ljust', 6) self.checkequal('abc', 'abc', 'ljust', 3) self.checkequal('abc', 'abc', 'ljust', 2) - + self.checkequal('abc*******', 'abc', 'ljust', 10, '*') self.checkraises(TypeError, 'abc', 'ljust') def test_rjust(self): @@ -235,7 +478,7 @@ self.checkequal(' abc', 'abc', 'rjust', 6) self.checkequal('abc', 'abc', 'rjust', 3) self.checkequal('abc', 'abc', 'rjust', 2) - + self.checkequal('*******abc', 'abc', 'rjust', 10, '*') self.checkraises(TypeError, 'abc', 'rjust') def test_center(self): @@ -243,7 +486,7 @@ self.checkequal(' abc ', 'abc', 'center', 6) self.checkequal('abc', 'abc', 'center', 3) self.checkequal('abc', 'abc', 'center', 2) - + self.checkequal('***abc****', 'abc', 'center', 10, '*') self.checkraises(TypeError, 'abc', 'center') def test_swapcase(self): @@ -252,6 +495,158 @@ self.checkraises(TypeError, 'hello', 'swapcase', 42) def test_replace(self): + EQ = self.checkequal + + # Operations on the empty string + EQ("", "", "replace", "", "") + EQ("A", "", "replace", "", "A") + EQ("", "", "replace", "A", "") + EQ("", "", "replace", "A", "A") + EQ("", "", "replace", "", "", 100) + EQ("", "", "replace", "", "", sys.maxint) + + # interleave (from=="", 'to' gets inserted everywhere) + EQ("A", "A", "replace", "", "") + EQ("*A*", "A", "replace", "", "*") + EQ("*1A*1", "A", "replace", "", "*1") + EQ("*-#A*-#", "A", "replace", "", "*-#") + EQ("*-A*-A*-", "AA", "replace", "", "*-") + EQ("*-A*-A*-", "AA", "replace", "", "*-", -1) + EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxint) + EQ("*-A*-A*-", "AA", "replace", "", "*-", 4) + EQ("*-A*-A*-", "AA", "replace", "", "*-", 3) + EQ("*-A*-A", "AA", "replace", "", "*-", 2) + EQ("*-AA", "AA", "replace", "", "*-", 1) + EQ("AA", "AA", "replace", "", "*-", 0) + + # single character deletion (from=="A", to=="") + EQ("", "A", "replace", "A", "") + EQ("", "AAA", "replace", "A", "") + EQ("", "AAA", "replace", "A", "", -1) + EQ("", "AAA", "replace", "A", "", sys.maxint) + EQ("", "AAA", "replace", "A", "", 4) + EQ("", "AAA", "replace", "A", "", 3) + EQ("A", "AAA", "replace", "A", "", 2) + EQ("AA", "AAA", "replace", "A", "", 1) + EQ("AAA", "AAA", "replace", "A", "", 0) + EQ("", "AAAAAAAAAA", "replace", "A", "") + EQ("BCD", "ABACADA", "replace", "A", "") + EQ("BCD", "ABACADA", "replace", "A", "", -1) + EQ("BCD", "ABACADA", "replace", "A", "", sys.maxint) + EQ("BCD", "ABACADA", "replace", "A", "", 5) + EQ("BCD", "ABACADA", "replace", "A", "", 4) + EQ("BCDA", "ABACADA", "replace", "A", "", 3) + EQ("BCADA", "ABACADA", "replace", "A", "", 2) + EQ("BACADA", "ABACADA", "replace", "A", "", 1) + EQ("ABACADA", "ABACADA", "replace", "A", "", 0) + EQ("BCD", "ABCAD", "replace", "A", "") + EQ("BCD", "ABCADAA", "replace", "A", "") + EQ("BCD", "BCD", "replace", "A", "") + EQ("*************", "*************", "replace", "A", "") + EQ("^A^", "^"+"A"*1000+"^", "replace", "A", "", 999) + + # substring deletion (from=="the", to=="") + EQ("", "the", "replace", "the", "") + EQ("ater", "theater", "replace", "the", "") + EQ("", "thethe", "replace", "the", "") + EQ("", "thethethethe", "replace", "the", "") + EQ("aaaa", "theatheatheathea", "replace", "the", "") + EQ("that", "that", "replace", "the", "") + EQ("thaet", "thaet", "replace", "the", "") + EQ("here and re", "here and there", "replace", "the", "") + EQ("here and re and re", "here and there and there", + "replace", "the", "", sys.maxint) + EQ("here and re and re", "here and there and there", + "replace", "the", "", -1) + EQ("here and re and re", "here and there and there", + "replace", "the", "", 3) + EQ("here and re and re", "here and there and there", + "replace", "the", "", 2) + EQ("here and re and there", "here and there and there", + "replace", "the", "", 1) + EQ("here and there and there", "here and there and there", + "replace", "the", "", 0) + EQ("here and re and re", "here and there and there", "replace", "the", "") + + EQ("abc", "abc", "replace", "the", "") + EQ("abcdefg", "abcdefg", "replace", "the", "") + + # substring deletion (from=="bob", to=="") + EQ("bob", "bbobob", "replace", "bob", "") + EQ("bobXbob", "bbobobXbbobob", "replace", "bob", "") + EQ("aaaaaaa", "aaaaaaabob", "replace", "bob", "") + EQ("aaaaaaa", "aaaaaaa", "replace", "bob", "") + + # single character replace in place (len(from)==len(to)==1) + EQ("Who goes there?", "Who goes there?", "replace", "o", "o") + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O") + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxint) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2) + EQ("WhO goes there?", "Who goes there?", "replace", "o", "O", 1) + EQ("Who goes there?", "Who goes there?", "replace", "o", "O", 0) + + EQ("Who goes there?", "Who goes there?", "replace", "a", "q") + EQ("who goes there?", "Who goes there?", "replace", "W", "w") + EQ("wwho goes there?ww", "WWho goes there?WW", "replace", "W", "w") + EQ("Who goes there!", "Who goes there?", "replace", "?", "!") + EQ("Who goes there!!", "Who goes there??", "replace", "?", "!") + + EQ("Who goes there?", "Who goes there?", "replace", ".", "!") + + # substring replace in place (len(from)==len(to) > 1) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**") + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxint) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3) + EQ("Th** ** a tissue", "This is a tissue", "replace", "is", "**", 2) + EQ("Th** is a tissue", "This is a tissue", "replace", "is", "**", 1) + EQ("This is a tissue", "This is a tissue", "replace", "is", "**", 0) + EQ("cobob", "bobob", "replace", "bob", "cob") + EQ("cobobXcobocob", "bobobXbobobob", "replace", "bob", "cob") + EQ("bobob", "bobob", "replace", "bot", "bot") + + # replace single character (len(from)==1, len(to)>1) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK") + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxint) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2) + EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1) + EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0) + EQ("A----B----C----", "A.B.C.", "replace", ".", "----") + + EQ("Reykjavik", "Reykjavik", "replace", "q", "KK") + + # replace substring (len(from)>1, len(to)!=len(from)) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham") + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", sys.maxint) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", -1) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", 4) + EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", + "replace", "spam", "ham", 3) + EQ("ham, ham, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 2) + EQ("ham, spam, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 1) + EQ("spam, spam, eggs and spam", "spam, spam, eggs and spam", + "replace", "spam", "ham", 0) + + EQ("bobob", "bobobob", "replace", "bobob", "bob") + EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob") + EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby") + + ba = buffer('a') + bb = buffer('b') + EQ("bbc", "abc", "replace", ba, bb) + EQ("aac", "abc", "replace", bb, ba) + + # self.checkequal('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1) self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '') self.checkequal('one@two@three!', 'one!two!three!', 'replace', '!', '@', 2) @@ -279,6 +674,15 @@ self.checkraises(TypeError, 'hello', 'replace', 42, 'h') self.checkraises(TypeError, 'hello', 'replace', 'h', 42) + def test_replace_overflow(self): + # Check for overflow checking on 32 bit machines + if sys.maxint != 2147483647 or struct.calcsize("P") > 4: + return + A2_16 = "A" * (2**16) + self.checkraises(OverflowError, A2_16, "replace", "", A2_16) + self.checkraises(OverflowError, A2_16, "replace", "A", A2_16) + self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16) + def test_zfill(self): self.checkequal('123', '123', 'zfill', 2) self.checkequal('123', '123', 'zfill', 3) @@ -425,6 +829,21 @@ self.checkraises(TypeError, 'hello', 'startswith') self.checkraises(TypeError, 'hello', 'startswith', 42) + # test tuple arguments + self.checkequal(True, 'hello', 'startswith', ('he', 'ha')) + self.checkequal(False, 'hello', 'startswith', ('lo', 'llo')) + self.checkequal(True, 'hello', 'startswith', ('hellox', 'hello')) + self.checkequal(False, 'hello', 'startswith', ()) + self.checkequal(True, 'helloworld', 'startswith', ('hellowo', + 'rld', 'lowo'), 3) + self.checkequal(False, 'helloworld', 'startswith', ('hellowo', 'ello', + 'rld'), 3) + self.checkequal(True, 'hello', 'startswith', ('lo', 'he'), 0, -1) + self.checkequal(False, 'hello', 'startswith', ('he', 'hel'), 0, 1) + self.checkequal(True, 'hello', 'startswith', ('he', 'hel'), 0, 2) + + self.checkraises(TypeError, 'hello', 'startswith', (42,)) + def test_endswith(self): self.checkequal(True, 'hello', 'endswith', 'lo') self.checkequal(False, 'hello', 'endswith', 'he') @@ -459,6 +878,21 @@ self.checkraises(TypeError, 'hello', 'endswith') self.checkraises(TypeError, 'hello', 'endswith', 42) + # test tuple arguments + self.checkequal(False, 'hello', 'endswith', ('he', 'ha')) + self.checkequal(True, 'hello', 'endswith', ('lo', 'llo')) + self.checkequal(True, 'hello', 'endswith', ('hellox', 'hello')) + self.checkequal(False, 'hello', 'endswith', ()) + self.checkequal(True, 'helloworld', 'endswith', ('hellowo', + 'rld', 'lowo'), 3) + self.checkequal(False, 'helloworld', 'endswith', ('hellowo', 'ello', + 'rld'), 3, -1) + self.checkequal(True, 'hello', 'endswith', ('hell', 'ell'), 0, -1) + self.checkequal(False, 'hello', 'endswith', ('he', 'hel'), 0, 1) + self.checkequal(True, 'hello', 'endswith', ('he', 'hell'), 0, 4) + + self.checkraises(TypeError, 'hello', 'endswith', (42,)) + def test___contains__(self): self.checkequal(True, '', '__contains__', '') # vereq('' in '', True) self.checkequal(True, 'abc', '__contains__', '') # vereq('' in 'abc', True) @@ -478,7 +912,7 @@ self.checkequal(u'abc', 'abc', '__getitem__', slice(0, 1000)) self.checkequal(u'a', 'abc', '__getitem__', slice(0, 1)) self.checkequal(u'', 'abc', '__getitem__', slice(0, 0)) - # FIXME What about negative indizes? This is handled differently by [] and __getitem__(slice) + # FIXME What about negative indices? This is handled differently by [] and __getitem__(slice) self.checkraises(TypeError, 'abc', '__getitem__', 'def') @@ -502,13 +936,10 @@ self.checkequal('abc', 'abc', '__mul__', 1) self.checkequal('abcabcabc', 'abc', '__mul__', 3) self.checkraises(TypeError, 'abc', '__mul__') - # CPython specific; pypy tests via the operator module instead - if not test_support.is_jython: - self.checkraises(TypeError, 'abc', '__mul__', '') - else: - import operator - self.checkraises(TypeError, operator, '__mul__', 'abc', '') - self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000) + self.checkraises(TypeError, 'abc', '__mul__', '') + # XXX: on a 64-bit system, this doesn't raise an overflow error, + # but either raises a MemoryError, or succeeds (if you have 54TiB) + #self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000) def test_join(self): # join now works with any sequence type @@ -517,6 +948,8 @@ # test.test_string.StringTest.test_join) self.checkequal('a b c d', ' ', 'join', ['a', 'b', 'c', 'd']) self.checkequal('abcd', '', 'join', ('a', 'b', 'c', 'd')) + self.checkequal('bd', '', 'join', ('', 'b', '', 'd')) + self.checkequal('ac', '', 'join', ('a', '', 'c', '')) self.checkequal('w x y z', ' ', 'join', Sequence()) self.checkequal('abc', 'a', 'join', ('abc',)) self.checkequal('z', 'a', 'join', UserList(['z'])) @@ -538,6 +971,15 @@ self.checkraises(TypeError, ' ', 'join') self.checkraises(TypeError, ' ', 'join', 7) self.checkraises(TypeError, ' ', 'join', Sequence([7, 'hello', 123L])) + try: + def f(): + yield 4 + "" + self.fixtype(' ').join(f()) + except TypeError, e: + if '+' not in str(e): + self.fail('join() ate exception message') + else: + self.fail('exception not raised') def test_formatting(self): self.checkequal('+hello+', '+%s+', '__mod__', 'hello') @@ -585,12 +1027,32 @@ # unicodeobject.c uses a 120 byte buffer and switches from # 'f' formatting to 'g' at precision 50, so we expect # OverflowErrors for the ranges x < 50 and prec >= 67. - if not test_support.is_jython and x < 50 and prec >= 67: + if x < 50 and prec >= 67: self.checkraises(OverflowError, format, "__mod__", value) else: self.checkcall(format, "__mod__", value) + def test_inplace_rewrites(self): + # Check that strings don't copy and modify cached single-character strings + self.checkequal('a', 'A', 'lower') + self.checkequal(True, 'A', 'isupper') + self.checkequal('A', 'a', 'upper') + self.checkequal(True, 'a', 'islower') + + self.checkequal('a', 'A', 'replace', 'A', 'a') + self.checkequal(True, 'A', 'isupper') + + self.checkequal('A', 'a', 'capitalize') + self.checkequal(True, 'a', 'islower') + + self.checkequal('A', 'a', 'swapcase') + self.checkequal(True, 'a', 'islower') + + self.checkequal('A', 'a', 'title') + self.checkequal(True, 'a', 'islower') + def test_partition(self): + self.checkequal(('this is the par', 'ti', 'tion method'), 'this is the partition method', 'partition', 'ti') @@ -605,6 +1067,7 @@ self.checkraises(TypeError, S, 'partition', None) def test_rpartition(self): + self.checkequal(('this is the rparti', 'ti', 'on method'), 'this is the rpartition method', 'rpartition', 'ti') @@ -616,8 +1079,9 @@ self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org') self.checkraises(ValueError, S, 'rpartition', '') - self.checkraises(TypeError, S, 'rpartition', None) + self.checkraises(TypeError, S, 'rpartition', None) + class MixinStrStringUserStringTest: # Additional tests for 8bit strings, i.e. str, UserString and # the string module @@ -645,23 +1109,70 @@ # Additional tests that only work with # 8bit compatible object, i.e. str and UserString - def test_encoding_decoding(self): - codecs = [('rot13', 'uryyb jbeyq'), - ('base64', 'aGVsbG8gd29ybGQ=\n'), - ('hex', '68656c6c6f20776f726c64'), - ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')] - for encoding, data in codecs: - self.checkequal(data, 'hello world', 'encode', encoding) - self.checkequal('hello world', data, 'decode', encoding) - # zlib is optional, so we make the test optional too... - try: - import zlib - except ImportError: + if test_support.have_unicode: + def test_encoding_decoding(self): + codecs = [('rot13', 'uryyb jbeyq'), + ('base64', 'aGVsbG8gd29ybGQ=\n'), + ('hex', '68656c6c6f20776f726c64'), + ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')] + for encoding, data in codecs: + self.checkequal(data, 'hello world', 'encode', encoding) + self.checkequal('hello world', data, 'decode', encoding) + # zlib is optional, so we make the test optional too... + try: + import zlib + except ImportError: + pass + else: + data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]' + self.checkequal(data, 'hello world', 'encode', 'zlib') + self.checkequal('hello world', data, 'decode', 'zlib') + + self.checkraises(TypeError, 'xyz', 'decode', 42) + self.checkraises(TypeError, 'xyz', 'encode', 42) + + +class MixinStrUnicodeTest: + # Additional tests that only work with str and unicode. + + def test_bug1001011(self): + # Make sure join returns a NEW object for single item sequences + # involving a subclass. + # Make sure that it is of the appropriate type. + # Check the optimisation still occurs for standard objects. + t = self.type2test + class subclass(t): pass + s1 = subclass("abcd") + s2 = t().join([s1]) + self.assert_(s1 is not s2) + self.assert_(type(s2) is t) + + s1 = t("abcd") + s2 = t().join([s1]) + self.assert_(s1 is s2) + + # Should also test mixed-type join. + if t is unicode: + s1 = subclass("abcd") + s2 = "".join([s1]) + self.assert_(s1 is not s2) + self.assert_(type(s2) is t) + + s1 = t("abcd") + s2 = "".join([s1]) + self.assert_(s1 is s2) + + elif t is str: + s1 = subclass("abcd") + s2 = u"".join([s1]) + self.assert_(s1 is not s2) + self.assert_(type(s2) is unicode) # promotes! + + s1 = t("abcd") + s2 = u"".join([s1]) + self.assert_(s1 is not s2) + self.assert_(type(s2) is unicode) # promotes! + else: - data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]' - self.checkequal(data, 'hello world', 'encode', 'zlib') - self.checkequal('hello world', data, 'decode', 'zlib') - - self.checkraises(TypeError, 'xyz', 'decode', 42) - self.checkraises(TypeError, 'xyz', 'encode', 42) + self.fail("unexpected type for MixinStrUnicodeTest %r" % t) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-11 19:37:23
|
Revision: 4891 http://jython.svn.sourceforge.net/jython/?rev=4891&view=rev Author: pjenvey Date: 2008-07-11 12:37:19 -0700 (Fri, 11 Jul 2008) Log Message: ----------- test_pep263 passes now Modified Paths: -------------- branches/asm/Lib/test/regrtest.py Modified: branches/asm/Lib/test/regrtest.py =================================================================== --- branches/asm/Lib/test/regrtest.py 2008-07-11 14:05:13 UTC (rev 4890) +++ branches/asm/Lib/test/regrtest.py 2008-07-11 19:37:19 UTC (rev 4891) @@ -1489,7 +1489,6 @@ test_gc test_iterlen test_marshal - test_pep263 test_pkgimport test_profilehooks test_pyclbr This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-07-11 14:05:14
|
Revision: 4890 http://jython.svn.sourceforge.net/jython/?rev=4890&view=rev Author: zyasoft Date: 2008-07-11 07:05:13 -0700 (Fri, 11 Jul 2008) Log Message: ----------- >From PyPy's test__rawffi, broke out standard ctypes_test code they use (to avoid using their compilation toolchain). Implemented minimum to get test__rawffi.test_short_addition to pass. Modified Paths: -------------- branches/asm/Lib/_rawffi.py branches/asm/Lib/test/test__rawffi.py Added Paths: ----------- branches/asm/tests/c/ branches/asm/tests/c/ctypes_test.c Modified: branches/asm/Lib/_rawffi.py =================================================================== --- branches/asm/Lib/_rawffi.py 2008-07-11 12:45:41 UTC (rev 4889) +++ branches/asm/Lib/_rawffi.py 2008-07-11 14:05:13 UTC (rev 4890) @@ -3,19 +3,40 @@ def get_libc(): return CDLL("c") +typecode_map = {'h': 2, 'H': 2} + class Array(object): - def __init__(self): - pass + def __init__(self, typecode): + self.typecode = typecode + self.itemsize = typecode_map[typecode] + def __call__(self, size, autofree=False): + if not autofree: + raise Exception + return ArrayInstance(self, size) + +class ArrayInstance(object): + def __init__(self, shape, size): + self.shape = shape + self.alloc = jna.Memory(shape.itemsize * size) + + def __setitem__(self, index, value): + self.alloc.setShort(index, value) + + def __getitem__(self, index): + return self.alloc.getShort(index) + class FuncPtr(object): - def __init__(self, fn, arg_types, ret_type): + def __init__(self, fn, name, argtypes, restype): self.fn = fn - # decode - self.arg_types = arg_types - self.ret_type = ret_type + self.name = name + self.argtypes = argtypes + self.restype = restype def __call__(self, *args): - pass + container = Array('H')(1, autofree=True) + container[0] = self.fn.invokeInt([i[0] for i in args]) + return container class CDLL(object): def __init__(self, libname): @@ -23,14 +44,14 @@ self.cache = dict() def ptr(self, name, argtypes, restype): - fn = self.lib.getFunction(name) key = (name, tuple(argtypes), restype) try: return self.cache[key] except KeyError: - fn = FuncPtr(name, argtypes, restype) - self.cache[key] = fn - return fn + fn = self.lib.getFunction(name) + fnp = FuncPtr(fn, name, argtypes, restype) + self.cache[key] = fnp + return fnp Modified: branches/asm/Lib/test/test__rawffi.py =================================================================== --- branches/asm/Lib/test/test__rawffi.py 2008-07-11 12:45:41 UTC (rev 4889) +++ branches/asm/Lib/test/test__rawffi.py 2008-07-11 14:05:13 UTC (rev 4890) @@ -5,6 +5,7 @@ def setUp(self): self.libc_name = "c" + self.lib_name = "ctypes_test" def test_libload(self): import _rawffi @@ -23,6 +24,21 @@ assert isinstance(func, _rawffi.FuncPtr) self.assertRaises(AttributeError, getattr, libc, "xxx") + def test_short_addition(self): + import _rawffi + lib = _rawffi.CDLL(self.lib_name) + short_add = lib.ptr('add_shorts', ['h', 'h'], 'H') + A = _rawffi.Array('h') + arg1 = A(1, autofree=True) + arg2 = A(1, autofree=True) + arg1[0] = 1 + arg2[0] = 2 + res = short_add(arg1, arg2) + assert res[0] == 3 + # this does not apply to this version of memory allocation + #arg1.free() + #arg2.free() + def test_main(): tests = [RawFFITestCase, ] Added: branches/asm/tests/c/ctypes_test.c =================================================================== --- branches/asm/tests/c/ctypes_test.c (rev 0) +++ branches/asm/tests/c/ctypes_test.c 2008-07-11 14:05:13 UTC (rev 4890) @@ -0,0 +1,126 @@ + #include <stdlib.h> + #include <stdio.h> + + struct x + { + int x1; + short x2; + char x3; + struct x* next; + }; + + void nothing() + { + } + + char inner_struct_elem(struct x *x1) + { + return x1->next->x3; + } + + struct x* create_double_struct() + { + struct x* x1, *x2; + + x1 = (struct x*)malloc(sizeof(struct x)); + x2 = (struct x*)malloc(sizeof(struct x)); + x1->next = x2; + x2->x2 = 3; + return x1; + } + + void free_double_struct(struct x* x1) + { + free(x1->next); + free(x1); + } + + const char *static_str = "xxxxxx"; + const long static_int = 42; + const double static_double = 42.42; + + unsigned short add_shorts(short one, short two) + { + return one + two; + } + + void* get_raw_pointer() + { + return (void*)add_shorts; + } + + char get_char(char* s, unsigned short num) + { + return s[num]; + } + + char *char_check(char x, char y) + { + if (y == static_str[0]) + return static_str; + return NULL; + } + + int get_array_elem(int* stuff, int num) + { + return stuff[num]; + } + + struct x* get_array_elem_s(struct x** array, int num) + { + return array[num]; + } + + long long some_huge_value() + { + return 1LL<<42; + } + + unsigned long long some_huge_uvalue() + { + return 1LL<<42; + } + + long long pass_ll(long long x) + { + return x; + } + + static int prebuilt_array1[] = {3}; + + int* allocate_array() + { + return prebuilt_array1; + } + + long long runcallback(long long(*callback)()) + { + return callback(); + } + + struct x_y { + long x; + long y; + }; + + long sum_x_y(struct x_y s) { + return s.x + s.y; + } + + struct s2h { + short x; + short y; + }; + + struct s2h give(short x, short y) { + struct s2h out; + out.x = x; + out.y = y; + return out; + } + + struct s2h perturb(struct s2h inp) { + inp.x *= 2; + inp.y *= 3; + return inp; + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-07-11 12:45:42
|
Revision: 4889 http://jython.svn.sourceforge.net/jython/?rev=4889&view=rev Author: fwierzbicki Date: 2008-07-11 05:45:41 -0700 (Fri, 11 Jul 2008) Log Message: ----------- added svnant-jars by default for more convenient full-build. Fixed jarjar and jar-complete (so jarjar only recompiles on changes and jar-complete properly depends on jarjar). Modified Paths: -------------- branches/asm/build.xml Added Paths: ----------- branches/asm/extlibs/svnant-jars/ branches/asm/extlibs/svnant-jars/svnClientAdapter.jar branches/asm/extlibs/svnant-jars/svnant.jar branches/asm/extlibs/svnant-jars/svnjavahl.jar Modified: branches/asm/build.xml =================================================================== --- branches/asm/build.xml 2008-07-11 12:16:28 UTC (rev 4888) +++ branches/asm/build.xml 2008-07-11 12:45:41 UTC (rev 4889) @@ -127,7 +127,6 @@ <target name="full-build" depends="full-check, install" description="a full build with svn checkout" /> <target name="needed-check" unless="full-build"> - <echo message="check needed"/> <uptodate property="jarjar.notneeded" targetfile="${output.dir}/jarjar.jar"> <srcfiles dir="extlibs" includes="*" /> </uptodate> @@ -229,6 +228,8 @@ <property file="${user.home}/ant.properties" /> <property file="${basedir}/ant.properties" /> + <property name="svnant.jar.dir" value="${basedir}/extlibs/svnant-jars" /> + <!-- use this property to distinguish a full-build from a developer-build --> <property name="full-build" value="true" /> @@ -540,7 +541,7 @@ </unjar> </target> - <target name="jar-complete" depends="jarjar,compile,expose"> + <target name="jar-complete" depends="compile,expose,jarjar"> <jar destfile="${dist.dir}/jython-complete.jar"> <fileset dir="${compile.dir}"/> <fileset dir="${exposed.dir}"/> Added: branches/asm/extlibs/svnant-jars/svnClientAdapter.jar =================================================================== (Binary files differ) Property changes on: branches/asm/extlibs/svnant-jars/svnClientAdapter.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/asm/extlibs/svnant-jars/svnant.jar =================================================================== (Binary files differ) Property changes on: branches/asm/extlibs/svnant-jars/svnant.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: branches/asm/extlibs/svnant-jars/svnjavahl.jar =================================================================== (Binary files differ) Property changes on: branches/asm/extlibs/svnant-jars/svnjavahl.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-07-11 12:16:31
|
Revision: 4888 http://jython.svn.sourceforge.net/jython/?rev=4888&view=rev Author: zyasoft Date: 2008-07-11 05:16:28 -0700 (Fri, 11 Jul 2008) Log Message: ----------- Begin port of PyPy's _rawffi, which with their pure-Python ctypes wrapper, implements ctypes Added Paths: ----------- branches/asm/Lib/_rawffi.py branches/asm/Lib/test/test__rawffi.py Added: branches/asm/Lib/_rawffi.py =================================================================== --- branches/asm/Lib/_rawffi.py (rev 0) +++ branches/asm/Lib/_rawffi.py 2008-07-11 12:16:28 UTC (rev 4888) @@ -0,0 +1,36 @@ +import com.sun.jna as jna + +def get_libc(): + return CDLL("c") + +class Array(object): + def __init__(self): + pass + +class FuncPtr(object): + def __init__(self, fn, arg_types, ret_type): + self.fn = fn + # decode + self.arg_types = arg_types + self.ret_type = ret_type + + def __call__(self, *args): + pass + +class CDLL(object): + def __init__(self, libname): + self.lib = jna.NativeLibrary.getInstance(libname) + self.cache = dict() + + def ptr(self, name, argtypes, restype): + fn = self.lib.getFunction(name) + key = (name, tuple(argtypes), restype) + try: + return self.cache[key] + except KeyError: + fn = FuncPtr(name, argtypes, restype) + self.cache[key] = fn + return fn + + + Added: branches/asm/Lib/test/test__rawffi.py =================================================================== --- branches/asm/Lib/test/test__rawffi.py (rev 0) +++ branches/asm/Lib/test/test__rawffi.py 2008-07-11 12:16:28 UTC (rev 4888) @@ -0,0 +1,32 @@ +import unittest +from test import test_support + +class RawFFITestCase(unittest.TestCase): + + def setUp(self): + self.libc_name = "c" + + def test_libload(self): + import _rawffi + _rawffi.CDLL(self.libc_name) + + def test_libc_load(self): + import _rawffi + _rawffi.get_libc() + + def test_getattr(self): + import _rawffi + libc = _rawffi.get_libc() + func = libc.ptr('rand', [], 'i') + assert libc.ptr('rand', [], 'i') is func # caching + assert libc.ptr('rand', [], 'l') is not func + assert isinstance(func, _rawffi.FuncPtr) + self.assertRaises(AttributeError, getattr, libc, "xxx") + +def test_main(): + tests = [RawFFITestCase, + ] + test_support.run_unittest(*tests) + +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...> - 2008-07-11 11:52:57
|
Revision: 4887 http://jython.svn.sourceforge.net/jython/?rev=4887&view=rev Author: fwierzbicki Date: 2008-07-11 04:52:55 -0700 (Fri, 11 Jul 2008) Log Message: ----------- move "not needed" checks into separate task because all such tasks *are* needed during a full build regardless of up to date status of files. Modified Paths: -------------- branches/asm/build.xml Modified: branches/asm/build.xml =================================================================== --- branches/asm/build.xml 2008-07-11 04:05:51 UTC (rev 4886) +++ branches/asm/build.xml 2008-07-11 11:52:55 UTC (rev 4887) @@ -126,6 +126,16 @@ <target name="full-build" depends="full-check, install" description="a full build with svn checkout" /> + <target name="needed-check" unless="full-build"> + <echo message="check needed"/> + <uptodate property="jarjar.notneeded" targetfile="${output.dir}/jarjar.jar"> + <srcfiles dir="extlibs" includes="*" /> + </uptodate> + <uptodate property="antlr.notneeded" targetfile="${dist.dir}/jython.jar"> + <srcfiles dir="grammar" includes="*.g" /> + </uptodate> + </target> + <target name="init" depends="version-init"> <property name="build.compiler" value="modern" /> <property name="jdk.target.version" value="1.5" /> @@ -183,12 +193,6 @@ <pathelement path="${exposed.dir}" /> <pathelement path="${compile.dir}" /> </path> - <uptodate property="jarjar.notneeded" targetfile="${output.dir}/jarjar.jar"> - <srcfiles dir="extlibs" includes="*" /> - </uptodate> - <uptodate property="antlr.notneeded" targetfile="${dist.dir}/jython.jar"> - <srcfiles dir="grammar" includes="*.g" /> - </uptodate> </target> <target name="version-init"> @@ -432,7 +436,7 @@ lazy="${templates.lazy}"/> </target> - <target name="antlr_gen" depends="init,prepare-output" unless="antlr.notneeded"> + <target name="antlr_gen" depends="init,needed-check,prepare-output" unless="antlr.notneeded"> <java classname="org.antlr.Tool" failonerror="true"> <arg value="-fo"/> <arg path="build/gensrc/org/python/antlr"/> @@ -515,7 +519,8 @@ destdir="${exposed.dir}" includesfile="${jython.base.dir}/CoreExposed.includes"/> </target> - <target name="jarjar" depends="init" > + + <target name="jarjar" depends="init,needed-check" unless="jarjar.notneeded"> <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="extlibs/jarjar-0.7.jar"/> <jarjar destfile="${output.dir}/jarjar.jar"> <zipfileset src="extlibs/antlr-runtime-3.1b1.jar"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-11 04:05:52
|
Revision: 4886 http://jython.svn.sourceforge.net/jython/?rev=4886&view=rev Author: pjenvey Date: 2008-07-10 21:05:51 -0700 (Thu, 10 Jul 2008) Log Message: ----------- preserve and escape strptime format characters that aren't SimpleDateFormat directives Modified Paths: -------------- trunk/jython/src/org/python/modules/time/Time.java Modified: trunk/jython/src/org/python/modules/time/Time.java =================================================================== --- trunk/jython/src/org/python/modules/time/Time.java 2008-07-11 03:46:09 UTC (rev 4885) +++ trunk/jython/src/org/python/modules/time/Time.java 2008-07-11 04:05:51 UTC (rev 4886) @@ -17,6 +17,7 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.HashMap; import java.util.Locale; import java.util.TimeZone; import java.text.ParseException; @@ -702,31 +703,62 @@ private static final String DEFAULT_FORMAT_PY = "%a %b %d %H:%M:%S %Y"; private static final String DEFAULT_FORMAT_JA = "EEE MMM dd HH:mm:ss zzz yyyy"; + private static final HashMap<Character, String> py2java = new HashMap<Character, String>() {{ + put('a', "EEE"); + put('A', "EEEE"); + put('b', "MMM"); + put('B', "MMMM"); + put('c', "EEE MMM dd HH:mm:ss yyyy"); + put('d', "dd"); + put('H', "HH"); + put('I', "kk"); + put('j', "DDD"); + put('m', "MM"); + put('M', "mm"); + put('p', "a"); + put('S', "ss"); + put('U', "ww"); + put('w', "0"); // unsupported in java + put('W', "ww"); // same as U ?? + put('x', "MM/dd/yy"); + put('X', "HH:mm:ss"); + put('y', "yy"); + put('Y', "yyyy"); + put('Z', "zzz"); + put('%', "%"); + }}; + private static String py2java_format(String format) { - format = format - .replaceAll("%a", "EEE") - .replaceAll("%A", "EEEE") - .replaceAll("%b", "MMM") - .replaceAll("%B", "MMMM") - .replaceAll("%c", "EEE MMM dd HH:mm:ss yyyy") - .replaceAll("%d", "dd") - .replaceAll("%H", "HH") - .replaceAll("%I", "kk") - .replaceAll("%j", "DDD") - .replaceAll("%m", "MM") - .replaceAll("%M", "mm") - .replaceAll("%p", "a") - .replaceAll("%S", "ss") - .replaceAll("%U", "ww") - .replaceAll("%w", "0") // unsupported in java - .replaceAll("%W", "ww") // same as %U ?? - .replaceAll("%x", "MM/dd/yy") - .replaceAll("%X", "HH:mm:ss") - .replaceAll("%y", "yy") - .replaceAll("%Y", "yyyy") - .replaceAll("%Z", "zzz") - .replaceAll("%%", "%") - ; - return format; + StringBuilder builder = new StringBuilder(); + boolean directive = false; + boolean inQuote = false; + + for (int i = 0; i < format.length(); i++) { + char charAt = format.charAt(i); + + if (charAt == '%' && !directive) { + directive = true; + continue; + } + + if (!directive) { + // ascii letters are considered SimpleDateFormat directive patterns unless + // escaped + boolean needsQuote = charAt >= 'A' && charAt <= 'z'; + if (needsQuote && !inQuote || !needsQuote && inQuote) { + builder.append("'"); + inQuote = needsQuote; + } + builder.append(charAt); + continue; + } else if (inQuote) { + builder.append("'"); + } + + String translated = py2java.get(charAt); + builder.append(translated != null ? translated : charAt); + directive = false; + } + return builder.toString(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-11 03:46:16
|
Revision: 4885 http://jython.svn.sourceforge.net/jython/?rev=4885&view=rev Author: pjenvey Date: 2008-07-10 20:46:09 -0700 (Thu, 10 Jul 2008) Log Message: ----------- add a -j option to regrtest for capturing test output to JUnit XML files (one file per TestCase or module import or doctest) in the specified dir Modified Paths: -------------- branches/asm/Lib/test/regrtest.py branches/asm/Lib/test/test_support.py Added Paths: ----------- branches/asm/Lib/test/junit_xml.py Added: branches/asm/Lib/test/junit_xml.py =================================================================== --- branches/asm/Lib/test/junit_xml.py (rev 0) +++ branches/asm/Lib/test/junit_xml.py 2008-07-11 03:46:09 UTC (rev 4885) @@ -0,0 +1,278 @@ +"""Support for writing JUnit XML test results for the regrtest""" +import os +import re +import sys +import time +import traceback +import unittest +from StringIO import StringIO +from xml.sax import saxutils + +# Invalid XML characters (control chars) +EVIL_CHARACTERS_RE = re.compile(r"[\000-\010\013\014\016-\037]") + +class JUnitXMLTestRunner: + + """A unittest runner that writes results to a JUnit XML file in + xml_dir + """ + + def __init__(self, xml_dir): + self.xml_dir = xml_dir + + def run(self, test): + result = JUnitXMLTestResult(self.xml_dir) + test(result) + result.write_xml() + return result + + +class JUnitXMLTestResult(unittest.TestResult): + + """JUnit XML test result writer. + + The name of the file written to is determined from the full module + name of the first test ran + """ + + def __init__(self, xml_dir): + unittest.TestResult.__init__(self) + self.xml_dir = xml_dir + + # The module name of the first test ran + self.module_name = None + + # All TestCases + self.tests = [] + + # Start time + self.start = None + + self.old_stdout = sys.stdout + self.old_stderr = sys.stderr + sys.stdout = self.stdout = Tee(sys.stdout) + sys.stderr = self.stderr = Tee(sys.stderr) + + def startTest(self, test): + unittest.TestResult.startTest(self, test) + self.ensure_module_name(test) + self.error, self.failure = None, None + self.start = time.time() + + def stopTest(self, test): + took = time.time() - self.start + unittest.TestResult.stopTest(self, test) + args = [test, took] + if self.error: + args.extend(['error', self.error]) + elif self.failure: + args.extend(['failure', self.failure]) + self.tests.append(TestInfo.from_testcase(*args)) + + def addError(self, test, err): + unittest.TestResult.addError(self, test, err) + self.error = err + + def addFailure(self, test, err): + unittest.TestResult.addFailure(self, test, err) + self.failure = err + + def ensure_module_name(self, test): + """Set self.module_name from test if not already set""" + if not self.module_name: + self.module_name = '.'.join(test.id().split('.')[:-1]) + + def write_xml(self): + if not self.module_name: + # No tests ran, nothing to write + return + took = time.time() - self.start + + stdout = self.stdout.getvalue() + stderr = self.stderr.getvalue() + sys.stdout = self.old_stdout + sys.stderr = self.old_stderr + + ensure_dir(self.xml_dir) + filename = os.path.join(self.xml_dir, 'TEST-%s.xml' % self.module_name) + stream = open(filename, 'w') + + write_testsuite_xml(stream, len(self.tests), len(self.errors), + len(self.failures), 0, self.module_name, took) + + for info in self.tests: + info.write_xml(stream) + + write_stdouterr_xml(stream, stdout, stderr) + + stream.write('</testsuite>') + stream.close() + + +class TestInfo(object): + + """The JUnit XML <testcase/> model.""" + + def __init__(self, name, took, type=None, exc_info=None): + # The name of the test + self.name = name + + # How long it took + self.took = took + + # Type of test: 'error', 'failure' 'skipped', or None for a + # success + self.type = type + + if exc_info: + self.exc_name = exc_name(exc_info) + self.message = exc_message(exc_info) + self.traceback = safe_str(''.join( + traceback.format_exception(*exc_info))) + else: + self.exc_name = self.message = self.traceback = '' + + @classmethod + def from_testcase(cls, testcase, took, type=None, exc_info=None): + name = testcase.id().split('.')[-1] + return cls(name, took, type, exc_info) + + def write_xml(self, stream): + stream.write(' <testcase name="%s" time="%.3f"' % (self.name, + self.took)) + + if not self.type: + # test was successful + stream.write('/>\n') + return + + stream.write('>\n <%s type="%s" message=%s><![CDATA[%s]]></%s>\n' % + (self.type, self.exc_name, saxutils.quoteattr(self.message), + escape_cdata(self.traceback), self.type)) + stream.write(' </testcase>\n') + + +class Tee(StringIO): + + """Writes data to this StringIO and a separate stream""" + + def __init__(self, stream): + StringIO.__init__(self) + self.stream = stream + + def write(self, data): + StringIO.write(self, data) + self.stream.write(data) + + def flush(self): + StringIO.flush(self) + self.stream.flush() + + +def write_testsuite_xml(stream, tests, errors, failures, skipped, name, took): + """Write the XML header (<testsuite/>)""" + stream.write('<?xml version="1.0" encoding="utf-8"?>\n') + stream.write('<testsuite tests="%d" errors="%d" failures="%d" ' % + (tests, errors, failures)) + stream.write('skipped="%d" name="%s" time="%.3f">\n' % (skipped, name, + took)) + +def write_stdouterr_xml(stream, stdout, stderr): + """Write the stdout/err tags""" + if stdout: + stream.write(' <system-out><![CDATA[%s]]></system-out>\n' % + escape_cdata(safe_str(stdout))) + if stderr: + stream.write(' <system-err><![CDATA[%s]]></system-err>\n' % + escape_cdata(safe_str(stderr))) + + +def write_direct_test(junit_xml_dir, name, took, type=None, exc_info=None, + stdout=None, stderr=None): + """Write XML for a regrtest 'direct' test; a test which was ran on + import (which we label as __main__.__import__) + """ + return write_manual_test(junit_xml_dir, '%s.__main__' % name, '__import__', + took, type, exc_info, stdout, stderr) + + +def write_doctest(junit_xml_dir, name, took, type=None, exc_info=None, + stdout=None, stderr=None): + """Write XML for a regrtest doctest, labeled as __main__.__doc__""" + return write_manual_test(junit_xml_dir, '%s.__main__' % name, '__doc__', + took, type, exc_info, stdout, stderr) + + +def write_manual_test(junit_xml_dir, module_name, test_name, took, type=None, + exc_info=None, stdout=None, stderr=None): + """Manually write XML for one test, outside of unittest""" + errors = type == 'error' and 1 or 0 + failures = type == 'failure' and 1 or 0 + skipped = type == 'skipped' and 1 or 0 + + ensure_dir(junit_xml_dir) + stream = open(os.path.join(junit_xml_dir, 'TEST-%s.xml' % module_name), + 'w') + + write_testsuite_xml(stream, 1, errors, failures, skipped, module_name, + took) + + info = TestInfo(test_name, took, type, exc_info) + info.write_xml(stream) + + write_stdouterr_xml(stream, stdout, stderr) + + stream.write('</testsuite>') + stream.close() + + +def ensure_dir(dir): + """Ensure dir exists""" + if not os.path.exists(dir): + os.mkdir(dir) + + +def exc_name(exc_info): + """Determine the full name of the exception that caused exc_info""" + exc = exc_info[1] + name = getattr(exc.__class__, '__module__', '') + if name: + name += '.' + return name + exc.__class__.__name__ + + +def exc_message(exc_info): + """Safely return a short message passed through safe_str describing + exc_info, being careful of unicode values. + """ + exc = exc_info[1] + if exc is None: + return safe_str(exc_info[0]) + if isinstance(exc, BaseException) and isinstance(exc.message, unicode): + return safe_str(exc.message) + try: + return safe_str(str(exc)) + except UnicodeEncodeError: + try: + val = unicode(exc) + return safe_str(val) + except UnicodeDecodeError: + return '?' + + +def escape_cdata(cdata): + """Escape a string for an XML CDATA section""" + return cdata.replace(']]>', ']]>]]><![CDATA[') + + +def safe_str(base): + """Return a str valid for UTF-8 XML from a basestring""" + if isinstance(base, unicode): + return remove_evil(base.encode('utf-8', 'replace')) + return remove_evil(base.decode('utf-8', 'replace').encode('utf-8', + 'replace')) + + +def remove_evil(string): + """Remove control characters from a string""" + return EVIL_CHARACTERS_RE.sub('?', string) Modified: branches/asm/Lib/test/regrtest.py =================================================================== --- branches/asm/Lib/test/regrtest.py 2008-07-11 03:36:29 UTC (rev 4884) +++ branches/asm/Lib/test/regrtest.py 2008-07-11 03:46:09 UTC (rev 4885) @@ -16,6 +16,7 @@ -s: single -- run only a single test (see below) -r: random -- randomize test execution order -m: memo -- save results to file +-j: junit-xml -- save results as JUnit XML to files in directory -f: fromfile -- read names of tests to run from a file (see below) -l: findleaks -- if GC is available detect tests that leak memory -u: use -- specify which special resource intensive tests to run @@ -131,6 +132,7 @@ import re import cStringIO import traceback +import time # I see no other way to suppress these warnings; # putting them in test_grammar.py has no effect: @@ -181,7 +183,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', - runleaks=False, huntrleaks=False, verbose2=False, expected=False, memo=None): + runleaks=False, huntrleaks=False, verbose2=False, expected=False, + memo=None, junit_xml=None): """Execute a test suite. This also parses command-line options and modifies its behavior @@ -206,7 +209,7 @@ test_support.record_original_stdout(sys.stdout) try: - opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:TD:NLR:wM:em:', + opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:TD:NLR:wM:emj:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=', 'trace', @@ -251,6 +254,8 @@ runleaks = True elif o in ('-m', '--memo'): memo = a + elif o in ('-j', '--junit-xml'): + junit_xml = a elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) @@ -365,6 +370,7 @@ trace=False, count=True) test_support.verbose = verbose # Tell tests to be moderately quiet test_support.use_resources = use_resources + test_support.junit_xml_dir = junit_xml save_modules = sys.modules.keys() skips = _ExpectedSkips() failures = _ExpectedFailures() @@ -382,7 +388,7 @@ else: try: ok = runtest(test, generate, verbose, quiet, testdir, - huntrleaks) + huntrleaks, junit_xml) except KeyboardInterrupt: # print a newline separate from the ^C print @@ -506,7 +512,8 @@ tests.sort() return stdtests + tests -def runtest(test, generate, verbose, quiet, testdir=None, huntrleaks=False): +def runtest(test, generate, verbose, quiet, testdir=None, huntrleaks=False, + junit_xml=None): """Run a single test. test -- the name of the test @@ -526,12 +533,12 @@ try: return runtest_inner(test, generate, verbose, quiet, testdir, - huntrleaks) + huntrleaks, junit_xml) finally: cleanup_test_droppings(test, verbose) def runtest_inner(test, generate, verbose, quiet, - testdir=None, huntrleaks=False): + testdir=None, huntrleaks=False, junit_xml_dir=None): test_support.unload(test) if not testdir: testdir = findtestdir() @@ -544,6 +551,12 @@ try: save_stdout = sys.stdout + if junit_xml_dir: + from test.junit_xml import Tee, write_direct_test + indirect_test = None + save_stderr = sys.stderr + sys.stdout = stdout = Tee(sys.stdout) + sys.stderr = stderr = Tee(sys.stderr) try: if cfp: sys.stdout = cfp @@ -553,6 +566,7 @@ else: # Always import it from the test package abstest = 'test.' + test + start = time.time() the_package = __import__(abstest, globals(), locals(), []) the_module = getattr(the_package, test) # Most tests run to completion simply as a side-effect of @@ -562,25 +576,46 @@ indirect_test = getattr(the_module, "test_main", None) if indirect_test is not None: indirect_test() + elif junit_xml_dir: + write_direct_test(junit_xml_dir, abstest, time.time() - start, + stdout=stdout.getvalue(), + stderr=stderr.getvalue()) if huntrleaks: dash_R(the_module, test, indirect_test, huntrleaks) finally: sys.stdout = save_stdout + if junit_xml_dir: + sys.stderr = save_stderr except test_support.ResourceDenied, msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() + if junit_xml_dir: + write_direct_test(junit_xml_dir, abstest, time.time() - start, + 'skipped', sys.exc_info(), + stdout=stdout.getvalue(), + stderr=stderr.getvalue()) return -2 except (ImportError, test_support.TestSkipped), msg: if not quiet: print test, "skipped --", msg sys.stdout.flush() + if junit_xml_dir: + write_direct_test(junit_xml_dir, abstest, time.time() - start, + 'skipped', sys.exc_info(), + stdout=stdout.getvalue(), + stderr=stderr.getvalue()) return -1 except KeyboardInterrupt: raise except test_support.TestFailed, msg: print "test", test, "failed --", msg sys.stdout.flush() + if junit_xml_dir and indirect_test is None: + write_direct_test(junit_xml_dir, abstest, time.time() - start, + 'failure', sys.exc_info(), + stdout=stdout.getvalue(), + stderr=stderr.getvalue()) return 0 except: type, value = sys.exc_info()[:2] @@ -589,6 +624,11 @@ if verbose: traceback.print_exc(file=sys.stdout) sys.stdout.flush() + if junit_xml_dir and indirect_test is None: + write_direct_test(junit_xml_dir, abstest, time.time() - start, + 'error', sys.exc_info(), + stdout=stdout.getvalue(), + stderr=stderr.getvalue()) return 0 else: if not cfp: Modified: branches/asm/Lib/test/test_support.py =================================================================== --- branches/asm/Lib/test/test_support.py 2008-07-11 03:36:29 UTC (rev 4884) +++ branches/asm/Lib/test/test_support.py 2008-07-11 03:46:09 UTC (rev 4885) @@ -4,6 +4,7 @@ raise ImportError, 'test_support must be imported from the test package' import sys +import time class Error(Exception): """Base class for regression test exceptions.""" @@ -31,6 +32,7 @@ verbose = 1 # Flag set to 0 by regrtest.py use_resources = None # Flag set to [] by regrtest.py +junit_xml_dir = None # Option set by regrtest.py max_memuse = 0 # Disable bigmem tests (they will still be run with # small sizes, to make sure they work.) @@ -414,8 +416,30 @@ def run_suite(suite, testclass=None): + """Run all TestCases in their own individual TestSuite""" + if not junit_xml_dir: + # Splitting tests apart slightly changes the handling of the + # TestFailed message + return _run_suite(suite, testclass) + + failed = False + for test in suite: + suite = unittest.TestSuite() + suite.addTest(test) + try: + _run_suite(suite, testclass) + except TestFailed, e: + if not failed: + failed = e + if failed: + raise failed + +def _run_suite(suite, testclass=None): """Run tests from a unittest.TestSuite-derived class.""" - if verbose: + if junit_xml_dir: + from junit_xml import JUnitXMLTestRunner + runner = JUnitXMLTestRunner(junit_xml_dir) + elif verbose: runner = unittest.TextTestRunner(sys.stdout, verbosity=2) else: runner = BasicTestRunner() @@ -473,12 +497,36 @@ # output shouldn't be compared by regrtest. save_stdout = sys.stdout sys.stdout = get_original_stdout() + + if junit_xml_dir: + from junit_xml import Tee, write_doctest + save_stderr = sys.stderr + sys.stdout = stdout = Tee(sys.stdout) + sys.stderr = stderr = Tee(sys.stderr) + try: - f, t = doctest.testmod(module, verbose=verbosity) + start = time.time() + try: + f, t = doctest.testmod(module, verbose=verbosity) + except: + took = time.time() - start + if junit_xml_dir: + write_doctest(junit_xml_dir, module.__name__, took, 'error', + sys.exc_info(), stdout.getvalue(), + stderr.getvalue()) + raise + took = time.time() - start if f: + if junit_xml_dir: + write_doctest(junit_xml_dir, module.__name__, took, 'failure', + stdout=stdout.getvalue(), + stderr=stderr.getvalue()) raise TestFailed("%d of %d doctests failed" % (f, t)) finally: sys.stdout = save_stdout + if junit_xml_dir: + write_doctest(junit_xml_dir, module.__name__, took, + stdout=stdout.getvalue(), stderr=stderr.getvalue()) if verbose: print 'doctest (%s) ... %d tests with zero failures' % (module.__name__, t) return f, t This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-11 03:36:39
|
Revision: 4884 http://jython.svn.sourceforge.net/jython/?rev=4884&view=rev Author: pjenvey Date: 2008-07-10 20:36:29 -0700 (Thu, 10 Jul 2008) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_support.py@60337 Added Paths: ----------- branches/asm/Lib/test/test_support.py Added: branches/asm/Lib/test/test_support.py =================================================================== --- branches/asm/Lib/test/test_support.py (rev 0) +++ branches/asm/Lib/test/test_support.py 2008-07-11 03:36:29 UTC (rev 4884) @@ -0,0 +1,527 @@ +"""Supporting definitions for the Python regression tests.""" + +if __name__ != 'test.test_support': + raise ImportError, 'test_support must be imported from the test package' + +import sys + +class Error(Exception): + """Base class for regression test exceptions.""" + +class TestFailed(Error): + """Test failed.""" + +class TestSkipped(Error): + """Test skipped. + + This can be raised to indicate that a test was deliberatly + skipped, but not because a feature wasn't available. For + example, if some resource can't be used, such as the network + appears to be unavailable, this should be raised instead of + TestFailed. + """ + +class ResourceDenied(TestSkipped): + """Test skipped because it requested a disallowed resource. + + This is raised when a test calls requires() for a resource that + has not be enabled. It is used to distinguish between expected + and unexpected skips. + """ + +verbose = 1 # Flag set to 0 by regrtest.py +use_resources = None # Flag set to [] by regrtest.py +max_memuse = 0 # Disable bigmem tests (they will still be run with + # small sizes, to make sure they work.) + +# _original_stdout is meant to hold stdout at the time regrtest began. +# This may be "the real" stdout, or IDLE's emulation of stdout, or whatever. +# The point is to have some flavor of stdout the user can actually see. +_original_stdout = None +def record_original_stdout(stdout): + global _original_stdout + _original_stdout = stdout + +def get_original_stdout(): + return _original_stdout or sys.stdout + +def unload(name): + try: + del sys.modules[name] + except KeyError: + pass + +def unlink(filename): + import os + try: + os.unlink(filename) + except OSError: + pass + +def forget(modname): + '''"Forget" a module was ever imported by removing it from sys.modules and + deleting any .pyc and .pyo files.''' + unload(modname) + import os + for dirname in sys.path: + unlink(os.path.join(dirname, modname + os.extsep + 'pyc')) + # Deleting the .pyo file cannot be within the 'try' for the .pyc since + # the chance exists that there is no .pyc (and thus the 'try' statement + # is exited) but there is a .pyo file. + unlink(os.path.join(dirname, modname + os.extsep + 'pyo')) + +def is_resource_enabled(resource): + """Test whether a resource is enabled. Known resources are set by + regrtest.py.""" + return use_resources is not None and resource in use_resources + +def requires(resource, msg=None): + """Raise ResourceDenied if the specified resource is not available. + + If the caller's module is __main__ then automatically return True. The + possibility of False being returned occurs when regrtest.py is executing.""" + # see if the caller's module is __main__ - if so, treat as if + # the resource was set + if sys._getframe().f_back.f_globals.get("__name__") == "__main__": + return + if not is_resource_enabled(resource): + if msg is None: + msg = "Use of the `%s' resource not enabled" % resource + raise ResourceDenied(msg) + +def bind_port(sock, host='', preferred_port=54321): + """Try to bind the sock to a port. If we are running multiple + tests and we don't try multiple ports, the test can fails. This + makes the test more robust.""" + + import socket, errno + + # Find some random ports that hopefully no one is listening on. + # Ideally each test would clean up after itself and not continue listening + # on any ports. However, this isn't the case. The last port (0) is + # a stop-gap that asks the O/S to assign a port. Whenever the warning + # message below is printed, the test that is listening on the port should + # be fixed to close the socket at the end of the test. + # Another reason why we can't use a port is another process (possibly + # another instance of the test suite) is using the same port. + for port in [preferred_port, 9907, 10243, 32999, 0]: + try: + sock.bind((host, port)) + if port == 0: + port = sock.getsockname()[1] + return port + except socket.error, (err, msg): + if err != errno.EADDRINUSE: + raise + print >>sys.__stderr__, \ + ' WARNING: failed to listen on port %d, trying another' % port + raise TestFailed, 'unable to find port to listen on' + +FUZZ = 1e-6 + +def fcmp(x, y): # fuzzy comparison function + if type(x) == type(0.0) or type(y) == type(0.0): + try: + x, y = coerce(x, y) + fuzz = (abs(x) + abs(y)) * FUZZ + if abs(x-y) <= fuzz: + return 0 + except: + pass + elif type(x) == type(y) and type(x) in (type(()), type([])): + for i in range(min(len(x), len(y))): + outcome = fcmp(x[i], y[i]) + if outcome != 0: + return outcome + return cmp(len(x), len(y)) + return cmp(x, y) + +try: + unicode + have_unicode = 1 +except NameError: + have_unicode = 0 + +is_jython = sys.platform.startswith('java') + +import os +# Filename used for testing +if os.name == 'java': + # Jython disallows @ in module names + TESTFN = '$test' +elif os.name == 'riscos': + TESTFN = 'testfile' +else: + TESTFN = '@test' + # Unicode name only used if TEST_FN_ENCODING exists for the platform. + if have_unicode: + # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding() + # TESTFN_UNICODE is a filename that can be encoded using the + # file system encoding, but *not* with the default (ascii) encoding + if isinstance('', unicode): + # python -U + # XXX perhaps unicode() should accept Unicode strings? + TESTFN_UNICODE = "@test-\xe0\xf2" + else: + # 2 latin characters. + TESTFN_UNICODE = unicode("@test-\xe0\xf2", "latin-1") + TESTFN_ENCODING = sys.getfilesystemencoding() + # TESTFN_UNICODE_UNENCODEABLE is a filename that should *not* be + # able to be encoded by *either* the default or filesystem encoding. + # This test really only makes sense on Windows NT platforms + # which have special Unicode support in posixmodule. + if (not hasattr(sys, "getwindowsversion") or + sys.getwindowsversion()[3] < 2): # 0=win32s or 1=9x/ME + TESTFN_UNICODE_UNENCODEABLE = None + else: + # Japanese characters (I think - from bug 846133) + TESTFN_UNICODE_UNENCODEABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"') + try: + # XXX - Note - should be using TESTFN_ENCODING here - but for + # Windows, "mbcs" currently always operates as if in + # errors=ignore' mode - hence we get '?' characters rather than + # the exception. 'Latin1' operates as we expect - ie, fails. + # See [ 850997 ] mbcs encoding ignores errors + TESTFN_UNICODE_UNENCODEABLE.encode("Latin1") + except UnicodeEncodeError: + pass + else: + print \ + 'WARNING: The filename %r CAN be encoded by the filesystem. ' \ + 'Unicode filename tests may not be effective' \ + % TESTFN_UNICODE_UNENCODEABLE + +# Make sure we can write to TESTFN, try in /tmp if we can't +fp = None +try: + fp = open(TESTFN, 'w+') +except IOError: + TMP_TESTFN = os.path.join('/tmp', TESTFN) + try: + fp = open(TMP_TESTFN, 'w+') + TESTFN = TMP_TESTFN + del TMP_TESTFN + except IOError: + print ('WARNING: tests will fail, unable to write to: %s or %s' % + (TESTFN, TMP_TESTFN)) +if fp is not None: + fp.close() + unlink(TESTFN) +del os, fp + +def findfile(file, here=__file__): + """Try to find a file on sys.path and the working directory. If it is not + found the argument passed to the function is returned (this does not + necessarily signal failure; could still be the legitimate path).""" + import os + if os.path.isabs(file): + return file + path = sys.path + path = [os.path.dirname(here)] + path + for dn in path: + fn = os.path.join(dn, file) + if os.path.exists(fn): return fn + return file + +def verify(condition, reason='test failed'): + """Verify that condition is true. If not, raise TestFailed. + + The optional argument reason can be given to provide + a better error text. + """ + + if not condition: + raise TestFailed(reason) + +def vereq(a, b): + """Raise TestFailed if a == b is false. + + This is better than verify(a == b) because, in case of failure, the + error message incorporates repr(a) and repr(b) so you can see the + inputs. + + Note that "not (a == b)" isn't necessarily the same as "a != b"; the + former is tested. + """ + + if not (a == b): + raise TestFailed, "%r == %r" % (a, b) + +def sortdict(dict): + "Like repr(dict), but in sorted order." + items = dict.items() + items.sort() + reprpairs = ["%r: %r" % pair for pair in items] + withcommas = ", ".join(reprpairs) + return "{%s}" % withcommas + +def check_syntax(statement): + try: + compile(statement, '<string>', 'exec') + except SyntaxError: + pass + else: + print 'Missing SyntaxError: "%s"' % statement + +def open_urlresource(url): + import urllib, urlparse + import os.path + + filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL! + + for path in [os.path.curdir, os.path.pardir]: + fn = os.path.join(path, filename) + if os.path.exists(fn): + return open(fn) + + requires('urlfetch') + print >> get_original_stdout(), '\tfetching %s ...' % url + fn, _ = urllib.urlretrieve(url, filename) + return open(fn) + +#======================================================================= +# Decorator for running a function in a different locale, correctly resetting +# it afterwards. + +def run_with_locale(catstr, *locales): + def decorator(func): + def inner(*args, **kwds): + try: + import locale + category = getattr(locale, catstr) + orig_locale = locale.setlocale(category) + except AttributeError: + # if the test author gives us an invalid category string + raise + except: + # cannot retrieve original locale, so do nothing + locale = orig_locale = None + else: + for loc in locales: + try: + locale.setlocale(category, loc) + break + except: + pass + + # now run the function, resetting the locale on exceptions + try: + return func(*args, **kwds) + finally: + if locale and orig_locale: + locale.setlocale(category, orig_locale) + inner.func_name = func.func_name + inner.__doc__ = func.__doc__ + return inner + return decorator + +#======================================================================= +# Big-memory-test support. Separate from 'resources' because memory use should be configurable. + +# Some handy shorthands. Note that these are used for byte-limits as well +# as size-limits, in the various bigmem tests +_1M = 1024*1024 +_1G = 1024 * _1M +_2G = 2 * _1G + +# Hack to get at the maximum value an internal index can take. +class _Dummy: + def __getslice__(self, i, j): + return j +MAX_Py_ssize_t = _Dummy()[:] + +def set_memlimit(limit): + import re + global max_memuse + sizes = { + 'k': 1024, + 'm': _1M, + 'g': _1G, + 't': 1024*_1G, + } + m = re.match(r'(\d+(\.\d+)?) (K|M|G|T)b?$', limit, + re.IGNORECASE | re.VERBOSE) + if m is None: + raise ValueError('Invalid memory limit %r' % (limit,)) + memlimit = int(float(m.group(1)) * sizes[m.group(3).lower()]) + if memlimit > MAX_Py_ssize_t: + memlimit = MAX_Py_ssize_t + if memlimit < _2G - 1: + raise ValueError('Memory limit %r too low to be useful' % (limit,)) + max_memuse = memlimit + +def bigmemtest(minsize, memuse, overhead=5*_1M): + """Decorator for bigmem tests. + + 'minsize' is the minimum useful size for the test (in arbitrary, + test-interpreted units.) 'memuse' is the number of 'bytes per size' for + the test, or a good estimate of it. 'overhead' specifies fixed overhead, + independant of the testsize, and defaults to 5Mb. + + The decorator tries to guess a good value for 'size' and passes it to + the decorated test function. If minsize * memuse is more than the + allowed memory use (as defined by max_memuse), the test is skipped. + Otherwise, minsize is adjusted upward to use up to max_memuse. + """ + def decorator(f): + def wrapper(self): + if not max_memuse: + # If max_memuse is 0 (the default), + # we still want to run the tests with size set to a few kb, + # to make sure they work. We still want to avoid using + # too much memory, though, but we do that noisily. + maxsize = 5147 + self.failIf(maxsize * memuse + overhead > 20 * _1M) + else: + maxsize = int((max_memuse - overhead) / memuse) + if maxsize < minsize: + # Really ought to print 'test skipped' or something + if verbose: + sys.stderr.write("Skipping %s because of memory " + "constraint\n" % (f.__name__,)) + return + # Try to keep some breathing room in memory use + maxsize = max(maxsize - 50 * _1M, minsize) + return f(self, maxsize) + wrapper.minsize = minsize + wrapper.memuse = memuse + wrapper.overhead = overhead + return wrapper + return decorator + +def bigaddrspacetest(f): + """Decorator for tests that fill the address space.""" + def wrapper(self): + if max_memuse < MAX_Py_ssize_t: + if verbose: + sys.stderr.write("Skipping %s because of memory " + "constraint\n" % (f.__name__,)) + else: + return f(self) + return wrapper + +#======================================================================= +# Preliminary PyUNIT integration. + +import unittest + + +class BasicTestRunner: + def run(self, test): + result = unittest.TestResult() + test(result) + return result + + +def run_suite(suite, testclass=None): + """Run tests from a unittest.TestSuite-derived class.""" + if verbose: + runner = unittest.TextTestRunner(sys.stdout, verbosity=2) + else: + runner = BasicTestRunner() + + result = runner.run(suite) + if not result.wasSuccessful(): + if len(result.errors) == 1 and not result.failures: + err = result.errors[0][1] + elif len(result.failures) == 1 and not result.errors: + err = result.failures[0][1] + else: + if testclass is None: + msg = "errors occurred; run in verbose mode for details" + else: + msg = "errors occurred in %s.%s" \ + % (testclass.__module__, testclass.__name__) + raise TestFailed(msg) + raise TestFailed(err) + + +def run_unittest(*classes): + """Run tests from unittest.TestCase-derived classes.""" + suite = unittest.TestSuite() + for cls in classes: + if isinstance(cls, (unittest.TestSuite, unittest.TestCase)): + suite.addTest(cls) + else: + suite.addTest(unittest.makeSuite(cls)) + if len(classes)==1: + testclass = classes[0] + else: + testclass = None + run_suite(suite, testclass) + + +#======================================================================= +# doctest driver. + +def run_doctest(module, verbosity=None): + """Run doctest on the given module. Return (#failures, #tests). + + If optional argument verbosity is not specified (or is None), pass + test_support's belief about verbosity on to doctest. Else doctest's + usual behavior is used (it searches sys.argv for -v). + """ + + import doctest + + if verbosity is None: + verbosity = verbose + else: + verbosity = None + + # Direct doctest output (normally just errors) to real stdout; doctest + # output shouldn't be compared by regrtest. + save_stdout = sys.stdout + sys.stdout = get_original_stdout() + try: + f, t = doctest.testmod(module, verbose=verbosity) + if f: + raise TestFailed("%d of %d doctests failed" % (f, t)) + finally: + sys.stdout = save_stdout + if verbose: + print 'doctest (%s) ... %d tests with zero failures' % (module.__name__, t) + return f, t + +#======================================================================= +# Threading support to prevent reporting refleaks when running regrtest.py -R + +def threading_setup(): + import threading + return len(threading._active), len(threading._limbo) + +def threading_cleanup(num_active, num_limbo): + import threading + import time + + _MAX_COUNT = 10 + count = 0 + while len(threading._active) != num_active and count < _MAX_COUNT: + count += 1 + time.sleep(0.1) + + count = 0 + while len(threading._limbo) != num_limbo and count < _MAX_COUNT: + count += 1 + time.sleep(0.1) + +def reap_children(): + """Use this function at the end of test_main() whenever sub-processes + are started. This will help ensure that no extra children (zombies) + stick around to hog resources and create problems when looking + for refleaks. + """ + + # Reap all our dead child processes so we don't leave zombies around. + # These hog resources and might be causing some of the buildbots to die. + import os + if hasattr(os, 'waitpid'): + any_process = -1 + while True: + try: + # This will raise an exception on Windows. That's ok. + pid, status = os.waitpid(any_process, os.WNOHANG) + if pid == 0: + break + except: + break This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-07-10 19:51:41
|
Revision: 4883 http://jython.svn.sourceforge.net/jython/?rev=4883&view=rev Author: leosoto Date: 2008-07-10 12:51:37 -0700 (Thu, 10 Jul 2008) Log Message: ----------- zxJDBC: Map SQLExceptions to zxJDBC.IntegrityError if the sqlState says the exception was caused by a integrity violation Modified Paths: -------------- branches/asm/src/com/ziclix/python/sql/zxJDBC.java Modified: branches/asm/src/com/ziclix/python/sql/zxJDBC.java =================================================================== --- branches/asm/src/com/ziclix/python/sql/zxJDBC.java 2008-07-10 05:12:05 UTC (rev 4882) +++ branches/asm/src/com/ziclix/python/sql/zxJDBC.java 2008-07-10 19:51:37 UTC (rev 4883) @@ -331,7 +331,22 @@ * @return PyException */ public static PyException makeException(Throwable throwable) { - return makeException(Error, throwable); + PyObject type = Error; + if (throwable instanceof SQLException) { + String state = ((SQLException)throwable).getSQLState(); + // The SQL standard is not freely available, but + // http://www.postgresql.org/docs/current/static/errcodes-appendix.html + // contains most of the SQLSTATES codes + if (state.length() == 5) { // Otherwise, the state is not following the standard. + if (state.startsWith("23")) { //Class 23 => Integrity Constraint Violation + type = IntegrityError; + } else if (state.equals("40002")) { + // 40002 => TRANSACTION INTEGRITY CONSTRAINT VIOLATION + type = IntegrityError; + } + } + } + return makeException(type, throwable); } /** @@ -342,15 +357,15 @@ * @return PyException */ public static PyException makeException(PyObject type, Throwable t) { - return makeException(type, t, -1); + return makeException(type, t, -1); } - + /** * Return a newly instantiated PyException of the given type. * * @param type * @param t - * @param rowIndex Row index where the error has happened. Useful for diagnosing. + * @param rowIndex Row index where the error has happened. Useful for diagnosing. * @return PyException */ public static PyException makeException(PyObject type, Throwable t, int rowIndex) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nr...@us...> - 2008-07-10 05:12:12
|
Revision: 4882 http://jython.svn.sourceforge.net/jython/?rev=4882&view=rev Author: nriley Date: 2008-07-09 22:12:05 -0700 (Wed, 09 Jul 2008) Log Message: ----------- need bash to test the script, too Modified Paths: -------------- branches/asm/tests/shell/test-jython.sh Modified: branches/asm/tests/shell/test-jython.sh =================================================================== --- branches/asm/tests/shell/test-jython.sh 2008-07-09 03:50:19 UTC (rev 4881) +++ branches/asm/tests/shell/test-jython.sh 2008-07-10 05:12:05 UTC (rev 4882) @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # test script for bin/jython This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Frank W. <fwi...@gm...> - 2008-07-09 23:01:50
|
On Tue, Jul 8, 2008 at 7:13 PM, Philip Jenvey <pj...@un...> wrote: >> <!-- The current version info --> >> - <property name="jython.version" value="2.5a0+" /> >> + <property name="jython.version" value="2.5a0" /> > > Why the version number change? Does the installer have trouble with it? Yeah -- on my system the + caused some problems -- I think the problem was with launching the installer (was working quickly -- at the time I had wanted to get a release together so I could announce it at EuroPython, but that didn't quite come together). I could try again and see what the problem was. Though since it is late here in Prague I probably won't get to it tonight. -Frank |
From: <nr...@us...> - 2008-07-09 03:50:22
|
Revision: 4881 http://jython.svn.sourceforge.net/jython/?rev=4881&view=rev Author: nriley Date: 2008-07-08 20:50:19 -0700 (Tue, 08 Jul 2008) Log Message: ----------- overriding fillInStackTrace for PyException speeds things up quite a bit Modified Paths: -------------- branches/asm/src/org/python/core/Options.java branches/asm/src/org/python/core/PyException.java Modified: branches/asm/src/org/python/core/Options.java =================================================================== --- branches/asm/src/org/python/core/Options.java 2008-07-09 00:42:59 UTC (rev 4880) +++ branches/asm/src/org/python/core/Options.java 2008-07-09 03:50:19 UTC (rev 4881) @@ -17,6 +17,13 @@ public static boolean showJavaExceptions = false; /** + * If true, exceptions raised from Python code will include a Java stack + * trace in addition to the Python traceback. This can slow raising + * considerably. + */ + public static boolean includeJavaStackInExceptions = false; + + /** * When true, python exception raised in overriden methods will be shown on * stderr. This option is remarkably useful when python is used for * implementing CORBA server. Some CORBA servers will turn python exception @@ -116,6 +123,9 @@ // Set the more unusual options Options.showJavaExceptions = getBooleanOption( "options.showJavaExceptions", Options.showJavaExceptions); + + Options.includeJavaStackInExceptions = getBooleanOption( + "options.includeJavaStackInExceptions", Options.includeJavaStackInExceptions); Options.showPythonProxyExceptions = getBooleanOption( "options.showPythonProxyExceptions", Modified: branches/asm/src/org/python/core/PyException.java =================================================================== --- branches/asm/src/org/python/core/PyException.java 2008-07-09 00:42:59 UTC (rev 4880) +++ branches/asm/src/org/python/core/PyException.java 2008-07-09 03:50:19 UTC (rev 4881) @@ -62,6 +62,13 @@ public void printStackTrace() { Py.printException(this); } + + public Throwable fillInStackTrace() { + if (Options.includeJavaStackInExceptions) + return super.fillInStackTrace(); + else + return this; + } public synchronized void printStackTrace(PrintStream s) { if (printingStackTrace) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-09 00:43:01
|
Revision: 4880 http://jython.svn.sourceforge.net/jython/?rev=4880&view=rev Author: pjenvey Date: 2008-07-08 17:42:59 -0700 (Tue, 08 Jul 2008) Log Message: ----------- s/java.os/os/g Modified Paths: -------------- branches/asm/Lib/platform.py Modified: branches/asm/Lib/platform.py =================================================================== --- branches/asm/Lib/platform.py 2008-07-09 00:41:01 UTC (rev 4879) +++ branches/asm/Lib/platform.py 2008-07-09 00:42:59 UTC (rev 4880) @@ -655,9 +655,9 @@ vm_release = _java_getprop('java.vm.version',vm_release) vminfo = vm_name,vm_release,vm_vendor os_name,os_version,os_arch = osinfo - os_arch = _java_getprop('java.os.arch',os_arch) - os_name = _java_getprop('java.os.name',os_name) - os_version = _java_getprop('java.os.version',os_version) + os_arch = _java_getprop('os.arch',os_arch) + os_name = _java_getprop('os.name',os_name) + os_version = _java_getprop('os.version',os_version) osinfo = os_name,os_version,os_arch return release,vendor,vminfo,osinfo This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-09 00:41:07
|
Revision: 4879 http://jython.svn.sourceforge.net/jython/?rev=4879&view=rev Author: pjenvey Date: 2008-07-08 17:41:01 -0700 (Tue, 08 Jul 2008) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/platform.py@62855 Added Paths: ----------- branches/asm/Lib/platform.py Added: branches/asm/Lib/platform.py =================================================================== --- branches/asm/Lib/platform.py (rev 0) +++ branches/asm/Lib/platform.py 2008-07-09 00:41:01 UTC (rev 4879) @@ -0,0 +1,1270 @@ +#!/usr/bin/env python + +""" This module tries to retrieve as much platform-identifying data as + possible. It makes this information available via function APIs. + + If called from the command line, it prints the platform + information concatenated as single string to stdout. The output + format is useable as part of a filename. + +""" +# This module is maintained by Marc-Andre Lemburg <ma...@eg...>. +# If you find problems, please submit bug reports/patches via the +# Python SourceForge Project Page and assign them to "lemburg". +# +# Note: Please keep this module compatible to Python 1.5.2. +# +# Still needed: +# * more support for WinCE +# * support for MS-DOS (PythonDX ?) +# * support for Amiga and other still unsupported platforms running Python +# * support for additional Linux distributions +# +# Many thanks to all those who helped adding platform-specific +# checks (in no particular order): +# +# Charles G Waldman, David Arnold, Gordon McMillan, Ben Darnell, +# Jeff Bauer, Cliff Crawford, Ivan Van Laningham, Josef +# Betancourt, Randall Hopper, Karl Putland, John Farrell, Greg +# Andruk, Just van Rossum, Thomas Heller, Mark R. Levinson, Mark +# Hammond, Bill Tutt, Hans Nowak, Uwe Zessin (OpenVMS support), +# Colin Kong, Trent Mick, Guido van Rossum +# +# History: +# +# <see CVS and SVN checkin messages for history> +# +# 1.0.3 - added normalization of Windows system name +# 1.0.2 - added more Windows support +# 1.0.1 - reformatted to make doc.py happy +# 1.0.0 - reformatted a bit and checked into Python CVS +# 0.8.0 - added sys.version parser and various new access +# APIs (python_version(), python_compiler(), etc.) +# 0.7.2 - fixed architecture() to use sizeof(pointer) where available +# 0.7.1 - added support for Caldera OpenLinux +# 0.7.0 - some fixes for WinCE; untabified the source file +# 0.6.2 - support for OpenVMS - requires version 1.5.2-V006 or higher and +# vms_lib.getsyi() configured +# 0.6.1 - added code to prevent 'uname -p' on platforms which are +# known not to support it +# 0.6.0 - fixed win32_ver() to hopefully work on Win95,98,NT and Win2k; +# did some cleanup of the interfaces - some APIs have changed +# 0.5.5 - fixed another type in the MacOS code... should have +# used more coffee today ;-) +# 0.5.4 - fixed a few typos in the MacOS code +# 0.5.3 - added experimental MacOS support; added better popen() +# workarounds in _syscmd_ver() -- still not 100% elegant +# though +# 0.5.2 - fixed uname() to return '' instead of 'unknown' in all +# return values (the system uname command tends to return +# 'unknown' instead of just leaving the field emtpy) +# 0.5.1 - included code for slackware dist; added exception handlers +# to cover up situations where platforms don't have os.popen +# (e.g. Mac) or fail on socket.gethostname(); fixed libc +# detection RE +# 0.5.0 - changed the API names referring to system commands to *syscmd*; +# added java_ver(); made syscmd_ver() a private +# API (was system_ver() in previous versions) -- use uname() +# instead; extended the win32_ver() to also return processor +# type information +# 0.4.0 - added win32_ver() and modified the platform() output for WinXX +# 0.3.4 - fixed a bug in _follow_symlinks() +# 0.3.3 - fixed popen() and "file" command invokation bugs +# 0.3.2 - added architecture() API and support for it in platform() +# 0.3.1 - fixed syscmd_ver() RE to support Windows NT +# 0.3.0 - added system alias support +# 0.2.3 - removed 'wince' again... oh well. +# 0.2.2 - added 'wince' to syscmd_ver() supported platforms +# 0.2.1 - added cache logic and changed the platform string format +# 0.2.0 - changed the API to use functions instead of module globals +# since some action take too long to be run on module import +# 0.1.0 - first release +# +# You can always get the latest version of this module at: +# +# http://www.egenix.com/files/python/platform.py +# +# If that URL should fail, try contacting the author. + +__copyright__ = """ + Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:ma...@le... + Copyright (c) 2000-2003, eGenix.com Software GmbH; mailto:in...@eg... + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee or royalty is hereby granted, + provided that the above copyright notice appear in all copies and that + both that copyright notice and this permission notice appear in + supporting documentation or portions thereof, including modifications, + that you make. + + EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO + THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, + INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! + +""" + +__version__ = '1.0.4' + +import sys,string,os,re + +### Platform specific APIs + +_libc_search = re.compile(r'(__libc_init)' + '|' + '(GLIBC_([0-9.]+))' + '|' + '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)') + +def libc_ver(executable=sys.executable,lib='',version='', + + chunksize=2048): + + """ Tries to determine the libc version that the file executable + (which defaults to the Python interpreter) is linked against. + + Returns a tuple of strings (lib,version) which default to the + given parameters in case the lookup fails. + + Note that the function has intimate knowledge of how different + libc versions add symbols to the executable and thus is probably + only useable for executables compiled using gcc. + + The file is read and scanned in chunks of chunksize bytes. + + """ + f = open(executable,'rb') + binary = f.read(chunksize) + pos = 0 + while 1: + m = _libc_search.search(binary,pos) + if not m: + binary = f.read(chunksize) + if not binary: + break + pos = 0 + continue + libcinit,glibc,glibcversion,so,threads,soversion = m.groups() + if libcinit and not lib: + lib = 'libc' + elif glibc: + if lib != 'glibc': + lib = 'glibc' + version = glibcversion + elif glibcversion > version: + version = glibcversion + elif so: + if lib != 'glibc': + lib = 'libc' + if soversion > version: + version = soversion + if threads and version[-len(threads):] != threads: + version = version + threads + pos = m.end() + f.close() + return lib,version + +def _dist_try_harder(distname,version,id): + + """ Tries some special tricks to get the distribution + information in case the default method fails. + + Currently supports older SuSE Linux, Caldera OpenLinux and + Slackware Linux distributions. + + """ + if os.path.exists('/var/adm/inst-log/info'): + # SuSE Linux stores distribution information in that file + info = open('/var/adm/inst-log/info').readlines() + distname = 'SuSE' + for line in info: + tv = string.split(line) + if len(tv) == 2: + tag,value = tv + else: + continue + if tag == 'MIN_DIST_VERSION': + version = string.strip(value) + elif tag == 'DIST_IDENT': + values = string.split(value,'-') + id = values[2] + return distname,version,id + + if os.path.exists('/etc/.installed'): + # Caldera OpenLinux has some infos in that file (thanks to Colin Kong) + info = open('/etc/.installed').readlines() + for line in info: + pkg = string.split(line,'-') + if len(pkg) >= 2 and pkg[0] == 'OpenLinux': + # XXX does Caldera support non Intel platforms ? If yes, + # where can we find the needed id ? + return 'OpenLinux',pkg[1],id + + if os.path.isdir('/usr/lib/setup'): + # Check for slackware verson tag file (thanks to Greg Andruk) + verfiles = os.listdir('/usr/lib/setup') + for n in range(len(verfiles)-1, -1, -1): + if verfiles[n][:14] != 'slack-version-': + del verfiles[n] + if verfiles: + verfiles.sort() + distname = 'slackware' + version = verfiles[-1][14:] + return distname,version,id + + return distname,version,id + +_release_filename = re.compile(r'(\w+)[-_](release|version)') +_release_version = re.compile(r'([\d.]+)[^(]*(?:\((.+)\))?') + +# Note:In supported_dists below we need 'fedora' before 'redhat' as in +# Fedora redhat-release is a link to fedora-release. + +def dist(distname='',version='',id='', + + supported_dists=('SuSE', 'debian', 'fedora', 'redhat', 'mandrake')): + + """ Tries to determine the name of the Linux OS distribution name. + + The function first looks for a distribution release file in + /etc and then reverts to _dist_try_harder() in case no + suitable files are found. + + Returns a tuple (distname,version,id) which default to the + args given as parameters. + + """ + try: + etc = os.listdir('/etc') + except os.error: + # Probably not a Unix system + return distname,version,id + for file in etc: + m = _release_filename.match(file) + if m: + _distname,dummy = m.groups() + if _distname in supported_dists: + distname = _distname + break + else: + return _dist_try_harder(distname,version,id) + f = open('/etc/'+file,'r') + firstline = f.readline() + f.close() + m = _release_version.search(firstline) + if m: + _version,_id = m.groups() + if _version: + version = _version + if _id: + id = _id + else: + # Unkown format... take the first two words + l = string.split(string.strip(firstline)) + if l: + version = l[0] + if len(l) > 1: + id = l[1] + return distname,version,id + +class _popen: + + """ Fairly portable (alternative) popen implementation. + + This is mostly needed in case os.popen() is not available, or + doesn't work as advertised, e.g. in Win9X GUI programs like + PythonWin or IDLE. + + Writing to the pipe is currently not supported. + + """ + tmpfile = '' + pipe = None + bufsize = None + mode = 'r' + + def __init__(self,cmd,mode='r',bufsize=None): + + if mode != 'r': + raise ValueError,'popen()-emulation only supports read mode' + import tempfile + self.tmpfile = tmpfile = tempfile.mktemp() + os.system(cmd + ' > %s' % tmpfile) + self.pipe = open(tmpfile,'rb') + self.bufsize = bufsize + self.mode = mode + + def read(self): + + return self.pipe.read() + + def readlines(self): + + if self.bufsize is not None: + return self.pipe.readlines() + + def close(self, + + remove=os.unlink,error=os.error): + + if self.pipe: + rc = self.pipe.close() + else: + rc = 255 + if self.tmpfile: + try: + remove(self.tmpfile) + except error: + pass + return rc + + # Alias + __del__ = close + +def popen(cmd, mode='r', bufsize=None): + + """ Portable popen() interface. + """ + # Find a working popen implementation preferring win32pipe.popen + # over os.popen over _popen + popen = None + if os.environ.get('OS','') == 'Windows_NT': + # On NT win32pipe should work; on Win9x it hangs due to bugs + # in the MS C lib (see MS KnowledgeBase article Q150956) + try: + import win32pipe + except ImportError: + pass + else: + popen = win32pipe.popen + if popen is None: + if hasattr(os,'popen'): + popen = os.popen + # Check whether it works... it doesn't in GUI programs + # on Windows platforms + if sys.platform == 'win32': # XXX Others too ? + try: + popen('') + except os.error: + popen = _popen + else: + popen = _popen + if bufsize is None: + return popen(cmd,mode) + else: + return popen(cmd,mode,bufsize) + +def _norm_version(version,build=''): + + """ Normalize the version and build strings and return a single + version string using the format major.minor.build (or patchlevel). + """ + l = string.split(version,'.') + if build: + l.append(build) + try: + ints = map(int,l) + except ValueError: + strings = l + else: + strings = map(str,ints) + version = string.join(strings[:3],'.') + return version + +_ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) ' + '.*' + 'Version ([\d.]+))') + +def _syscmd_ver(system='',release='',version='', + + supported_platforms=('win32','win16','dos','os2')): + + """ Tries to figure out the OS version used and returns + a tuple (system,release,version). + + It uses the "ver" shell command for this which is known + to exists on Windows, DOS and OS/2. XXX Others too ? + + In case this fails, the given parameters are used as + defaults. + + """ + if sys.platform not in supported_platforms: + return system,release,version + + # Try some common cmd strings + for cmd in ('ver','command /c ver','cmd /c ver'): + try: + pipe = popen(cmd) + info = pipe.read() + if pipe.close(): + raise os.error,'command failed' + # XXX How can I supress shell errors from being written + # to stderr ? + except os.error,why: + #print 'Command %s failed: %s' % (cmd,why) + continue + except IOError,why: + #print 'Command %s failed: %s' % (cmd,why) + continue + else: + break + else: + return system,release,version + + # Parse the output + info = string.strip(info) + m = _ver_output.match(info) + if m: + system,release,version = m.groups() + # Strip trailing dots from version and release + if release[-1] == '.': + release = release[:-1] + if version[-1] == '.': + version = version[:-1] + # Normalize the version and build strings (eliminating additional + # zeros) + version = _norm_version(version) + return system,release,version + +def _win32_getvalue(key,name,default=''): + + """ Read a value for name from the registry key. + + In case this fails, default is returned. + + """ + from win32api import RegQueryValueEx + try: + return RegQueryValueEx(key,name) + except: + return default + +def win32_ver(release='',version='',csd='',ptype=''): + + """ Get additional version information from the Windows Registry + and return a tuple (version,csd,ptype) referring to version + number, CSD level and OS type (multi/single + processor). + + As a hint: ptype returns 'Uniprocessor Free' on single + processor NT machines and 'Multiprocessor Free' on multi + processor machines. The 'Free' refers to the OS version being + free of debugging code. It could also state 'Checked' which + means the OS version uses debugging code, i.e. code that + checks arguments, ranges, etc. (Thomas Heller). + + Note: this function only works if Mark Hammond's win32 + package is installed and obviously only runs on Win32 + compatible platforms. + + """ + # XXX Is there any way to find out the processor type on WinXX ? + # XXX Is win32 available on Windows CE ? + # + # Adapted from code posted by Karl Putland to comp.lang.python. + # + # The mappings between reg. values and release names can be found + # here: http://msdn.microsoft.com/library/en-us/sysinfo/base/osversioninfo_str.asp + + # Import the needed APIs + try: + import win32api + except ImportError: + return release,version,csd,ptype + from win32api import RegQueryValueEx,RegOpenKeyEx,RegCloseKey,GetVersionEx + from win32con import HKEY_LOCAL_MACHINE,VER_PLATFORM_WIN32_NT,\ + VER_PLATFORM_WIN32_WINDOWS + + # Find out the registry key and some general version infos + maj,min,buildno,plat,csd = GetVersionEx() + version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF) + if csd[:13] == 'Service Pack ': + csd = 'SP' + csd[13:] + if plat == VER_PLATFORM_WIN32_WINDOWS: + regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' + # Try to guess the release name + if maj == 4: + if min == 0: + release = '95' + elif min == 10: + release = '98' + elif min == 90: + release = 'Me' + else: + release = 'postMe' + elif maj == 5: + release = '2000' + elif plat == VER_PLATFORM_WIN32_NT: + regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion' + if maj <= 4: + release = 'NT' + elif maj == 5: + if min == 0: + release = '2000' + elif min == 1: + release = 'XP' + elif min == 2: + release = '2003Server' + else: + release = 'post2003' + else: + if not release: + # E.g. Win3.1 with win32s + release = '%i.%i' % (maj,min) + return release,version,csd,ptype + + # Open the registry key + try: + keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE,regkey) + # Get a value to make sure the key exists... + RegQueryValueEx(keyCurVer,'SystemRoot') + except: + return release,version,csd,ptype + + # Parse values + #subversion = _win32_getvalue(keyCurVer, + # 'SubVersionNumber', + # ('',1))[0] + #if subversion: + # release = release + subversion # 95a, 95b, etc. + build = _win32_getvalue(keyCurVer, + 'CurrentBuildNumber', + ('',1))[0] + ptype = _win32_getvalue(keyCurVer, + 'CurrentType', + (ptype,1))[0] + + # Normalize version + version = _norm_version(version,build) + + # Close key + RegCloseKey(keyCurVer) + return release,version,csd,ptype + +def _mac_ver_lookup(selectors,default=None): + + from gestalt import gestalt + import MacOS + l = [] + append = l.append + for selector in selectors: + try: + append(gestalt(selector)) + except (RuntimeError, MacOS.Error): + append(default) + return l + +def _bcd2str(bcd): + + return hex(bcd)[2:] + +def mac_ver(release='',versioninfo=('','',''),machine=''): + + """ Get MacOS version information and return it as tuple (release, + versioninfo, machine) with versioninfo being a tuple (version, + dev_stage, non_release_version). + + Entries which cannot be determined are set to the paramter values + which default to ''. All tuple entries are strings. + + Thanks to Mark R. Levinson for mailing documentation links and + code examples for this function. Documentation for the + gestalt() API is available online at: + + http://www.rgaros.nl/gestalt/ + + """ + # Check whether the version info module is available + try: + import gestalt + import MacOS + except ImportError: + return release,versioninfo,machine + # Get the infos + sysv,sysu,sysa = _mac_ver_lookup(('sysv','sysu','sysa')) + # Decode the infos + if sysv: + major = (sysv & 0xFF00) >> 8 + minor = (sysv & 0x00F0) >> 4 + patch = (sysv & 0x000F) + + if (major, minor) >= (10, 4): + # the 'sysv' gestald cannot return patchlevels + # higher than 9. Apple introduced 3 new + # gestalt codes in 10.4 to deal with this + # issue (needed because patch levels can + # run higher than 9, such as 10.4.11) + major,minor,patch = _mac_ver_lookup(('sys1','sys2','sys3')) + release = '%i.%i.%i' %(major, minor, patch) + else: + release = '%s.%i.%i' % (_bcd2str(major),minor,patch) + if sysu: + major = int((sysu & 0xFF000000L) >> 24) + minor = (sysu & 0x00F00000) >> 20 + bugfix = (sysu & 0x000F0000) >> 16 + stage = (sysu & 0x0000FF00) >> 8 + nonrel = (sysu & 0x000000FF) + version = '%s.%i.%i' % (_bcd2str(major),minor,bugfix) + nonrel = _bcd2str(nonrel) + stage = {0x20:'development', + 0x40:'alpha', + 0x60:'beta', + 0x80:'final'}.get(stage,'') + versioninfo = (version,stage,nonrel) + if sysa: + machine = {0x1: '68k', + 0x2: 'PowerPC', + 0xa: 'i386'}.get(sysa,'') + return release,versioninfo,machine + +def _java_getprop(name,default): + + from java.lang import System + try: + return System.getProperty(name) + except: + return default + +def java_ver(release='',vendor='',vminfo=('','',''),osinfo=('','','')): + + """ Version interface for Jython. + + Returns a tuple (release,vendor,vminfo,osinfo) with vminfo being + a tuple (vm_name,vm_release,vm_vendor) and osinfo being a + tuple (os_name,os_version,os_arch). + + Values which cannot be determined are set to the defaults + given as parameters (which all default to ''). + + """ + # Import the needed APIs + try: + import java.lang + except ImportError: + return release,vendor,vminfo,osinfo + + vendor = _java_getprop('java.vendor',vendor) + release = _java_getprop('java.version',release) + vm_name,vm_release,vm_vendor = vminfo + vm_name = _java_getprop('java.vm.name',vm_name) + vm_vendor = _java_getprop('java.vm.vendor',vm_vendor) + vm_release = _java_getprop('java.vm.version',vm_release) + vminfo = vm_name,vm_release,vm_vendor + os_name,os_version,os_arch = osinfo + os_arch = _java_getprop('java.os.arch',os_arch) + os_name = _java_getprop('java.os.name',os_name) + os_version = _java_getprop('java.os.version',os_version) + osinfo = os_name,os_version,os_arch + + return release,vendor,vminfo,osinfo + +### System name aliasing + +def system_alias(system,release,version): + + """ Returns (system,release,version) aliased to common + marketing names used for some systems. + + It also does some reordering of the information in some cases + where it would otherwise cause confusion. + + """ + if system == 'Rhapsody': + # Apple's BSD derivative + # XXX How can we determine the marketing release number ? + return 'MacOS X Server',system+release,version + + elif system == 'SunOS': + # Sun's OS + if release < '5': + # These releases use the old name SunOS + return system,release,version + # Modify release (marketing release = SunOS release - 3) + l = string.split(release,'.') + if l: + try: + major = int(l[0]) + except ValueError: + pass + else: + major = major - 3 + l[0] = str(major) + release = string.join(l,'.') + if release < '6': + system = 'Solaris' + else: + # XXX Whatever the new SunOS marketing name is... + system = 'Solaris' + + elif system == 'IRIX64': + # IRIX reports IRIX64 on platforms with 64-bit support; yet it + # is really a version and not a different platform, since 32-bit + # apps are also supported.. + system = 'IRIX' + if version: + version = version + ' (64bit)' + else: + version = '64bit' + + elif system in ('win32','win16'): + # In case one of the other tricks + system = 'Windows' + + return system,release,version + +### Various internal helpers + +def _platform(*args): + + """ Helper to format the platform string in a filename + compatible format e.g. "system-version-machine". + """ + # Format the platform string + platform = string.join( + map(string.strip, + filter(len,args)), + '-') + + # Cleanup some possible filename obstacles... + replace = string.replace + platform = replace(platform,' ','_') + platform = replace(platform,'/','-') + platform = replace(platform,'\\','-') + platform = replace(platform,':','-') + platform = replace(platform,';','-') + platform = replace(platform,'"','-') + platform = replace(platform,'(','-') + platform = replace(platform,')','-') + + # No need to report 'unknown' information... + platform = replace(platform,'unknown','') + + # Fold '--'s and remove trailing '-' + while 1: + cleaned = replace(platform,'--','-') + if cleaned == platform: + break + platform = cleaned + while platform[-1] == '-': + platform = platform[:-1] + + return platform + +def _node(default=''): + + """ Helper to determine the node name of this machine. + """ + try: + import socket + except ImportError: + # No sockets... + return default + try: + return socket.gethostname() + except socket.error: + # Still not working... + return default + +# os.path.abspath is new in Python 1.5.2: +if not hasattr(os.path,'abspath'): + + def _abspath(path, + + isabs=os.path.isabs,join=os.path.join,getcwd=os.getcwd, + normpath=os.path.normpath): + + if not isabs(path): + path = join(getcwd(), path) + return normpath(path) + +else: + + _abspath = os.path.abspath + +def _follow_symlinks(filepath): + + """ In case filepath is a symlink, follow it until a + real file is reached. + """ + filepath = _abspath(filepath) + while os.path.islink(filepath): + filepath = os.path.normpath( + os.path.join(filepath,os.readlink(filepath))) + return filepath + +def _syscmd_uname(option,default=''): + + """ Interface to the system's uname command. + """ + if sys.platform in ('dos','win32','win16','os2'): + # XXX Others too ? + return default + try: + f = os.popen('uname %s 2> /dev/null' % option) + except (AttributeError,os.error): + return default + output = string.strip(f.read()) + rc = f.close() + if not output or rc: + return default + else: + return output + +def _syscmd_file(target,default=''): + + """ Interface to the system's file command. + + The function uses the -b option of the file command to have it + ommit the filename in its output and if possible the -L option + to have the command follow symlinks. It returns default in + case the command should fail. + + """ + target = _follow_symlinks(target) + try: + f = os.popen('file %s 2> /dev/null' % target) + except (AttributeError,os.error): + return default + output = string.strip(f.read()) + rc = f.close() + if not output or rc: + return default + else: + return output + +### Information about the used architecture + +# Default values for architecture; non-empty strings override the +# defaults given as parameters +_default_architecture = { + 'win32': ('','WindowsPE'), + 'win16': ('','Windows'), + 'dos': ('','MSDOS'), +} + +_architecture_split = re.compile(r'[\s,]').split + +def architecture(executable=sys.executable,bits='',linkage=''): + + """ Queries the given executable (defaults to the Python interpreter + binary) for various architecture information. + + Returns a tuple (bits,linkage) which contains information about + the bit architecture and the linkage format used for the + executable. Both values are returned as strings. + + Values that cannot be determined are returned as given by the + parameter presets. If bits is given as '', the sizeof(pointer) + (or sizeof(long) on Python version < 1.5.2) is used as + indicator for the supported pointer size. + + The function relies on the system's "file" command to do the + actual work. This is available on most if not all Unix + platforms. On some non-Unix platforms where the "file" command + does not exist and the executable is set to the Python interpreter + binary defaults from _default_architecture are used. + + """ + # Use the sizeof(pointer) as default number of bits if nothing + # else is given as default. + if not bits: + import struct + try: + size = struct.calcsize('P') + except struct.error: + # Older installations can only query longs + size = struct.calcsize('l') + bits = str(size*8) + 'bit' + + # Get data from the 'file' system command + output = _syscmd_file(executable,'') + + if not output and \ + executable == sys.executable: + # "file" command did not return anything; we'll try to provide + # some sensible defaults then... + if _default_architecture.has_key(sys.platform): + b,l = _default_architecture[sys.platform] + if b: + bits = b + if l: + linkage = l + return bits,linkage + + # Split the output into a list of strings omitting the filename + fileout = _architecture_split(output)[1:] + + if 'executable' not in fileout: + # Format not supported + return bits,linkage + + # Bits + if '32-bit' in fileout: + bits = '32bit' + elif 'N32' in fileout: + # On Irix only + bits = 'n32bit' + elif '64-bit' in fileout: + bits = '64bit' + + # Linkage + if 'ELF' in fileout: + linkage = 'ELF' + elif 'PE' in fileout: + # E.g. Windows uses this format + if 'Windows' in fileout: + linkage = 'WindowsPE' + else: + linkage = 'PE' + elif 'COFF' in fileout: + linkage = 'COFF' + elif 'MS-DOS' in fileout: + linkage = 'MSDOS' + else: + # XXX the A.OUT format also falls under this class... + pass + + return bits,linkage + +### Portable uname() interface + +_uname_cache = None + +def uname(): + + """ Fairly portable uname interface. Returns a tuple + of strings (system,node,release,version,machine,processor) + identifying the underlying platform. + + Note that unlike the os.uname function this also returns + possible processor information as an additional tuple entry. + + Entries which cannot be determined are set to ''. + + """ + global _uname_cache + + if _uname_cache is not None: + return _uname_cache + + # Get some infos from the builtin os.uname API... + try: + system,node,release,version,machine = os.uname() + + except AttributeError: + # Hmm, no uname... we'll have to poke around the system then. + system = sys.platform + release = '' + version = '' + node = _node() + machine = '' + processor = '' + use_syscmd_ver = 1 + + # Try win32_ver() on win32 platforms + if system == 'win32': + release,version,csd,ptype = win32_ver() + if release and version: + use_syscmd_ver = 0 + + # Try the 'ver' system command available on some + # platforms + if use_syscmd_ver: + system,release,version = _syscmd_ver(system) + # Normalize system to what win32_ver() normally returns + # (_syscmd_ver() tends to return the vendor name as well) + if system == 'Microsoft Windows': + system = 'Windows' + + # In case we still don't know anything useful, we'll try to + # help ourselves + if system in ('win32','win16'): + if not version: + if system == 'win32': + version = '32bit' + else: + version = '16bit' + system = 'Windows' + + elif system[:4] == 'java': + release,vendor,vminfo,osinfo = java_ver() + system = 'Java' + version = string.join(vminfo,', ') + if not version: + version = vendor + + elif os.name == 'mac': + release,(version,stage,nonrel),machine = mac_ver() + system = 'MacOS' + + else: + # System specific extensions + if system == 'OpenVMS': + # OpenVMS seems to have release and version mixed up + if not release or release == '0': + release = version + version = '' + # Get processor information + try: + import vms_lib + except ImportError: + pass + else: + csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0) + if (cpu_number >= 128): + processor = 'Alpha' + else: + processor = 'VAX' + else: + # Get processor information from the uname system command + processor = _syscmd_uname('-p','') + + # 'unknown' is not really any useful as information; we'll convert + # it to '' which is more portable + if system == 'unknown': + system = '' + if node == 'unknown': + node = '' + if release == 'unknown': + release = '' + if version == 'unknown': + version = '' + if machine == 'unknown': + machine = '' + if processor == 'unknown': + processor = '' + + # normalize name + if system == 'Microsoft' and release == 'Windows': + system = 'Windows' + release = 'Vista' + + _uname_cache = system,node,release,version,machine,processor + return _uname_cache + +### Direct interfaces to some of the uname() return values + +def system(): + + """ Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'. + + An empty string is returned if the value cannot be determined. + + """ + return uname()[0] + +def node(): + + """ Returns the computer's network name (which may not be fully + qualified) + + An empty string is returned if the value cannot be determined. + + """ + return uname()[1] + +def release(): + + """ Returns the system's release, e.g. '2.2.0' or 'NT' + + An empty string is returned if the value cannot be determined. + + """ + return uname()[2] + +def version(): + + """ Returns the system's release version, e.g. '#3 on degas' + + An empty string is returned if the value cannot be determined. + + """ + return uname()[3] + +def machine(): + + """ Returns the machine type, e.g. 'i386' + + An empty string is returned if the value cannot be determined. + + """ + return uname()[4] + +def processor(): + + """ Returns the (true) processor name, e.g. 'amdk6' + + An empty string is returned if the value cannot be + determined. Note that many platforms do not provide this + information or simply return the same value as for machine(), + e.g. NetBSD does this. + + """ + return uname()[5] + +### Various APIs for extracting information from sys.version + +_sys_version_parser = re.compile(r'([\w.+]+)\s*' + '\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*' + '\[([^\]]+)\]?') +_sys_version_cache = None + +def _sys_version(): + + """ Returns a parsed version of Python's sys.version as tuple + (version, buildno, builddate, compiler) referring to the Python + version, build number, build date/time as string and the compiler + identification string. + + Note that unlike the Python sys.version, the returned value + for the Python version will always include the patchlevel (it + defaults to '.0'). + + """ + global _sys_version_cache + + if _sys_version_cache is not None: + return _sys_version_cache + version, buildno, builddate, buildtime, compiler = \ + _sys_version_parser.match(sys.version).groups() + builddate = builddate + ' ' + buildtime + l = string.split(version, '.') + if len(l) == 2: + l.append('0') + version = string.join(l, '.') + _sys_version_cache = (version, buildno, builddate, compiler) + return _sys_version_cache + +def python_version(): + + """ Returns the Python version as string 'major.minor.patchlevel' + + Note that unlike the Python sys.version, the returned value + will always include the patchlevel (it defaults to 0). + + """ + return _sys_version()[0] + +def python_version_tuple(): + + """ Returns the Python version as tuple (major, minor, patchlevel) + of strings. + + Note that unlike the Python sys.version, the returned value + will always include the patchlevel (it defaults to 0). + + """ + return string.split(_sys_version()[0], '.') + +def python_build(): + + """ Returns a tuple (buildno, builddate) stating the Python + build number and date as strings. + + """ + return _sys_version()[1:3] + +def python_compiler(): + + """ Returns a string identifying the compiler used for compiling + Python. + + """ + return _sys_version()[3] + +### The Opus Magnum of platform strings :-) + +_platform_cache = {} + +def platform(aliased=0, terse=0): + + """ Returns a single string identifying the underlying platform + with as much useful information as possible (but no more :). + + The output is intended to be human readable rather than + machine parseable. It may look different on different + platforms and this is intended. + + If "aliased" is true, the function will use aliases for + various platforms that report system names which differ from + their common names, e.g. SunOS will be reported as + Solaris. The system_alias() function is used to implement + this. + + Setting terse to true causes the function to return only the + absolute minimum information needed to identify the platform. + + """ + result = _platform_cache.get((aliased, terse), None) + if result is not None: + return result + + # Get uname information and then apply platform specific cosmetics + # to it... + system,node,release,version,machine,processor = uname() + if machine == processor: + processor = '' + if aliased: + system,release,version = system_alias(system,release,version) + + if system == 'Windows': + # MS platforms + rel,vers,csd,ptype = win32_ver(version) + if terse: + platform = _platform(system,release) + else: + platform = _platform(system,release,version,csd) + + elif system in ('Linux',): + # Linux based systems + distname,distversion,distid = dist('') + if distname and not terse: + platform = _platform(system,release,machine,processor, + 'with', + distname,distversion,distid) + else: + # If the distribution name is unknown check for libc vs. glibc + libcname,libcversion = libc_ver(sys.executable) + platform = _platform(system,release,machine,processor, + 'with', + libcname+libcversion) + elif system == 'Java': + # Java platforms + r,v,vminfo,(os_name,os_version,os_arch) = java_ver() + if terse: + platform = _platform(system,release,version) + else: + platform = _platform(system,release,version, + 'on', + os_name,os_version,os_arch) + + elif system == 'MacOS': + # MacOS platforms + if terse: + platform = _platform(system,release) + else: + platform = _platform(system,release,machine) + + else: + # Generic handler + if terse: + platform = _platform(system,release) + else: + bits,linkage = architecture(sys.executable) + platform = _platform(system,release,machine,processor,bits,linkage) + + _platform_cache[(aliased, terse)] = platform + return platform + +### Command line interface + +if __name__ == '__main__': + # Default is to print the aliased verbose platform string + terse = ('terse' in sys.argv or '--terse' in sys.argv) + aliased = (not 'nonaliased' in sys.argv and not '--nonaliased' in sys.argv) + print platform(aliased,terse) + sys.exit(0) Property changes on: branches/asm/Lib/platform.py ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Philip J. <pj...@un...> - 2008-07-08 23:14:04
|
On Jul 8, 2008, at 1:59 AM, fwi...@us... wrote: > Revision: 4870 > http://jython.svn.sourceforge.net/jython/?rev=4870&view=rev > Author: fwierzbicki > Date: 2008-07-08 01:59:37 -0700 (Tue, 08 Jul 2008) > > Log Message: > ----------- > some tweaks to help the install task. > > Modified Paths: > -------------- > branches/asm/build.xml > > Modified: branches/asm/build.xml > =================================================================== > --- branches/asm/build.xml 2008-07-08 07:27:03 UTC (rev 4869) > +++ branches/asm/build.xml 2008-07-08 08:59:37 UTC (rev 4870) > @@ -202,7 +202,7 @@ > <property name="PY_RELEASE_LEVEL_SNAPSHOT" value="170"/> > <!-- 0xAA --> > > <!-- The current version info --> > - <property name="jython.version" value="2.5a0+" /> > + <property name="jython.version" value="2.5a0" /> Why the version number change? Does the installer have trouble with it? -- Philip Jenvey |
From: <pj...@us...> - 2008-07-08 21:05:57
|
Revision: 4878 http://jython.svn.sourceforge.net/jython/?rev=4878&view=rev Author: pjenvey Date: 2008-07-08 14:05:48 -0700 (Tue, 08 Jul 2008) Log Message: ----------- o allow a length argument to zlib decompressobj flush o workarounds for 2.5 test_scope test_types (which output now matches stdlib's) and test_zlib Modified Paths: -------------- branches/asm/Lib/test/test_scope.py branches/asm/Lib/test/test_types.py branches/asm/Lib/test/test_zlib.py branches/asm/Lib/zlib.py Removed Paths: ------------- branches/asm/Lib/test/output/test_types Deleted: branches/asm/Lib/test/output/test_types =================================================================== --- branches/asm/Lib/test/output/test_types 2008-07-08 20:38:02 UTC (rev 4877) +++ branches/asm/Lib/test/output/test_types 2008-07-08 21:05:48 UTC (rev 4878) @@ -1,15 +0,0 @@ -test_types -6. Built-in types -6.1 Truth value testing -6.2 Boolean operations -6.3 Comparisons -6.4 Numeric types (mostly conversions) -6.4.1 32-bit integers -6.4.2 Long integers -6.4.3 Floating point numbers -6.5 Sequence types -6.5.1 Strings -6.5.2 Tuples -6.5.3 Lists -6.5.3a Additional list operations -6.6 Mappings == Dictionaries Modified: branches/asm/Lib/test/test_scope.py =================================================================== --- branches/asm/Lib/test/test_scope.py 2008-07-08 20:38:02 UTC (rev 4877) +++ branches/asm/Lib/test/test_scope.py 2008-07-08 21:05:48 UTC (rev 4878) @@ -1,4 +1,4 @@ -from test.test_support import verify, TestFailed, check_syntax, vereq +from test.test_support import verify, TestFailed, check_syntax, vereq, is_jython import warnings warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>") @@ -435,6 +435,9 @@ for i in range(100): f1() +if is_jython: + from test_weakref import extra_collect + extra_collect() vereq(Foo.count, 0) print "17. class and global" Modified: branches/asm/Lib/test/test_types.py =================================================================== --- branches/asm/Lib/test/test_types.py 2008-07-08 20:38:02 UTC (rev 4877) +++ branches/asm/Lib/test/test_types.py 2008-07-08 21:05:48 UTC (rev 4878) @@ -229,58 +229,60 @@ except TypeError: pass else: raise TestFailed, 'type(), w/4 args expected TypeError' +# XXX: Jython lacks buffers print 'Buffers' -try: buffer('asdf', -1) -except ValueError: pass -else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" -cmp(buffer("abc"), buffer("def")) # used to raise a warning: tp_compare didn't return -1, 0, or 1 +if not is_jython: + try: buffer('asdf', -1) + except ValueError: pass + else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" + cmp(buffer("abc"), buffer("def")) # used to raise a warning: tp_compare didn't return -1, 0, or 1 -try: buffer(None) -except TypeError: pass -else: raise TestFailed, "buffer(None) should raise TypeError" + try: buffer(None) + except TypeError: pass + else: raise TestFailed, "buffer(None) should raise TypeError" -a = buffer('asdf') -hash(a) -b = a * 5 -if a == b: - raise TestFailed, 'buffers should not be equal' -if str(b) != ('asdf' * 5): - raise TestFailed, 'repeated buffer has wrong content' -if str(a * 0) != '': - raise TestFailed, 'repeated buffer zero times has wrong content' -if str(a + buffer('def')) != 'asdfdef': - raise TestFailed, 'concatenation of buffers yields wrong content' -if str(buffer(a)) != 'asdf': - raise TestFailed, 'composing buffers failed' -if str(buffer(a, 2)) != 'df': - raise TestFailed, 'specifying buffer offset failed' -if str(buffer(a, 0, 2)) != 'as': - raise TestFailed, 'specifying buffer size failed' -if str(buffer(a, 1, 2)) != 'sd': - raise TestFailed, 'specifying buffer offset and size failed' -try: buffer(buffer('asdf', 1), -1) -except ValueError: pass -else: raise TestFailed, "buffer(buffer('asdf', 1), -1) should raise ValueError" -if str(buffer(buffer('asdf', 0, 2), 0)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's': - raise TestFailed, 'composing length-specified buffer failed' + a = buffer('asdf') + hash(a) + b = a * 5 + if a == b: + raise TestFailed, 'buffers should not be equal' + if str(b) != ('asdf' * 5): + raise TestFailed, 'repeated buffer has wrong content' + if str(a * 0) != '': + raise TestFailed, 'repeated buffer zero times has wrong content' + if str(a + buffer('def')) != 'asdfdef': + raise TestFailed, 'concatenation of buffers yields wrong content' + if str(buffer(a)) != 'asdf': + raise TestFailed, 'composing buffers failed' + if str(buffer(a, 2)) != 'df': + raise TestFailed, 'specifying buffer offset failed' + if str(buffer(a, 0, 2)) != 'as': + raise TestFailed, 'specifying buffer size failed' + if str(buffer(a, 1, 2)) != 'sd': + raise TestFailed, 'specifying buffer offset and size failed' + try: buffer(buffer('asdf', 1), -1) + except ValueError: pass + else: raise TestFailed, "buffer(buffer('asdf', 1), -1) should raise ValueError" + if str(buffer(buffer('asdf', 0, 2), 0)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' + if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' + if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' + if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's': + raise TestFailed, 'composing length-specified buffer failed' -try: a[1] = 'g' -except TypeError: pass -else: raise TestFailed, "buffer assignment should raise TypeError" + try: a[1] = 'g' + except TypeError: pass + else: raise TestFailed, "buffer assignment should raise TypeError" -try: a[0:1] = 'g' -except TypeError: pass -else: raise TestFailed, "buffer slice assignment should raise TypeError" + try: a[0:1] = 'g' + except TypeError: pass + else: raise TestFailed, "buffer slice assignment should raise TypeError" -# array.array() returns an object that does not implement a char buffer, -# something which int() uses for conversion. -import array -try: int(buffer(array.array('c'))) -except TypeError :pass -else: raise TestFailed, "char buffer (at C level) not working" + # array.array() returns an object that does not implement a char buffer, + # something which int() uses for conversion. + import array + try: int(buffer(array.array('c'))) + except TypeError :pass + else: raise TestFailed, "char buffer (at C level) not working" Modified: branches/asm/Lib/test/test_zlib.py =================================================================== --- branches/asm/Lib/test/test_zlib.py 2008-07-08 20:38:02 UTC (rev 4877) +++ branches/asm/Lib/test/test_zlib.py 2008-07-08 21:05:48 UTC (rev 4878) @@ -33,12 +33,16 @@ def test_adler32start(self): self.assertEqual(zlib.adler32(""), zlib.adler32("", 1)) - self.assert_(zlib.adler32("abc", 0xffffffff)) + # XXX: Jython adler32 only supports start value of 1 + if not test_support.is_jython: + self.assert_(zlib.adler32("abc", 0xffffffff)) def test_adler32empty(self): - self.assertEqual(zlib.adler32("", 0), 0) + if not test_support.is_jython: + self.assertEqual(zlib.adler32("", 0), 0) self.assertEqual(zlib.adler32("", 1), 1) - self.assertEqual(zlib.adler32("", 432), 432) + if not test_support.is_jython: + self.assertEqual(zlib.adler32("", 432), 432) def assertEqual32(self, seen, expected): # 32-bit values masked -- checksums on 32- vs 64- bit machines @@ -48,7 +52,8 @@ def test_penguins(self): self.assertEqual32(zlib.crc32("penguin", 0), 0x0e5c1a120L) self.assertEqual32(zlib.crc32("penguin", 1), 0x43b6aa94) - self.assertEqual32(zlib.adler32("penguin", 0), 0x0bcf02f6) + if not test_support.is_jython: + self.assertEqual32(zlib.adler32("penguin", 0), 0x0bcf02f6) self.assertEqual32(zlib.adler32("penguin", 1), 0x0bd602f7) self.assertEqual(zlib.crc32("penguin"), zlib.crc32("penguin", 0)) Modified: branches/asm/Lib/zlib.py =================================================================== --- branches/asm/Lib/zlib.py 2008-07-08 20:38:02 UTC (rev 4877) +++ branches/asm/Lib/zlib.py 2008-07-08 21:05:48 UTC (rev 4878) @@ -118,10 +118,14 @@ return inflated - def flush(self): + def flush(self, length=None): if self._ended: raise error("decompressobj may not be used after flush()") - last = _get_inflate_data(self.inflater) + if length is None: + length = 0 + elif length <= 0: + raise ValueError('length must be greater than zero') + last = _get_inflate_data(self.inflater, length) self.inflater.end() return last This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-08 20:38:13
|
Revision: 4877 http://jython.svn.sourceforge.net/jython/?rev=4877&view=rev Author: pjenvey Date: 2008-07-08 13:38:02 -0700 (Tue, 08 Jul 2008) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_scope.py@50493 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_types.py@51140 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_zlib.py@62236 Modified Paths: -------------- branches/asm/Lib/test/test_scope.py branches/asm/Lib/test/test_types.py branches/asm/Lib/test/test_zlib.py Modified: branches/asm/Lib/test/test_scope.py =================================================================== --- branches/asm/Lib/test/test_scope.py 2008-07-08 19:55:47 UTC (rev 4876) +++ branches/asm/Lib/test/test_scope.py 2008-07-08 20:38:02 UTC (rev 4877) @@ -1,4 +1,4 @@ -from test_support import verify, TestFailed, check_syntax +from test.test_support import verify, TestFailed, check_syntax, vereq import warnings warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>") @@ -13,8 +13,8 @@ inc = make_adder(1) plus10 = make_adder(10) -verify(inc(1) == 2) -verify(plus10(-2) == 8) +vereq(inc(1), 2) +vereq(plus10(-2), 8) print "2. extra nesting" @@ -28,8 +28,8 @@ inc = make_adder2(1) plus10 = make_adder2(10) -verify(inc(1) == 2) -verify(plus10(-2) == 8) +vereq(inc(1), 2) +vereq(plus10(-2), 8) print "3. simple nesting + rebinding" @@ -42,8 +42,8 @@ inc = make_adder3(0) plus10 = make_adder3(9) -verify(inc(1) == 2) -verify(plus10(-2) == 8) +vereq(inc(1), 2) +vereq(plus10(-2), 8) print "4. nesting with global but no free" @@ -58,10 +58,10 @@ global_x = 1 adder = make_adder4() -verify(adder(1) == 2) +vereq(adder(1), 2) global_x = 10 -verify(adder(-2) == 8) +vereq(adder(-2), 8) print "5. nesting through class" @@ -74,8 +74,8 @@ inc = make_adder5(1) plus10 = make_adder5(10) -verify(inc(1) == 2) -verify(plus10(-2) == 8) +vereq(inc(1), 2) +vereq(plus10(-2), 8) print "6. nesting plus free ref to global" @@ -89,8 +89,8 @@ inc = make_adder6(1) plus10 = make_adder6(10) -verify(inc(1) == 11) # there's only one global -verify(plus10(-2) == 8) +vereq(inc(1), 11) # there's only one global +vereq(plus10(-2), 8) print "7. nearest enclosing scope" @@ -103,7 +103,7 @@ return g(2) test_func = f(10) -verify(test_func(5) == 47) +vereq(test_func(5), 47) print "8. mixed freevars and cellvars" @@ -123,7 +123,7 @@ g = f(1, 2, 3) h = g(2, 4, 6) -verify(h() == 39) +vereq(h(), 39) print "9. free variable in method" @@ -141,9 +141,9 @@ return Test() t = test() -verify(t.test() == "var") -verify(t.method_and_var() == "method") -verify(t.actual_global() == "global") +vereq(t.test(), "var") +vereq(t.method_and_var(), "method") +vereq(t.actual_global(), "global") method_and_var = "var" class Test: @@ -158,9 +158,9 @@ return str(self) t = Test() -verify(t.test() == "var") -verify(t.method_and_var() == "method") -verify(t.actual_global() == "global") +vereq(t.test(), "var") +vereq(t.method_and_var(), "method") +vereq(t.actual_global(), "global") print "10. recursion" @@ -175,7 +175,7 @@ else: raise ValueError, "x must be >= 0" -verify(f(6) == 720) +vereq(f(6), 720) print "11. unoptimized namespaces" @@ -252,24 +252,24 @@ f1 = lambda x: lambda y: x + y inc = f1(1) plus10 = f1(10) -verify(inc(1) == 2) -verify(plus10(5) == 15) +vereq(inc(1), 2) +vereq(plus10(5), 15) f2 = lambda x: (lambda : lambda y: x + y)() inc = f2(1) plus10 = f2(10) -verify(inc(1) == 2) -verify(plus10(5) == 15) +vereq(inc(1), 2) +vereq(plus10(5), 15) f3 = lambda x: lambda y: global_x + y global_x = 1 inc = f3(None) -verify(inc(2) == 3) +vereq(inc(2), 3) f8 = lambda x, y, z: lambda a, b, c: lambda : z * (b + y) g = f8(1, 2, 3) h = g(2, 4, 6) -verify(h() == 18) +vereq(h(), 18) print "13. UnboundLocal" @@ -299,6 +299,17 @@ else: raise TestFailed +# test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation +global_x = 1 +def f(): + global_x += 1 +try: + f() +except UnboundLocalError: + pass +else: + raise TestFailed, 'scope of global_x not correctly determined' + print "14. complex definitions" def makeReturner(*lst): @@ -306,21 +317,21 @@ return lst return returner -verify(makeReturner(1,2,3)() == (1,2,3)) +vereq(makeReturner(1,2,3)(), (1,2,3)) def makeReturner2(**kwargs): def returner(): return kwargs return returner -verify(makeReturner2(a=11)()['a'] == 11) +vereq(makeReturner2(a=11)()['a'], 11) def makeAddPair((a, b)): def addPair((c, d)): return (a + c, b + d) return addPair -verify(makeAddPair((1, 2))((100, 200)) == (101,202)) +vereq(makeAddPair((1, 2))((100, 200)), (101,202)) print "15. scope of global statements" # Examples posted by Samuele Pedroni to python-dev on 3/1/2001 @@ -337,8 +348,8 @@ return h() return i() return g() -verify(f() == 7) -verify(x == 7) +vereq(f(), 7) +vereq(x, 7) # II x = 7 @@ -352,8 +363,8 @@ return h() return i() return g() -verify(f() == 2) -verify(x == 7) +vereq(f(), 2) +vereq(x, 7) # III x = 7 @@ -368,8 +379,8 @@ return h() return i() return g() -verify(f() == 2) -verify(x == 2) +vereq(f(), 2) +vereq(x, 2) # IV x = 7 @@ -384,9 +395,26 @@ return h() return i() return g() -verify(f() == 2) -verify(x == 2) +vereq(f(), 2) +vereq(x, 2) +# XXX what about global statements in class blocks? +# do they affect methods? + +x = 12 +class Global: + global x + x = 13 + def set(self, val): + x = val + def get(self): + return x + +g = Global() +vereq(g.get(), 13) +g.set(15) +vereq(g.get(), 13) + print "16. check leaks" class Foo: @@ -407,13 +435,7 @@ for i in range(100): f1() -import os -if os.name == 'java': - from java.lang import System, Thread - System.gc() - Thread.sleep(100) - System.gc() -verify(Foo.count == 0) +vereq(Foo.count, 0) print "17. class and global" @@ -425,10 +447,19 @@ return Foo() x = 0 -verify(test(6)(2) == 8) +vereq(test(6)(2), 8) x = -1 -verify(test(3)(2) == 5) +vereq(test(3)(2), 5) +looked_up_by_load_name = False +class X: + # Implicit globals inside classes are be looked up by LOAD_NAME, not + # LOAD_GLOBAL. + locals()['looked_up_by_load_name'] = True + passed = looked_up_by_load_name + +verify(X.passed) + print "18. verify that locals() works" def f(x): @@ -443,7 +474,7 @@ d = f(2)(4) verify(d.has_key('h')) del d['h'] -verify(d == {'x': 2, 'y': 7, 'w': 6}) +vereq(d, {'x': 2, 'y': 7, 'w': 6}) print "19. var is bound and free in class" @@ -455,7 +486,7 @@ return C inst = f(3)() -verify(inst.a == inst.m()) +vereq(inst.a, inst.m()) print "20. interaction with trace function" Modified: branches/asm/Lib/test/test_types.py =================================================================== --- branches/asm/Lib/test/test_types.py 2008-07-08 19:55:47 UTC (rev 4876) +++ branches/asm/Lib/test/test_types.py 2008-07-08 20:38:02 UTC (rev 4877) @@ -1,4 +1,3 @@ -from __future__ import generators # Python test set -- part 6, built-in types from test.test_support import * @@ -11,15 +10,10 @@ if 0L: raise TestFailed, '0L is true instead of false' if 0.0: raise TestFailed, '0.0 is true instead of false' if '': raise TestFailed, '\'\' is true instead of false' -if (): raise TestFailed, '() is true instead of false' -if []: raise TestFailed, '[] is true instead of false' -if {}: raise TestFailed, '{} is true instead of false' if not 1: raise TestFailed, '1 is false instead of true' if not 1L: raise TestFailed, '1L is false instead of true' if not 1.0: raise TestFailed, '1.0 is false instead of true' if not 'x': raise TestFailed, '\'x\' is false instead of true' -if not (1, 1): raise TestFailed, '(1, 1) is false instead of true' -if not [1]: raise TestFailed, '[1] is false instead of true' if not {'x': 1}: raise TestFailed, '{\'x\': 1} is false instead of true' def f(): pass class C: pass @@ -45,9 +39,7 @@ else: raise TestFailed, 'float comparisons failed' if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass else: raise TestFailed, 'string comparisons failed' -if 0 in [0] and 0 not in [1]: pass -else: raise TestFailed, 'membership test failed' -if None is None and [] is not []: pass +if None is None: pass else: raise TestFailed, 'identity test failed' try: float('') @@ -98,6 +90,10 @@ if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass else: raise TestFailed, 'float() does not work properly' print '6.4.1 32-bit integers' +# Ensure the first 256 integers are shared +a = 256 +b = 128*2 +if a is not b: raise TestFailed, '256 is not shared' if 12 + 24 != 36: raise TestFailed, 'int op' if 12 + (-24) != -12: raise TestFailed, 'int op' if (-12) + 24 != 12: raise TestFailed, 'int op' @@ -218,546 +214,73 @@ vereq(a[-100L:100L:2L], unicode('02468', 'ascii')) -print '6.5.2 Tuples' -# calling built-in types without argument must return empty -if tuple() != (): raise TestFailed,'tuple() does not return ()' -if len(()) != 0: raise TestFailed, 'len(())' -if len((1,)) != 1: raise TestFailed, 'len((1,))' -if len((1,2,3,4,5,6)) != 6: raise TestFailed, 'len((1,2,3,4,5,6))' -if (1,2)+(3,4) != (1,2,3,4): raise TestFailed, 'tuple concatenation' -if (1,2)*3 != (1,2,1,2,1,2): raise TestFailed, 'tuple repetition *3' -if 0*(1,2,3) != (): raise TestFailed, 'tuple repetition 0*' -if min((1,2)) != 1 or max((1,2)) != 2: raise TestFailed, 'min/max tuple' -if 0 in (0,1,2) and 1 in (0,1,2) and 2 in (0,1,2) and 3 not in (0,1,2): pass -else: raise TestFailed, 'in/not in tuple' -try: ()[0] -except IndexError: pass -else: raise TestFailed, "tuple index error didn't raise IndexError" -x = () -x += () -if x != (): raise TestFailed, 'tuple inplace add from () to () failed' -x += (1,) -if x != (1,): raise TestFailed, 'tuple resize from () failed' +print '6.5.2 Tuples [see test_tuple.py]' -# extended slicing - subscript only for tuples -a = (0,1,2,3,4) -vereq(a[::], a) -vereq(a[::2], (0,2,4)) -vereq(a[1::2], (1,3)) -vereq(a[::-1], (4,3,2,1,0)) -vereq(a[::-2], (4,2,0)) -vereq(a[3::-2], (3,1)) -vereq(a[-100:100:], a) -vereq(a[100:-100:-1], a[::-1]) -vereq(a[-100L:100L:2L], (0,2,4)) +print '6.5.3 Lists [see test_list.py]' -# Check that a specific bug in _PyTuple_Resize() is squashed. -def f(): - for i in range(1000): - yield i -vereq(list(tuple(f())), range(1000)) +print '6.6 Mappings == Dictionaries [see test_dict.py]' -# Verify that __getitem__ overrides are not recognized by __iter__ -# XXX: this is a problem -#class T(tuple): -# def __getitem__(self, key): -# return str(key) + '!!!' -#vereq(iter(T((1,2))).next(), 1) -print '6.5.3 Lists' -# calling built-in types without argument must return empty -if list() != []: raise TestFailed,'list() does not return []' -if len([]) != 0: raise TestFailed, 'len([])' -if len([1,]) != 1: raise TestFailed, 'len([1,])' -if len([1,2,3,4,5,6]) != 6: raise TestFailed, 'len([1,2,3,4,5,6])' -if [1,2]+[3,4] != [1,2,3,4]: raise TestFailed, 'list concatenation' -if [1,2]*3 != [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3' -if [1,2]*3L != [1,2,1,2,1,2]: raise TestFailed, 'list repetition *3L' -if 0*[1,2,3] != []: raise TestFailed, 'list repetition 0*' -if 0L*[1,2,3] != []: raise TestFailed, 'list repetition 0L*' -if min([1,2]) != 1 or max([1,2]) != 2: raise TestFailed, 'min/max list' -if 0 in [0,1,2] and 1 in [0,1,2] and 2 in [0,1,2] and 3 not in [0,1,2]: pass -else: raise TestFailed, 'in/not in list' -a = [1, 2, 3, 4, 5] -a[:-1] = a -if a != [1, 2, 3, 4, 5, 5]: - raise TestFailed, "list self-slice-assign (head)" -a = [1, 2, 3, 4, 5] -a[1:] = a -if a != [1, 1, 2, 3, 4, 5]: - raise TestFailed, "list self-slice-assign (tail)" -a = [1, 2, 3, 4, 5] -a[1:-1] = a -if a != [1, 1, 2, 3, 4, 5, 5]: - raise TestFailed, "list self-slice-assign (center)" -try: [][0] -except IndexError: pass -else: raise TestFailed, "list index error didn't raise IndexError" -try: [][0] = 5 -except IndexError: pass -else: raise TestFailed, "list assignment index error didn't raise IndexError" -try: [].pop() -except IndexError: pass -else: raise TestFailed, "empty list.pop() didn't raise IndexError" -try: [1].pop(5) -except IndexError: pass -else: raise TestFailed, "[1].pop(5) didn't raise IndexError" - -try: [][0:1] = 5 +try: type(1, 2) except TypeError: pass -else: raise TestFailed, "bad list slice assignment didn't raise TypeError" -try: [].extend(None) -except TypeError: pass -else: raise TestFailed, "list.extend(None) didn't raise TypeError" -a = [1, 2, 3, 4] -a *= 0 -if a != []: - raise TestFailed, "list inplace repeat" +else: raise TestFailed, 'type(), w/2 args expected TypeError' -a = [] -a[:] = tuple(range(10)) -if a != range(10): - raise TestFailed, "assigning tuple to slice" - -print '6.5.3a Additional list operations' -a = [0,1,2,3,4] -a[0L] = 1 -a[1L] = 2 -a[2L] = 3 -if a != [1,2,3,3,4]: raise TestFailed, 'list item assignment [0L], [1L], [2L]' -a[0] = 5 -a[1] = 6 -a[2] = 7 -if a != [5,6,7,3,4]: raise TestFailed, 'list item assignment [0], [1], [2]' -a[-2L] = 88 -a[-1L] = 99 -if a != [5,6,7,88,99]: raise TestFailed, 'list item assignment [-2L], [-1L]' -a[-2] = 8 -a[-1] = 9 -if a != [5,6,7,8,9]: raise TestFailed, 'list item assignment [-2], [-1]' -a[:2] = [0,4] -a[-3:] = [] -a[1:1] = [1,2,3] -if a != [0,1,2,3,4]: raise TestFailed, 'list slice assignment' -a[ 1L : 4L] = [7,8,9] -if a != [0,7,8,9,4]: raise TestFailed, 'list slice assignment using long ints' -del a[1:4] -if a != [0,4]: raise TestFailed, 'list slice deletion' -del a[0] -if a != [4]: raise TestFailed, 'list item deletion [0]' -del a[-1] -if a != []: raise TestFailed, 'list item deletion [-1]' -a=range(0,5) -del a[1L:4L] -if a != [0,4]: raise TestFailed, 'list slice deletion' -del a[0L] -if a != [4]: raise TestFailed, 'list item deletion [0]' -del a[-1L] -if a != []: raise TestFailed, 'list item deletion [-1]' -a.append(0) -a.append(1) -a.append(2) -if a != [0,1,2]: raise TestFailed, 'list append' -a.insert(0, -2) -a.insert(1, -1) -a.insert(2,0) -if a != [-2,-1,0,0,1,2]: raise TestFailed, 'list insert' -b = a[:] -b.insert(-2, "foo") -b.insert(-200, "left") -b.insert(200, "right") -if b != ["left",-2,-1,0,0,"foo",1,2,"right"]: raise TestFailed, 'list insert2' -# a = [-2,-1,0,0,1,2] -if a.count(0) != 2: raise TestFailed, ' list count' -if a.index(0) != 2: raise TestFailed, 'list index' - -if a.index(0,2) != 2: raise TestFailed, 'list index, start argument' -if a.index(0,-4) != 2: raise TestFailed, 'list index, -start argument' -if a.index(-2,-10) != 0: raise TestFailed, 'list index, very -start argument' -if a.index(0,3) != 3: raise TestFailed, 'list index, start argument' -if a.index(0,-3) != 3: raise TestFailed, 'list index, -start argument' -if a.index(0,3,4) != 3: raise TestFailed, 'list index, stop argument' -if a.index(0,-3,-2) != 3: raise TestFailed, 'list index, -stop argument' -#XXX index with Long not working yet. -#if a.index(0,-4*sys.maxint,4*sys.maxint) != 2: -# raise TestFailed, 'list index, -maxint, maxint argument' -#try: -# a.index(0, 4*sys.maxint,-4*sys.maxint) -#except ValueError: -# pass -#else: -# raise TestFailed, 'list index, maxint,-maxint argument' - -try: - a.index(2,0,-10) -except ValueError: - pass -else: - raise TestFailed, 'list index, very -stop argument' -a.remove(0) -try: - a.index(2,0,4) -except ValueError: - pass -else: - raise TestFailed, 'list index, stop argument.' -if a != [-2,-1,0,1,2]: raise TestFailed, 'list remove' -a.reverse() -if a != [2,1,0,-1,-2]: raise TestFailed, 'list reverse' -a.sort() -if a != [-2,-1,0,1,2]: raise TestFailed, 'list sort' -def revcmp(a, b): return cmp(b, a) -a.sort(revcmp) -if a != [2,1,0,-1,-2]: raise TestFailed, 'list sort with cmp func' -# The following dumps core in unpatched Python 1.5: -def myComparison(x,y): - return cmp(x%3, y%7) -z = range(12) -z.sort(myComparison) - -try: z.sort(2) +try: type(1, 2, 3, 4) except TypeError: pass -else: raise TestFailed, 'list sort compare function is not callable' +else: raise TestFailed, 'type(), w/4 args expected TypeError' -def selfmodifyingComparison(x,y): - z.append(1) - return cmp(x, y) -try: z.sort(selfmodifyingComparison) +print 'Buffers' +try: buffer('asdf', -1) except ValueError: pass -else: raise TestFailed, 'modifying list during sort' +else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" +cmp(buffer("abc"), buffer("def")) # used to raise a warning: tp_compare didn't return -1, 0, or 1 -try: z.sort(lambda x, y: 's') +try: buffer(None) except TypeError: pass -else: raise TestFailed, 'list sort compare function does not return int' +else: raise TestFailed, "buffer(None) should raise TypeError" -# Test extreme cases with long ints -a = [0,1,2,3,4] -if a[ -pow(2,128L): 3 ] != [0,1,2]: - raise TestFailed, "list slicing with too-small long integer" -if a[ 3: pow(2,145L) ] != [3,4]: - raise TestFailed, "list slicing with too-large long integer" - - -# extended slicing - -# subscript -a = [0,1,2,3,4] -vereq(a[::], a) -vereq(a[::2], [0,2,4]) -vereq(a[1::2], [1,3]) -vereq(a[::-1], [4,3,2,1,0]) -vereq(a[::-2], [4,2,0]) -vereq(a[3::-2], [3,1]) -vereq(a[-100:100:], a) -vereq(a[100:-100:-1], a[::-1]) -vereq(a[-100L:100L:2L], [0,2,4]) -vereq(a[1000:2000:2], []) -vereq(a[-1000:-2000:-2], []) -# deletion -del a[::2] -vereq(a, [1,3]) -a = range(5) -del a[1::2] -vereq(a, [0,2,4]) -a = range(5) -del a[1::-2] -vereq(a, [0,2,3,4]) -a = range(10) -del a[::1000] -vereq(a, [1, 2, 3, 4, 5, 6, 7, 8, 9]) -# assignment -a = range(10) -a[::2] = [-1]*5 -vereq(a, [-1, 1, -1, 3, -1, 5, -1, 7, -1, 9]) -a = range(10) -a[::-4] = [10]*3 -vereq(a, [0, 10, 2, 3, 4, 10, 6, 7, 8 ,10]) -a = range(4) -a[::-1] = a -vereq(a, [3, 2, 1, 0]) -a = range(10) -b = a[:] -c = a[:] -a[2:3] = ["two", "elements"] -b[slice(2,3)] = ["two", "elements"] -c[2:3:] = ["two", "elements"] -vereq(a, b) -vereq(a, c) -a = range(10) -a[::2] = tuple(range(5)) -vereq(a, [0, 1, 1, 3, 2, 5, 3, 7, 4, 9]) - -# Verify that __getitem__ overrides are not recognized by __iter__ -class L(list): - def __getitem__(self, key): - return str(key) + '!!!' -vereq(iter(L([1,2])).next(), 1) - - -print '6.6 Mappings == Dictionaries' -# calling built-in types without argument must return empty -if dict() != {}: raise TestFailed,'dict() does not return {}' -d = {} -if d.keys() != []: raise TestFailed, '{}.keys()' -if d.values() != []: raise TestFailed, '{}.values()' -if d.items() != []: raise TestFailed, '{}.items()' -if d.has_key('a') != 0: raise TestFailed, '{}.has_key(\'a\')' -if ('a' in d) != 0: raise TestFailed, "'a' in {}" -if ('a' not in d) != 1: raise TestFailed, "'a' not in {}" -if len(d) != 0: raise TestFailed, 'len({})' -d = {'a': 1, 'b': 2} -if len(d) != 2: raise TestFailed, 'len(dict)' -k = d.keys() -k.sort() -if k != ['a', 'b']: raise TestFailed, 'dict keys()' -if d.has_key('a') and d.has_key('b') and not d.has_key('c'): pass -else: raise TestFailed, 'dict keys()' -if 'a' in d and 'b' in d and 'c' not in d: pass -else: raise TestFailed, 'dict keys() # in/not in version' -if d['a'] != 1 or d['b'] != 2: raise TestFailed, 'dict item' -d['c'] = 3 -d['a'] = 4 -if d['c'] != 3 or d['a'] != 4: raise TestFailed, 'dict item assignment' -del d['b'] -if d != {'a': 4, 'c': 3}: raise TestFailed, 'dict item deletion' -# dict.clear() -d = {1:1, 2:2, 3:3} -d.clear() -if d != {}: raise TestFailed, 'dict clear' -# dict.update() -d.update({1:100}) -d.update({2:20}) -d.update({1:1, 2:2, 3:3}) -if d != {1:1, 2:2, 3:3}: raise TestFailed, 'dict update' -d.clear() -try: d.update(None) -# XXX: AttributeError is 2.3 behavior, TypeError >= 2.4 -#except AttributeError: pass -except TypeError: pass -else: raise TestFailed, 'dict.update(None), AttributeError expected' -class SimpleUserDict: - def __init__(self): - self.d = {1:1, 2:2, 3:3} - def keys(self): - return self.d.keys() - def __getitem__(self, i): - return self.d[i] -d.update(SimpleUserDict()) -if d != {1:1, 2:2, 3:3}: raise TestFailed, 'dict.update(instance)' -d.clear() -class FailingUserDict: - def keys(self): - raise ValueError -try: d.update(FailingUserDict()) +a = buffer('asdf') +hash(a) +b = a * 5 +if a == b: + raise TestFailed, 'buffers should not be equal' +if str(b) != ('asdf' * 5): + raise TestFailed, 'repeated buffer has wrong content' +if str(a * 0) != '': + raise TestFailed, 'repeated buffer zero times has wrong content' +if str(a + buffer('def')) != 'asdfdef': + raise TestFailed, 'concatenation of buffers yields wrong content' +if str(buffer(a)) != 'asdf': + raise TestFailed, 'composing buffers failed' +if str(buffer(a, 2)) != 'df': + raise TestFailed, 'specifying buffer offset failed' +if str(buffer(a, 0, 2)) != 'as': + raise TestFailed, 'specifying buffer size failed' +if str(buffer(a, 1, 2)) != 'sd': + raise TestFailed, 'specifying buffer offset and size failed' +try: buffer(buffer('asdf', 1), -1) except ValueError: pass -else: raise TestFailed, 'dict.keys() expected ValueError' -class FailingUserDict: - def keys(self): - class BogonIter: - def __iter__(self): - raise ValueError - return BogonIter() -try: d.update(FailingUserDict()) -except ValueError: pass -else: raise TestFailed, 'iter(dict.keys()) expected ValueError' -class FailingUserDict: - def keys(self): - class BogonIter: - def __init__(self): - self.i = 1 - def __iter__(self): - return self - def next(self): - if self.i: - self.i = 0 - return 'a' - raise ValueError - return BogonIter() - def __getitem__(self, key): - return key -try: d.update(FailingUserDict()) -except ValueError: pass -else: raise TestFailed, 'iter(dict.keys()).next() expected ValueError' -class FailingUserDict: - def keys(self): - class BogonIter: - def __init__(self): - self.i = ord('a') - def __iter__(self): - return self - def next(self): - if self.i <= ord('z'): - rtn = chr(self.i) - self.i += 1 - return rtn - raise StopIteration - return BogonIter() - def __getitem__(self, key): - raise ValueError -try: d.update(FailingUserDict()) -except ValueError: pass -else: raise TestFailed, 'dict.update(), __getitem__ expected ValueError' -# dict.fromkeys() -if dict.fromkeys('abc') != {'a':None, 'b':None, 'c':None}: - raise TestFailed, 'dict.fromkeys did not work as a class method' -d = {} -if d.fromkeys('abc') is d: - raise TestFailed, 'dict.fromkeys did not return a new dict' -if d.fromkeys('abc') != {'a':None, 'b':None, 'c':None}: - raise TestFailed, 'dict.fromkeys failed with default value' -if d.fromkeys((4,5),0) != {4:0, 5:0}: - raise TestFailed, 'dict.fromkeys failed with specified value' -if d.fromkeys([]) != {}: - raise TestFailed, 'dict.fromkeys failed with null sequence' -def g(): - yield 1 -if d.fromkeys(g()) != {1:None}: - raise TestFailed, 'dict.fromkeys failed with a generator' -try: {}.fromkeys(3) -except TypeError: pass -else: raise TestFailed, 'dict.fromkeys failed to raise TypeError' -class dictlike(dict): pass -#if dictlike.fromkeys('a') != {'a':None}: -# raise TestFailed, 'dictsubclass.fromkeys did not inherit' -#if dictlike().fromkeys('a') != {'a':None}: -# raise TestFailed, 'dictsubclass.fromkeys did not inherit' -if type(dictlike.fromkeys('a')) is not dictlike: - raise TestFailed, 'dictsubclass.fromkeys created wrong type' -if type(dictlike().fromkeys('a')) is not dictlike: - raise TestFailed, 'dictsubclass.fromkeys created wrong type' -from UserDict import UserDict -class mydict(dict): - def __new__(cls): - return UserDict() -#ud = mydict.fromkeys('ab') -#if ud != {'a':None, 'b':None} or not isinstance(ud,UserDict): -# raise TestFailed, 'fromkeys did not instantiate using __new__' -# dict.copy() -d = {1:1, 2:2, 3:3} -if d.copy() != {1:1, 2:2, 3:3}: raise TestFailed, 'dict copy' -if {}.copy() != {}: raise TestFailed, 'empty dict copy' -# dict.get() -d = {} -if d.get('c') is not None: raise TestFailed, 'missing {} get, no 2nd arg' -if d.get('c', 3) != 3: raise TestFailed, 'missing {} get, w/ 2nd arg' -d = {'a' : 1, 'b' : 2} -if d.get('c') is not None: raise TestFailed, 'missing dict get, no 2nd arg' -if d.get('c', 3) != 3: raise TestFailed, 'missing dict get, w/ 2nd arg' -if d.get('a') != 1: raise TestFailed, 'present dict get, no 2nd arg' -if d.get('a', 3) != 1: raise TestFailed, 'present dict get, w/ 2nd arg' -# dict.setdefault() -d = {} -if d.setdefault('key0') is not None: - raise TestFailed, 'missing {} setdefault, no 2nd arg' -if d.setdefault('key0') is not None: - raise TestFailed, 'present {} setdefault, no 2nd arg' -d.setdefault('key', []).append(3) -if d['key'][0] != 3: - raise TestFailed, 'missing {} setdefault, w/ 2nd arg' -d.setdefault('key', []).append(4) -if len(d['key']) != 2: - raise TestFailed, 'present {} setdefault, w/ 2nd arg' -# dict.popitem() -for copymode in -1, +1: - # -1: b has same structure as a - # +1: b is a.copy() - for log2size in range(12): - size = 2**log2size - a = {} - b = {} - for i in range(size): - a[`i`] = i - if copymode < 0: - b[`i`] = i - if copymode > 0: - b = a.copy() - for i in range(size): - ka, va = ta = a.popitem() - if va != int(ka): raise TestFailed, "a.popitem: %s" % str(ta) - kb, vb = tb = b.popitem() - if vb != int(kb): raise TestFailed, "b.popitem: %s" % str(tb) - if copymode < 0 and ta != tb: - raise TestFailed, "a.popitem != b.popitem: %s, %s" % ( - str(ta), str(tb)) - if a: raise TestFailed, 'a not empty after popitems: %s' % str(a) - if b: raise TestFailed, 'b not empty after popitems: %s' % str(b) +else: raise TestFailed, "buffer(buffer('asdf', 1), -1) should raise ValueError" +if str(buffer(buffer('asdf', 0, 2), 0)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' +if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' +if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as': + raise TestFailed, 'composing length-specified buffer failed' +if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's': + raise TestFailed, 'composing length-specified buffer failed' -d.clear() -try: d.popitem() -except KeyError: pass -else: raise TestFailed, "{}.popitem doesn't raise KeyError" - -# Tests for pop with specified key -d.clear() -k, v = 'abc', 'def' -d[k] = v -try: d.pop('ghi') -except KeyError: pass -else: raise TestFailed, "{}.pop(k) doesn't raise KeyError when k not in dictionary" - -if d.pop(k) != v: raise TestFailed, "{}.pop(k) doesn't find known key/value pair" -if len(d) > 0: raise TestFailed, "{}.pop(k) failed to remove the specified pair" - -try: d.pop(k) -except KeyError: pass -else: raise TestFailed, "{}.pop(k) doesn't raise KeyError when dictionary is empty" - -# verify longs/ints get same value when key > 32 bits (for 64-bit archs) -# see SF bug #689659 -x = 4503599627370496L -y = 4503599627370496 -h = {x: 'anything', y: 'something else'} -if h[x] != h[y]: - raise TestFailed, "long/int key should match" - -if d.pop(k, v) != v: raise TestFailed, "{}.pop(k, v) doesn't return default value" -d[k] = v -if d.pop(k, 1) != v: raise TestFailed, "{}.pop(k, v) doesn't find known key/value pair" - -#XXX need locking strategy. -#d[1] = 1 -#try: -# for i in d: -# d[i+1] = 1 -#except RuntimeError: -# pass -#else: -# raise TestFailed, "changing dict size during iteration doesn't raise Error" - -try: type(1, 2) +try: a[1] = 'g' except TypeError: pass -else: raise TestFailed, 'type(), w/2 args expected TypeError' +else: raise TestFailed, "buffer assignment should raise TypeError" -try: type(1, 2, 3, 4) +try: a[0:1] = 'g' except TypeError: pass -else: raise TestFailed, 'type(), w/4 args expected TypeError' +else: raise TestFailed, "buffer slice assignment should raise TypeError" -#XXX: Jython will probably never have buffers -#print 'Buffers' -#try: buffer('asdf', -1) -#except ValueError: pass -#else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" -# -#try: buffer(None) -#except TypeError: pass -#else: raise TestFailed, "buffer(None) should raise TypeError" -# -#a = buffer('asdf') -#hash(a) -#b = a * 5 -#if a == b: -# raise TestFailed, 'buffers should not be equal' -#if str(b) != ('asdf' * 5): -# raise TestFailed, 'repeated buffer has wrong content' -#if str(a * 0) != '': -# raise TestFailed, 'repeated buffer zero times has wrong content' -#if str(a + buffer('def')) != 'asdfdef': -# raise TestFailed, 'concatenation of buffers yields wrong content' -# -#try: a[1] = 'g' -#except TypeError: pass -#else: raise TestFailed, "buffer assignment should raise TypeError" -# -#try: a[0:1] = 'g' -#except TypeError: pass -#else: raise TestFailed, "buffer slice assignment should raise TypeError" +# array.array() returns an object that does not implement a char buffer, +# something which int() uses for conversion. +import array +try: int(buffer(array.array('c'))) +except TypeError :pass +else: raise TestFailed, "char buffer (at C level) not working" Modified: branches/asm/Lib/test/test_zlib.py =================================================================== --- branches/asm/Lib/test/test_zlib.py 2008-07-08 19:55:47 UTC (rev 4876) +++ branches/asm/Lib/test/test_zlib.py 2008-07-08 20:38:02 UTC (rev 4877) @@ -33,30 +33,25 @@ def test_adler32start(self): self.assertEqual(zlib.adler32(""), zlib.adler32("", 1)) - ##self.assert_(zlib.adler32("abc", 0xffffffff)) + self.assert_(zlib.adler32("abc", 0xffffffff)) def test_adler32empty(self): - ##self.assertEqual(zlib.adler32("", 0), 0) + self.assertEqual(zlib.adler32("", 0), 0) self.assertEqual(zlib.adler32("", 1), 1) - ##self.assertEqual(zlib.adler32("", 432), 432) + self.assertEqual(zlib.adler32("", 432), 432) - def test_adler32_non7bit(self): - # Introduced on jython to test non-7-bit strings - self.assertEqual(zlib.adler32("\x80", 1), 8454273) - self.assertEqual(zlib.adler32("\x3b3", 1), 11206767) - def assertEqual32(self, seen, expected): # 32-bit values masked -- checksums on 32- vs 64- bit machines # This is important if bit 31 (0x08000000L) is set. self.assertEqual(seen & 0x0FFFFFFFFL, expected & 0x0FFFFFFFFL) def test_penguins(self): - ##self.assertEqual32(zlib.crc32("penguin", 0), 0x0e5c1a120L) + self.assertEqual32(zlib.crc32("penguin", 0), 0x0e5c1a120L) self.assertEqual32(zlib.crc32("penguin", 1), 0x43b6aa94) - ##self.assertEqual32(zlib.adler32("penguin", 0), 0x0bcf02f6) + self.assertEqual32(zlib.adler32("penguin", 0), 0x0bcf02f6) self.assertEqual32(zlib.adler32("penguin", 1), 0x0bd602f7) - ##self.assertEqual(zlib.crc32("penguin"), zlib.crc32("penguin", 0)) + self.assertEqual(zlib.crc32("penguin"), zlib.crc32("penguin", 0)) self.assertEqual(zlib.adler32("penguin"),zlib.adler32("penguin",1)) @@ -76,8 +71,13 @@ # verify failure on building decompress object with bad params self.assertRaises(ValueError, zlib.decompressobj, 0) + def test_decompressobj_badflush(self): + # verify failure on calling decompressobj.flush with bad params + self.assertRaises(ValueError, zlib.decompressobj().flush, 0) + self.assertRaises(ValueError, zlib.decompressobj().flush, -1) + class CompressTestCase(unittest.TestCase): # Test compression in one go (whole message compression) def test_speech(self): @@ -457,11 +457,12 @@ def test_main(): - for cls in (ChecksumTestCase, + test_support.run_unittest( + ChecksumTestCase, ExceptionTestCase, CompressTestCase, - CompressObjectTestCase): - test_support.run_unittest(cls) + CompressObjectTestCase + ) if __name__ == "__main__": test_main() @@ -483,5 +484,3 @@ su = ut.TestSuite() su.addTest(ut.makeSuite(tz.CompressTestCase)) ts.run_suite(su) - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-07-08 19:55:48
|
Revision: 4876 http://jython.svn.sourceforge.net/jython/?rev=4876&view=rev Author: pjenvey Date: 2008-07-08 12:55:47 -0700 (Tue, 08 Jul 2008) Log Message: ----------- always re-generating byte code is more trouble than it's worth right now (breaks the imp module) Modified Paths: -------------- branches/asm/src/org/python/core/imp.java branches/asm/src/org/python/modules/zipimport/zipimporter.java Modified: branches/asm/src/org/python/core/imp.java =================================================================== --- branches/asm/src/org/python/core/imp.java 2008-07-08 10:02:23 UTC (rev 4875) +++ branches/asm/src/org/python/core/imp.java 2008-07-08 19:55:47 UTC (rev 4876) @@ -127,11 +127,7 @@ } } */ - // XXX: always re-generate byte code until APIVersion is fixed. Note that - // zipimporter.isOutdatedBytecode is also disabled so that all zipimported - // bytecode is also always re-generated - //return data; - return null; + return data; } public static byte[] compileSource(String name, File file, String sourceFilename, Modified: branches/asm/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- branches/asm/src/org/python/modules/zipimport/zipimporter.java 2008-07-08 10:02:23 UTC (rev 4875) +++ branches/asm/src/org/python/modules/zipimport/zipimporter.java 2008-07-08 19:55:47 UTC (rev 4876) @@ -437,9 +437,6 @@ * @return boolean whether or not the byte code is older */ private boolean isOutdatedBytecode(String path, PyObject tocEntry) { - // XXX: Always recompile bytecode until bytecode APIVersion is fixed - return true; - /* String sourcePath = path.substring(0, path.length() - 9) + ".py"; PyObject sourceTocEntry = files.__finditem__(sourcePath); if (sourceTocEntry == null) { @@ -455,7 +452,6 @@ catch (PyObject.ConversionException ce) { return false; } - */ } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-07-08 10:02:25
|
Revision: 4875 http://jython.svn.sourceforge.net/jython/?rev=4875&view=rev Author: fwierzbicki Date: 2008-07-08 03:02:23 -0700 (Tue, 08 Jul 2008) Log Message: ----------- rename to reflect general demos, not particular events. Added Paths: ----------- trunk/sandbox/wierzbicki/demos/ trunk/sandbox/wierzbicki/demos/countries.py trunk/sandbox/wierzbicki/demos/mysite/templates/world/ trunk/sandbox/wierzbicki/demos/mysite/world/models.py trunk/sandbox/wierzbicki/demos/mysite/world/urls.py trunk/sandbox/wierzbicki/demos/world.sql Removed Paths: ------------- trunk/sandbox/wierzbicki/demos/countries.py trunk/sandbox/wierzbicki/demos/mysite/world/models.py Copied: trunk/sandbox/wierzbicki/demos (from rev 4648, trunk/sandbox/wierzbicki/javaone2008) Deleted: trunk/sandbox/wierzbicki/demos/countries.py =================================================================== --- trunk/sandbox/wierzbicki/javaone2008/countries.py 2008-06-16 05:23:39 UTC (rev 4648) +++ trunk/sandbox/wierzbicki/demos/countries.py 2008-07-08 10:02:23 UTC (rev 4875) @@ -1,738 +0,0 @@ -import os - -os.putenv("DJANGO_SETTINGS_MODULE", "mysite.settings") - -from mysite.world.models import Continent, Country - -#Continent.objects.remove() -#Country.objects.remove() - -#Continent -Asia = Continent(name='Asia') -Asia.save() -Europe = Continent(name='Europe') -Europe.save() -North_America = Continent(name='North America') -North_America.save() -Africa = Continent(name='Africa') -Africa.save() -Oceania = Continent(name='Oceania') -Oceania.save() -Antarctica = Continent(name='Antarctica') -Antarctica.save() -South_America = Continent(name='South America') -South_America.save() - -#Country -AFG = Country(code='AFG', name='Afghanistan',continent=Asia, region='Southern and Central Asia', surface_area=652090.00, indep_year=1919, population=22720000, life_expectancy=45.9, gnp=5976.00, gnp_old=None, local_name='Afganistan/Afqanestan', government_form='Islamic Emirate', head_of_state='Mohammad Omar',capital=None, code2='AF') -AFG.save() -NLD = Country(code='NLD', name='Netherlands',continent=Europe, region='Western Europe', surface_area=41526.00, indep_year=1581, population=15864000, life_expectancy=78.3, gnp=371362.00, gnp_old=360478.00, local_name='Nederland', government_form='Constitutional Monarchy', head_of_state='Beatrix',capital=None,code2='NL') -NLD.save() -ANT = Country(code='ANT', name='Netherlands Antilles',continent=North_America, region='Caribbean', surface_area=800.00, indep_year=None, population=217000, life_expectancy=74.7, gnp=1941.00, gnp_old=None, local_name='Nederlandse Antillen', government_form='Nonmetropolitan Territory of The Netherlands', head_of_state='Beatrix',capital=None,code2='AN') -ANT.save() -ALB = Country(code='ALB', name='Albania',continent=Europe, region='Southern Europe', surface_area=28748.00, indep_year=1912, population=3401200, life_expectancy=71.6, gnp=3205.00, gnp_old=2500.00, local_name='Shqipëria', government_form='Republic', head_of_state='Rexhep Mejdani',capital=None,code2='AL') -ALB.save() -DZA = Country(code='DZA', name='Algeria',continent=Africa, region='Northern Africa', surface_area=2381741.00, indep_year=1962, population=31471000, life_expectancy=69.7, gnp=49982.00, gnp_old=46966.00, local_name='Al-Jazair/Algérie', government_form='Republic', head_of_state='Abdelaziz Bouteflika',capital=None,code2='DZ') -DZA.save() -ASM = Country(code='ASM', name='American Samoa',continent=Oceania, region='Polynesia', surface_area=199.00, indep_year=None, population=68000, life_expectancy=75.1, gnp=334.00, gnp_old=None, local_name='Amerika Samoa', government_form='US Territory', head_of_state='George W. Bush',capital=None,code2='AS') -ASM.save() -AND = Country(code='AND', name='Andorra',continent=Europe, region='Southern Europe', surface_area=468.00, indep_year=1278, population=78000, life_expectancy=83.5, gnp=1630.00, gnp_old=None, local_name='Andorra', government_form='Parliamentary Coprincipality', head_of_state='',capital=None,code2='AD') -AND.save() -AGO = Country(code='AGO', name='Angola',continent=Africa, region='Central Africa', surface_area=1246700.00, indep_year=1975, population=12878000, life_expectancy=38.3, gnp=6648.00, gnp_old=7984.00, local_name='Angola', government_form='Republic', head_of_state='José Eduardo dos Santos',capital=None,code2='AO') -AGO.save() -AIA = Country(code='AIA', name='Anguilla',continent=North_America, region='Caribbean', surface_area=96.00, indep_year=None, population=8000, life_expectancy=76.1, gnp=63.20, gnp_old=None, local_name='Anguilla', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='AI') -AIA.save() -ATG = Country(code='ATG', name='Antigua and Barbuda',continent=North_America, region='Caribbean', surface_area=442.00, indep_year=1981, population=68000, life_expectancy=70.5, gnp=612.00, gnp_old=584.00, local_name='Antigua and Barbuda', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='AG') -ATG.save() -ARE = Country(code='ARE', name='United Arab Emirates',continent=Asia, region='Middle East', surface_area=83600.00, indep_year=1971, population=2441000, life_expectancy=74.1, gnp=37966.00, gnp_old=36846.00, local_name='Al-Imarat al-´Arabiya al-Muttahida', government_form='Emirate Federation', head_of_state='Zayid bin Sultan al-Nahayan',capital=None,code2='AE') -ARE.save() -ARG = Country(code='ARG', name='Argentina',continent=South_America, region='South America', surface_area=2780400.00, indep_year=1816, population=37032000, life_expectancy=75.1, gnp=340238.00, gnp_old=323310.00, local_name='Argentina', government_form='Federal Republic', head_of_state='Fernando de la Rúa',capital=None,code2='AR') -ARG.save() -ARM = Country(code='ARM', name='Armenia',continent=Asia, region='Middle East', surface_area=29800.00, indep_year=1991, population=3520000, life_expectancy=66.4, gnp=1813.00, gnp_old=1627.00, local_name='Hajastan', government_form='Republic', head_of_state='Robert Kotarjan',capital=None,code2='AM') -ARM.save() -ABW = Country(code='ABW', name='Aruba',continent=North_America, region='Caribbean', surface_area=193.00, indep_year=None, population=103000, life_expectancy=78.4, gnp=828.00, gnp_old=793.00, local_name='Aruba', government_form='Nonmetropolitan Territory of The Netherlands', head_of_state='Beatrix',capital=None,code2='AW') -ABW.save() -AUS = Country(code='AUS', name='Australia',continent=Oceania, region='Australia and New Zealand', surface_area=7741220.00, indep_year=1901, population=18886000, life_expectancy=79.8, gnp=351182.00, gnp_old=392911.00, local_name='Australia', government_form='Constitutional Monarchy, Federation', head_of_state='Elisabeth II',capital=None,code2='AU') -AUS.save() -AZE = Country(code='AZE', name='Azerbaijan',continent=Asia, region='Middle East', surface_area=86600.00, indep_year=1991, population=7734000, life_expectancy=62.9, gnp=4127.00, gnp_old=4100.00, local_name='Azärbaycan', government_form='Federal Republic', head_of_state='Heydär Äliyev',capital=None,code2='AZ') -AZE.save() -BHS = Country(code='BHS', name='Bahamas',continent=North_America, region='Caribbean', surface_area=13878.00, indep_year=1973, population=307000, life_expectancy=71.1, gnp=3527.00, gnp_old=3347.00, local_name='The Bahamas', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='BS') -BHS.save() -BHR = Country(code='BHR', name='Bahrain',continent=Asia, region='Middle East', surface_area=694.00, indep_year=1971, population=617000, life_expectancy=73.0, gnp=6366.00, gnp_old=6097.00, local_name='Al-Bahrayn', government_form='Monarchy (Emirate)', head_of_state='Hamad ibn Isa al-Khalifa',capital=None,code2='BH') -BHR.save() -BGD = Country(code='BGD', name='Bangladesh',continent=Asia, region='Southern and Central Asia', surface_area=143998.00, indep_year=1971, population=129155000, life_expectancy=60.2, gnp=32852.00, gnp_old=31966.00, local_name='Bangladesh', government_form='Republic', head_of_state='Shahabuddin Ahmad',capital=None,code2='BD') -BGD.save() -BRB = Country(code='BRB', name='Barbados',continent=North_America, region='Caribbean', surface_area=430.00, indep_year=1966, population=270000, life_expectancy=73.0, gnp=2223.00, gnp_old=2186.00, local_name='Barbados', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='BB') -BRB.save() -BEL = Country(code='BEL', name='Belgium',continent=Europe, region='Western Europe', surface_area=30518.00, indep_year=1830, population=10239000, life_expectancy=77.8, gnp=249704.00, gnp_old=243948.00, local_name='België/Belgique', government_form='Constitutional Monarchy, Federation', head_of_state='Albert II',capital=None,code2='BE') -BEL.save() -BLZ = Country(code='BLZ', name='Belize',continent=North_America, region='Central America', surface_area=22696.00, indep_year=1981, population=241000, life_expectancy=70.9, gnp=630.00, gnp_old=616.00, local_name='Belize', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='BZ') -BLZ.save() -BEN = Country(code='BEN', name='Benin',continent=Africa, region='Western Africa', surface_area=112622.00, indep_year=1960, population=6097000, life_expectancy=50.2, gnp=2357.00, gnp_old=2141.00, local_name='Bénin', government_form='Republic', head_of_state='Mathieu Kérékou',capital=None,code2='BJ') -BEN.save() -BMU = Country(code='BMU', name='Bermuda',continent=North_America, region='North America', surface_area=53.00, indep_year=None, population=65000, life_expectancy=76.9, gnp=2328.00, gnp_old=2190.00, local_name='Bermuda', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='BM') -BMU.save() -BTN = Country(code='BTN', name='Bhutan',continent=Asia, region='Southern and Central Asia', surface_area=47000.00, indep_year=1910, population=2124000, life_expectancy=52.4, gnp=372.00, gnp_old=383.00, local_name='Druk-Yul', government_form='Monarchy', head_of_state='Jigme Singye Wangchuk',capital=None,code2='BT') -BTN.save() -BOL = Country(code='BOL', name='Bolivia',continent=South_America, region='South America', surface_area=1098581.00, indep_year=1825, population=8329000, life_expectancy=63.7, gnp=8571.00, gnp_old=7967.00, local_name='Bolivia', government_form='Republic', head_of_state='Hugo Bánzer Suárez',capital=None,code2='BO') -BOL.save() -BIH = Country(code='BIH', name='Bosnia and Herzegovina',continent=Europe, region='Southern Europe', surface_area=51197.00, indep_year=1992, population=3972000, life_expectancy=71.5, gnp=2841.00, gnp_old=None, local_name='Bosna i Hercegovina', government_form='Federal Republic', head_of_state='Ante Jelavic',capital=None,code2='BA') -BIH.save() -BWA = Country(code='BWA', name='Botswana',continent=Africa, region='Southern Africa', surface_area=581730.00, indep_year=1966, population=1622000, life_expectancy=39.3, gnp=4834.00, gnp_old=4935.00, local_name='Botswana', government_form='Republic', head_of_state='Festus G. Mogae',capital=None,code2='BW') -BWA.save() -BRA = Country(code='BRA', name='Brazil',continent=South_America, region='South America', surface_area=8547403.00, indep_year=1822, population=170115000, life_expectancy=62.9, gnp=776739.00, gnp_old=804108.00, local_name='Brasil', government_form='Federal Republic', head_of_state='Fernando Henrique Cardoso',capital=None,code2='BR') -BRA.save() -GBR = Country(code='GBR', name='United Kingdom',continent=Europe, region='British Islands', surface_area=242900.00, indep_year=1066, population=59623400, life_expectancy=77.7, gnp=1378330.00, gnp_old=1296830.00, local_name='United Kingdom', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='GB') -GBR.save() -VGB = Country(code='VGB', name='Virgin Islands, British',continent=North_America, region='Caribbean', surface_area=151.00, indep_year=None, population=21000, life_expectancy=75.4, gnp=612.00, gnp_old=573.00, local_name='British Virgin Islands', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='VG') -VGB.save() -BRN = Country(code='BRN', name='Brunei',continent=Asia, region='Southeast Asia', surface_area=5765.00, indep_year=1984, population=328000, life_expectancy=73.6, gnp=11705.00, gnp_old=12460.00, local_name='Brunei Darussalam', government_form='Monarchy (Sultanate)', head_of_state='Haji Hassan al-Bolkiah',capital=None,code2='BN') -BRN.save() -BGR = Country(code='BGR', name='Bulgaria',continent=Europe, region='Eastern Europe', surface_area=110994.00, indep_year=1908, population=8190900, life_expectancy=70.9, gnp=12178.00, gnp_old=10169.00, local_name='Balgarija', government_form='Republic', head_of_state='Petar Stojanov',capital=None,code2='BG') -BGR.save() -BFA = Country(code='BFA', name='Burkina Faso',continent=Africa, region='Western Africa', surface_area=274000.00, indep_year=1960, population=11937000, life_expectancy=46.7, gnp=2425.00, gnp_old=2201.00, local_name='Burkina Faso', government_form='Republic', head_of_state='Blaise Compaoré',capital=None,code2='BF') -BFA.save() -BDI = Country(code='BDI', name='Burundi',continent=Africa, region='Eastern Africa', surface_area=27834.00, indep_year=1962, population=6695000, life_expectancy=46.2, gnp=903.00, gnp_old=982.00, local_name='Burundi/Uburundi', government_form='Republic', head_of_state='Pierre Buyoya',capital=None,code2='BI') -BDI.save() -CYM = Country(code='CYM', name='Cayman Islands',continent=North_America, region='Caribbean', surface_area=264.00, indep_year=None, population=38000, life_expectancy=78.9, gnp=1263.00, gnp_old=1186.00, local_name='Cayman Islands', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='KY') -CYM.save() -CHL = Country(code='CHL', name='Chile',continent=South_America, region='South America', surface_area=756626.00, indep_year=1810, population=15211000, life_expectancy=75.7, gnp=72949.00, gnp_old=75780.00, local_name='Chile', government_form='Republic', head_of_state='Ricardo Lagos Escobar',capital=None,code2='CL') -CHL.save() -COK = Country(code='COK', name='Cook Islands',continent=Oceania, region='Polynesia', surface_area=236.00, indep_year=None, population=20000, life_expectancy=71.1, gnp=100.00, gnp_old=None, local_name='The Cook Islands', government_form='Nonmetropolitan Territory of New Zealand', head_of_state='Elisabeth II',capital=None,code2='CK') -COK.save() -CRI = Country(code='CRI', name='Costa Rica',continent=North_America, region='Central America', surface_area=51100.00, indep_year=1821, population=4023000, life_expectancy=75.8, gnp=10226.00, gnp_old=9757.00, local_name='Costa Rica', government_form='Republic', head_of_state='Miguel Ángel Rodríguez Echeverría',capital=None,code2='CR') -CRI.save() -DJI = Country(code='DJI', name='Djibouti',continent=Africa, region='Eastern Africa', surface_area=23200.00, indep_year=1977, population=638000, life_expectancy=50.8, gnp=382.00, gnp_old=373.00, local_name='Djibouti/Jibuti', government_form='Republic', head_of_state='Ismail Omar Guelleh',capital=None,code2='DJ') -DJI.save() -DMA = Country(code='DMA', name='Dominica',continent=North_America, region='Caribbean', surface_area=751.00, indep_year=1978, population=71000, life_expectancy=73.4, gnp=256.00, gnp_old=243.00, local_name='Dominica', government_form='Republic', head_of_state='Vernon Shaw',capital=None,code2='DM') -DMA.save() -DOM = Country(code='DOM', name='Dominican Republic',continent=North_America, region='Caribbean', surface_area=48511.00, indep_year=1844, population=8495000, life_expectancy=73.2, gnp=15846.00, gnp_old=15076.00, local_name='República Dominicana', government_form='Republic', head_of_state='Hipólito Mejía Domínguez',capital=None,code2='DO') -DOM.save() -ECU = Country(code='ECU', name='Ecuador',continent=South_America, region='South America', surface_area=283561.00, indep_year=1822, population=12646000, life_expectancy=71.1, gnp=19770.00, gnp_old=19769.00, local_name='Ecuador', government_form='Republic', head_of_state='Gustavo Noboa Bejarano',capital=None,code2='EC') -ECU.save() -EGY = Country(code='EGY', name='Egypt',continent=Africa, region='Northern Africa', surface_area=1001449.00, indep_year=1922, population=68470000, life_expectancy=63.3, gnp=82710.00, gnp_old=75617.00, local_name='Misr', government_form='Republic', head_of_state='Hosni Mubarak',capital=None,code2='EG') -EGY.save() -SLV = Country(code='SLV', name='El Salvador',continent=North_America, region='Central America', surface_area=21041.00, indep_year=1841, population=6276000, life_expectancy=69.7, gnp=11863.00, gnp_old=11203.00, local_name='El Salvador', government_form='Republic', head_of_state='Francisco Guillermo Flores Pérez',capital=None,code2='SV') -SLV.save() -ERI = Country(code='ERI', name='Eritrea',continent=Africa, region='Eastern Africa', surface_area=117600.00, indep_year=1993, population=3850000, life_expectancy=55.8, gnp=650.00, gnp_old=755.00, local_name='Ertra', government_form='Republic', head_of_state='Isayas Afewerki [Isaias Afwerki]',capital=None,code2='ER') -ERI.save() -ESP = Country(code='ESP', name='Spain',continent=Europe, region='Southern Europe', surface_area=505992.00, indep_year=1492, population=39441700, life_expectancy=78.8, gnp=553233.00, gnp_old=532031.00, local_name='España', government_form='Constitutional Monarchy', head_of_state='Juan Carlos I',capital=None,code2='ES') -ESP.save() -ZAF = Country(code='ZAF', name='South Africa',continent=Africa, region='Southern Africa', surface_area=1221037.00, indep_year=1910, population=40377000, life_expectancy=51.1, gnp=116729.00, gnp_old=129092.00, local_name='South Africa', government_form='Republic', head_of_state='Thabo Mbeki',capital=None,code2='ZA') -ZAF.save() -ETH = Country(code='ETH', name='Ethiopia',continent=Africa, region='Eastern Africa', surface_area=1104300.00, indep_year=-1000, population=62565000, life_expectancy=45.2, gnp=6353.00, gnp_old=6180.00, local_name='YeItyop´iya', government_form='Republic', head_of_state='Negasso Gidada',capital=None,code2='ET') -ETH.save() -FLK = Country(code='FLK', name='Falkland Islands',continent=South_America, region='South America', surface_area=12173.00, indep_year=None, population=2000, life_expectancy=None, gnp=0.00, gnp_old=None, local_name='Falkland Islands', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='FK') -FLK.save() -FJI = Country(code='FJI', name='Fiji Islands',continent=Oceania, region='Melanesia', surface_area=18274.00, indep_year=1970, population=817000, life_expectancy=67.9, gnp=1536.00, gnp_old=2149.00, local_name='Fiji Islands', government_form='Republic', head_of_state='Josefa Iloilo',capital=None,code2='FJ') -FJI.save() -PHL = Country(code='PHL', name='Philippines',continent=Asia, region='Southeast Asia', surface_area=300000.00, indep_year=1946, population=75967000, life_expectancy=67.5, gnp=65107.00, gnp_old=82239.00, local_name='Pilipinas', government_form='Republic', head_of_state='Gloria Macapagal-Arroyo',capital=None,code2='PH') -PHL.save() -FRO = Country(code='FRO', name='Faroe Islands',continent=Europe, region='Nordic Countries', surface_area=1399.00, indep_year=None, population=43000, life_expectancy=78.4, gnp=0.00, gnp_old=None, local_name='Føroyar', government_form='Part of Denmark', head_of_state='Margrethe II',capital=None,code2='FO') -FRO.save() -GAB = Country(code='GAB', name='Gabon',continent=Africa, region='Central Africa', surface_area=267668.00, indep_year=1960, population=1226000, life_expectancy=50.1, gnp=5493.00, gnp_old=5279.00, local_name='Le Gabon', government_form='Republic', head_of_state='Omar Bongo',capital=None,code2='GA') -GAB.save() -GMB = Country(code='GMB', name='Gambia',continent=Africa, region='Western Africa', surface_area=11295.00, indep_year=1965, population=1305000, life_expectancy=53.2, gnp=320.00, gnp_old=325.00, local_name='The Gambia', government_form='Republic', head_of_state='Yahya Jammeh',capital=None,code2='GM') -GMB.save() -GEO = Country(code='GEO', name='Georgia',continent=Asia, region='Middle East', surface_area=69700.00, indep_year=1991, population=4968000, life_expectancy=64.5, gnp=6064.00, gnp_old=5924.00, local_name='Sakartvelo', government_form='Republic', head_of_state='Eduard evardnadze',capital=None,code2='GE') -GEO.save() -GHA = Country(code='GHA', name='Ghana',continent=Africa, region='Western Africa', surface_area=238533.00, indep_year=1957, population=20212000, life_expectancy=57.4, gnp=7137.00, gnp_old=6884.00, local_name='Ghana', government_form='Republic', head_of_state='John Kufuor',capital=None,code2='GH') -GHA.save() -GIB = Country(code='GIB', name='Gibraltar',continent=Europe, region='Southern Europe', surface_area=6.00, indep_year=None, population=25000, life_expectancy=79.0, gnp=258.00, gnp_old=None, local_name='Gibraltar', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='GI') -GIB.save() -GRD = Country(code='GRD', name='Grenada',continent=North_America, region='Caribbean', surface_area=344.00, indep_year=1974, population=94000, life_expectancy=64.5, gnp=318.00, gnp_old=None, local_name='Grenada', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='GD') -GRD.save() -GRL = Country(code='GRL', name='Greenland',continent=North_America, region='North America', surface_area=2166090.00, indep_year=None, population=56000, life_expectancy=68.1, gnp=0.00, gnp_old=None, local_name='Kalaallit Nunaat/Grønland', government_form='Part of Denmark', head_of_state='Margrethe II',capital=None,code2='GL') -GRL.save() -GLP = Country(code='GLP', name='Guadeloupe',continent=North_America, region='Caribbean', surface_area=1705.00, indep_year=None, population=456000, life_expectancy=77.0, gnp=3501.00, gnp_old=None, local_name='Guadeloupe', government_form='Overseas Department of France', head_of_state='Jacques Chirac',capital=None,code2='GP') -GLP.save() -GUM = Country(code='GUM', name='Guam',continent=Oceania, region='Micronesia', surface_area=549.00, indep_year=None, population=168000, life_expectancy=77.8, gnp=1197.00, gnp_old=1136.00, local_name='Guam', government_form='US Territory', head_of_state='George W. Bush',capital=None,code2='GU') -GUM.save() -GTM = Country(code='GTM', name='Guatemala',continent=North_America, region='Central America', surface_area=108889.00, indep_year=1821, population=11385000, life_expectancy=66.2, gnp=19008.00, gnp_old=17797.00, local_name='Guatemala', government_form='Republic', head_of_state='Alfonso Portillo Cabrera',capital=None,code2='GT') -GTM.save() -GIN = Country(code='GIN', name='Guinea',continent=Africa, region='Western Africa', surface_area=245857.00, indep_year=1958, population=7430000, life_expectancy=45.6, gnp=2352.00, gnp_old=2383.00, local_name='Guinée', government_form='Republic', head_of_state='Lansana Conté',capital=None,code2='GN') -GIN.save() -GNB = Country(code='GNB', name='Guinea-Bissau',continent=Africa, region='Western Africa', surface_area=36125.00, indep_year=1974, population=1213000, life_expectancy=49.0, gnp=293.00, gnp_old=272.00, local_name='Guiné-Bissau', government_form='Republic', head_of_state='Kumba Ialá',capital=None,code2='GW') -GNB.save() -GUY = Country(code='GUY', name='Guyana',continent=South_America, region='South America', surface_area=214969.00, indep_year=1966, population=861000, life_expectancy=64.0, gnp=722.00, gnp_old=743.00, local_name='Guyana', government_form='Republic', head_of_state='Bharrat Jagdeo',capital=None,code2='GY') -GUY.save() -HTI = Country(code='HTI', name='Haiti',continent=North_America, region='Caribbean', surface_area=27750.00, indep_year=1804, population=8222000, life_expectancy=49.2, gnp=3459.00, gnp_old=3107.00, local_name='Haïti/Dayti', government_form='Republic', head_of_state='Jean-Bertrand Aristide',capital=None,code2='HT') -HTI.save() -HND = Country(code='HND', name='Honduras',continent=North_America, region='Central America', surface_area=112088.00, indep_year=1838, population=6485000, life_expectancy=69.9, gnp=5333.00, gnp_old=4697.00, local_name='Honduras', government_form='Republic', head_of_state='Carlos Roberto Flores Facussé',capital=None,code2='HN') -HND.save() -HKG = Country(code='HKG', name='Hong Kong',continent=Asia, region='Eastern Asia', surface_area=1075.00, indep_year=None, population=6782000, life_expectancy=79.5, gnp=166448.00, gnp_old=173610.00, local_name='Xianggang/Hong Kong', government_form='Special Administrative Region of China', head_of_state='Jiang Zemin',capital=None,code2='HK') -HKG.save() -SJM = Country(code='SJM', name='Svalbard and Jan Mayen',continent=Europe, region='Nordic Countries', surface_area=62422.00, indep_year=None, population=3200, life_expectancy=None, gnp=0.00, gnp_old=None, local_name='Svalbard og Jan Mayen', government_form='Dependent Territory of Norway', head_of_state='Harald V',capital=None,code2='SJ') -SJM.save() -IDN = Country(code='IDN', name='Indonesia',continent=Asia, region='Southeast Asia', surface_area=1904569.00, indep_year=1945, population=212107000, life_expectancy=68.0, gnp=84982.00, gnp_old=215002.00, local_name='Indonesia', government_form='Republic', head_of_state='Abdurrahman Wahid',capital=None,code2='ID') -IDN.save() -IND = Country(code='IND', name='India',continent=Asia, region='Southern and Central Asia', surface_area=3287263.00, indep_year=1947, population=1013662000, life_expectancy=62.5, gnp=447114.00, gnp_old=430572.00, local_name='Bharat/India', government_form='Federal Republic', head_of_state='Kocheril Raman Narayanan',capital=None,code2='IN') -IND.save() -IRQ = Country(code='IRQ', name='Iraq',continent=Asia, region='Middle East', surface_area=438317.00, indep_year=1932, population=23115000, life_expectancy=66.5, gnp=11500.00, gnp_old=None, local_name='Al-´Iraq', government_form='Republic', head_of_state='Saddam Hussein al-Takriti',capital=None,code2='IQ') -IRQ.save() -IRN = Country(code='IRN', name='Iran',continent=Asia, region='Southern and Central Asia', surface_area=1648195.00, indep_year=1906, population=67702000, life_expectancy=69.7, gnp=195746.00, gnp_old=160151.00, local_name='Iran', government_form='Islamic Republic', head_of_state='Ali Mohammad Khatami-Ardakani',capital=None,code2='IR') -IRN.save() -IRL = Country(code='IRL', name='Ireland',continent=Europe, region='British Islands', surface_area=70273.00, indep_year=1921, population=3775100, life_expectancy=76.8, gnp=75921.00, gnp_old=73132.00, local_name='Ireland/Éire', government_form='Republic', head_of_state='Mary McAleese',capital=None,code2='IE') -IRL.save() -ISL = Country(code='ISL', name='Iceland',continent=Europe, region='Nordic Countries', surface_area=103000.00, indep_year=1944, population=279000, life_expectancy=79.4, gnp=8255.00, gnp_old=7474.00, local_name='Ísland', government_form='Republic', head_of_state='Ólafur Ragnar Grímsson',capital=None,code2='IS') -ISL.save() -ISR = Country(code='ISR', name='Israel',continent=Asia, region='Middle East', surface_area=21056.00, indep_year=1948, population=6217000, life_expectancy=78.6, gnp=97477.00, gnp_old=98577.00, local_name='Yisrael/Israil', government_form='Republic', head_of_state='Moshe Katzav',capital=None,code2='IL') -ISR.save() -ITA = Country(code='ITA', name='Italy',continent=Europe, region='Southern Europe', surface_area=301316.00, indep_year=1861, population=57680000, life_expectancy=79.0, gnp=1161755.00, gnp_old=1145372.00, local_name='Italia', government_form='Republic', head_of_state='Carlo Azeglio Ciampi',capital=None,code2='IT') -ITA.save() -TMP = Country(code='TMP', name='East Timor',continent=Asia, region='Southeast Asia', surface_area=14874.00, indep_year=None, population=885000, life_expectancy=46.0, gnp=0.00, gnp_old=None, local_name='Timor Timur', government_form='Administrated by the UN', head_of_state='José Alexandre Gusmão',capital=None,code2='TP') -TMP.save() -AUT = Country(code='AUT', name='Austria',continent=Europe, region='Western Europe', surface_area=83859.00, indep_year=1918, population=8091800, life_expectancy=77.7, gnp=211860.00, gnp_old=206025.00, local_name='Österreich', government_form='Federal Republic', head_of_state='Thomas Klestil',capital=None,code2='AT') -AUT.save() -JAM = Country(code='JAM', name='Jamaica',continent=North_America, region='Caribbean', surface_area=10990.00, indep_year=1962, population=2583000, life_expectancy=75.2, gnp=6871.00, gnp_old=6722.00, local_name='Jamaica', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='JM') -JAM.save() -JPN = Country(code='JPN', name='Japan',continent=Asia, region='Eastern Asia', surface_area=377829.00, indep_year=-660, population=126714000, life_expectancy=80.7, gnp=3787042.00, gnp_old=4192638.00, local_name='Nihon/Nippon', government_form='Constitutional Monarchy', head_of_state='Akihito',capital=None,code2='JP') -JPN.save() -YEM = Country(code='YEM', name='Yemen',continent=Asia, region='Middle East', surface_area=527968.00, indep_year=1918, population=18112000, life_expectancy=59.8, gnp=6041.00, gnp_old=5729.00, local_name='Al-Yaman', government_form='Republic', head_of_state='Ali Abdallah Salih',capital=None,code2='YE') -YEM.save() -JOR = Country(code='JOR', name='Jordan',continent=Asia, region='Middle East', surface_area=88946.00, indep_year=1946, population=5083000, life_expectancy=77.4, gnp=7526.00, gnp_old=7051.00, local_name='Al-Urdunn', government_form='Constitutional Monarchy', head_of_state='Abdullah II',capital=None,code2='JO') -JOR.save() -CXR = Country(code='CXR', name='Christmas Island',continent=Oceania, region='Australia and New Zealand', surface_area=135.00, indep_year=None, population=2500, life_expectancy=None, gnp=0.00, gnp_old=None, local_name='Christmas Island', government_form='Territory of Australia', head_of_state='Elisabeth II',capital=None,code2='CX') -CXR.save() -YUG = Country(code='YUG', name='Yugoslavia',continent=Europe, region='Southern Europe', surface_area=102173.00, indep_year=1918, population=10640000, life_expectancy=72.4, gnp=17000.00, gnp_old=None, local_name='Jugoslavija', government_form='Federal Republic', head_of_state='Vojislav Kotunica',capital=None,code2='YU') -YUG.save() -KHM = Country(code='KHM', name='Cambodia',continent=Asia, region='Southeast Asia', surface_area=181035.00, indep_year=1953, population=11168000, life_expectancy=56.5, gnp=5121.00, gnp_old=5670.00, local_name='Kâmpuchéa', government_form='Constitutional Monarchy', head_of_state='Norodom Sihanouk',capital=None,code2='KH') -KHM.save() -CMR = Country(code='CMR', name='Cameroon',continent=Africa, region='Central Africa', surface_area=475442.00, indep_year=1960, population=15085000, life_expectancy=54.8, gnp=9174.00, gnp_old=8596.00, local_name='Cameroun/Cameroon', government_form='Republic', head_of_state='Paul Biya',capital=None,code2='CM') -CMR.save() -CAN = Country(code='CAN', name='Canada',continent=North_America, region='North America', surface_area=9970610.00, indep_year=1867, population=31147000, life_expectancy=79.4, gnp=598862.00, gnp_old=625626.00, local_name='Canada', government_form='Constitutional Monarchy, Federation', head_of_state='Elisabeth II',capital=None,code2='CA') -CAN.save() -CPV = Country(code='CPV', name='Cape Verde',continent=Africa, region='Western Africa', surface_area=4033.00, indep_year=1975, population=428000, life_expectancy=68.9, gnp=435.00, gnp_old=420.00, local_name='Cabo Verde', government_form='Republic', head_of_state='António Mascarenhas Monteiro',capital=None,code2='CV') -CPV.save() -KAZ = Country(code='KAZ', name='Kazakstan',continent=Asia, region='Southern and Central Asia', surface_area=2724900.00, indep_year=1991, population=16223000, life_expectancy=63.2, gnp=24375.00, gnp_old=23383.00, local_name='Qazaqstan', government_form='Republic', head_of_state='Nursultan Nazarbajev',capital=None,code2='KZ') -KAZ.save() -KEN = Country(code='KEN', name='Kenya',continent=Africa, region='Eastern Africa', surface_area=580367.00, indep_year=1963, population=30080000, life_expectancy=48.0, gnp=9217.00, gnp_old=10241.00, local_name='Kenya', government_form='Republic', head_of_state='Daniel arap Moi',capital=None,code2='KE') -KEN.save() -CAF = Country(code='CAF', name='Central African Republic',continent=Africa, region='Central Africa', surface_area=622984.00, indep_year=1960, population=3615000, life_expectancy=44.0, gnp=1054.00, gnp_old=993.00, local_name='Centrafrique/Bê-Afrîka', government_form='Republic', head_of_state='Ange-Félix Patassé',capital=None,code2='CF') -CAF.save() -CHN = Country(code='CHN', name='China',continent=Asia, region='Eastern Asia', surface_area=9572900.00, indep_year=-1523, population=1277558000, life_expectancy=71.4, gnp=982268.00, gnp_old=917719.00, local_name='Zhongquo', government_form='People\'sRepublic', head_of_state='Jiang Zemin',capital=None,code2='CN') -CHN.save() -KGZ = Country(code='KGZ', name='Kyrgyzstan',continent=Asia, region='Southern and Central Asia', surface_area=199900.00, indep_year=1991, population=4699000, life_expectancy=63.4, gnp=1626.00, gnp_old=1767.00, local_name='Kyrgyzstan', government_form='Republic', head_of_state='Askar Akajev',capital=None,code2='KG') -KGZ.save() -KIR = Country(code='KIR', name='Kiribati',continent=Oceania, region='Micronesia', surface_area=726.00, indep_year=1979, population=83000, life_expectancy=59.8, gnp=40.70, gnp_old=None, local_name='Kiribati', government_form='Republic', head_of_state='Teburoro Tito',capital=None,code2='KI') -KIR.save() -COL = Country(code='COL', name='Colombia',continent=South_America, region='South America', surface_area=1138914.00, indep_year=1810, population=42321000, life_expectancy=70.3, gnp=102896.00, gnp_old=105116.00, local_name='Colombia', government_form='Republic', head_of_state='Andrés Pastrana Arango',capital=None,code2='CO') -COL.save() -COM = Country(code='COM', name='Comoros',continent=Africa, region='Eastern Africa', surface_area=1862.00, indep_year=1975, population=578000, life_expectancy=60.0, gnp=4401.00, gnp_old=4361.00, local_name='Komori/Comores', government_form='Republic', head_of_state='Azali Assoumani',capital=None,code2='KM') -COM.save() -COG = Country(code='COG', name='Congo',continent=Africa, region='Central Africa', surface_area=342000.00, indep_year=1960, population=2943000, life_expectancy=47.4, gnp=2108.00, gnp_old=2287.00, local_name='Congo', government_form='Republic', head_of_state='Denis Sassou-Nguesso',capital=None,code2='CG') -COG.save() -COD = Country(code='COD', name='Congo, The Democratic Republic of the',continent=Africa, region='Central Africa', surface_area=2344858.00, indep_year=1960, population=51654000, life_expectancy=48.8, gnp=6964.00, gnp_old=2474.00, local_name='République Démocratique du Congo', government_form='Republic', head_of_state='Joseph Kabila',capital=None,code2='CD') -COD.save() -CCK = Country(code='CCK', name='Cocos (Keeling) Islands',continent=Oceania, region='Australia and New Zealand', surface_area=14.00, indep_year=None, population=600, life_expectancy=None, gnp=0.00, gnp_old=None, local_name='Cocos (Keeling) Islands', government_form='Territory of Australia', head_of_state='Elisabeth II',capital=None,code2='CC') -CCK.save() -PRK = Country(code='PRK', name='North Korea',continent=Asia, region='Eastern Asia', surface_area=120538.00, indep_year=1948, population=24039000, life_expectancy=70.7, gnp=5332.00, gnp_old=None, local_name='Choson Minjujuui In´min Konghwaguk (Bukhan)', government_form='Socialistic Republic', head_of_state='Kim Jong-il',capital=None,code2='KP') -PRK.save() -KOR = Country(code='KOR', name='South Korea',continent=Asia, region='Eastern Asia', surface_area=99434.00, indep_year=1948, population=46844000, life_expectancy=74.4, gnp=320749.00, gnp_old=442544.00, local_name='Taehan Minguk (Namhan)', government_form='Republic', head_of_state='Kim Dae-jung',capital=None,code2='KR') -KOR.save() -GRC = Country(code='GRC', name='Greece',continent=Europe, region='Southern Europe', surface_area=131626.00, indep_year=1830, population=10545700, life_expectancy=78.4, gnp=120724.00, gnp_old=119946.00, local_name='Elláda', government_form='Republic', head_of_state='Kostis Stefanopoulos',capital=None,code2='GR') -GRC.save() -HRV = Country(code='HRV', name='Croatia',continent=Europe, region='Southern Europe', surface_area=56538.00, indep_year=1991, population=4473000, life_expectancy=73.7, gnp=20208.00, gnp_old=19300.00, local_name='Hrvatska', government_form='Republic', head_of_state='tipe Mesic',capital=None,code2='HR') -HRV.save() -CUB = Country(code='CUB', name='Cuba',continent=North_America, region='Caribbean', surface_area=110861.00, indep_year=1902, population=11201000, life_expectancy=76.2, gnp=17843.00, gnp_old=18862.00, local_name='Cuba', government_form='Socialistic Republic', head_of_state='Fidel Castro Ruz',capital=None,code2='CU') -CUB.save() -KWT = Country(code='KWT', name='Kuwait',continent=Asia, region='Middle East', surface_area=17818.00, indep_year=1961, population=1972000, life_expectancy=76.1, gnp=27037.00, gnp_old=30373.00, local_name='Al-Kuwayt', government_form='Constitutional Monarchy (Emirate)', head_of_state='Jabir al-Ahmad al-Jabir al-Sabah',capital=None,code2='KW') -KWT.save() -CYP = Country(code='CYP', name='Cyprus',continent=Asia, region='Middle East', surface_area=9251.00, indep_year=1960, population=754700, life_expectancy=76.7, gnp=9333.00, gnp_old=8246.00, local_name='Kýpros/Kibris', government_form='Republic', head_of_state='Glafkos Klerides',capital=None,code2='CY') -CYP.save() -LAO = Country(code='LAO', name='Laos',continent=Asia, region='Southeast Asia', surface_area=236800.00, indep_year=1953, population=5433000, life_expectancy=53.1, gnp=1292.00, gnp_old=1746.00, local_name='Lao', government_form='Republic', head_of_state='Khamtay Siphandone',capital=None,code2='LA') -LAO.save() -LVA = Country(code='LVA', name='Latvia',continent=Europe, region='Baltic Countries', surface_area=64589.00, indep_year=1991, population=2424200, life_expectancy=68.4, gnp=6398.00, gnp_old=5639.00, local_name='Latvija', government_form='Republic', head_of_state='Vaira Vike-Freiberga',capital=None,code2='LV') -LVA.save() -LSO = Country(code='LSO', name='Lesotho',continent=Africa, region='Southern Africa', surface_area=30355.00, indep_year=1966, population=2153000, life_expectancy=50.8, gnp=1061.00, gnp_old=1161.00, local_name='Lesotho', government_form='Constitutional Monarchy', head_of_state='Letsie III',capital=None,code2='LS') -LSO.save() -LBN = Country(code='LBN', name='Lebanon',continent=Asia, region='Middle East', surface_area=10400.00, indep_year=1941, population=3282000, life_expectancy=71.3, gnp=17121.00, gnp_old=15129.00, local_name='Lubnan', government_form='Republic', head_of_state='Émile Lahoud',capital=None,code2='LB') -LBN.save() -LBR = Country(code='LBR', name='Liberia',continent=Africa, region='Western Africa', surface_area=111369.00, indep_year=1847, population=3154000, life_expectancy=51.0, gnp=2012.00, gnp_old=None, local_name='Liberia', government_form='Republic', head_of_state='Charles Taylor',capital=None,code2='LR') -LBR.save() -LBY = Country(code='LBY', name='Libyan Arab Jamahiriya',continent=Africa, region='Northern Africa', surface_area=1759540.00, indep_year=1951, population=5605000, life_expectancy=75.5, gnp=44806.00, gnp_old=40562.00, local_name='Libiya', government_form='Socialistic State', head_of_state='Muammar al-Qadhafi',capital=None,code2='LY') -LBY.save() -LIE = Country(code='LIE', name='Liechtenstein',continent=Europe, region='Western Europe', surface_area=160.00, indep_year=1806, population=32300, life_expectancy=78.8, gnp=1119.00, gnp_old=1084.00, local_name='Liechtenstein', government_form='Constitutional Monarchy', head_of_state='Hans-Adam II',capital=None,code2='LI') -LIE.save() -LTU = Country(code='LTU', name='Lithuania',continent=Europe, region='Baltic Countries', surface_area=65301.00, indep_year=1991, population=3698500, life_expectancy=69.1, gnp=10692.00, gnp_old=9585.00, local_name='Lietuva', government_form='Republic', head_of_state='Valdas Adamkus',capital=None,code2='LT') -LTU.save() -LUX = Country(code='LUX', name='Luxembourg',continent=Europe, region='Western Europe', surface_area=2586.00, indep_year=1867, population=435700, life_expectancy=77.1, gnp=16321.00, gnp_old=15519.00, local_name='Luxembourg/Lëtzebuerg', government_form='Constitutional Monarchy', head_of_state='Henri',capital=None,code2='LU') -LUX.save() -ESH = Country(code='ESH', name='Western Sahara',continent=Africa, region='Northern Africa', surface_area=266000.00, indep_year=None, population=293000, life_expectancy=49.8, gnp=60.00, gnp_old=None, local_name='As-Sahrawiya', government_form='Occupied by Marocco', head_of_state='Mohammed Abdel Aziz',capital=None,code2='EH') -ESH.save() -MAC = Country(code='MAC', name='Macao',continent=Asia, region='Eastern Asia', surface_area=18.00, indep_year=None, population=473000, life_expectancy=81.6, gnp=5749.00, gnp_old=5940.00, local_name='Macau/Aomen', government_form='Special Administrative Region of China', head_of_state='Jiang Zemin',capital=None,code2='MO') -MAC.save() -MDG = Country(code='MDG', name='Madagascar',continent=Africa, region='Eastern Africa', surface_area=587041.00, indep_year=1960, population=15942000, life_expectancy=55.0, gnp=3750.00, gnp_old=3545.00, local_name='Madagasikara/Madagascar', government_form='Federal Republic', head_of_state='Didier Ratsiraka',capital=None,code2='MG') -MDG.save() -MKD = Country(code='MKD', name='Macedonia',continent=Europe, region='Southern Europe', surface_area=25713.00, indep_year=1991, population=2024000, life_expectancy=73.8, gnp=1694.00, gnp_old=1915.00, local_name='Makedonija', government_form='Republic', head_of_state='Boris Trajkovski',capital=None,code2='MK') -MKD.save() -MWI = Country(code='MWI', name='Malawi',continent=Africa, region='Eastern Africa', surface_area=118484.00, indep_year=1964, population=10925000, life_expectancy=37.6, gnp=1687.00, gnp_old=2527.00, local_name='Malawi', government_form='Republic', head_of_state='Bakili Muluzi',capital=None,code2='MW') -MWI.save() -MDV = Country(code='MDV', name='Maldives',continent=Asia, region='Southern and Central Asia', surface_area=298.00, indep_year=1965, population=286000, life_expectancy=62.2, gnp=199.00, gnp_old=None, local_name='Dhivehi Raajje/Maldives', government_form='Republic', head_of_state='Maumoon Abdul Gayoom',capital=None,code2='MV') -MDV.save() -MYS = Country(code='MYS', name='Malaysia',continent=Asia, region='Southeast Asia', surface_area=329758.00, indep_year=1957, population=22244000, life_expectancy=70.8, gnp=69213.00, gnp_old=97884.00, local_name='Malaysia', government_form='Constitutional Monarchy, Federation', head_of_state='Salahuddin Abdul Aziz Shah Alhaj',capital=None,code2='MY') -MYS.save() -MLI = Country(code='MLI', name='Mali',continent=Africa, region='Western Africa', surface_area=1240192.00, indep_year=1960, population=11234000, life_expectancy=46.7, gnp=2642.00, gnp_old=2453.00, local_name='Mali', government_form='Republic', head_of_state='Alpha Oumar Konaré',capital=None,code2='ML') -MLI.save() -MLT = Country(code='MLT', name='Malta',continent=Europe, region='Southern Europe', surface_area=316.00, indep_year=1964, population=380200, life_expectancy=77.9, gnp=3512.00, gnp_old=3338.00, local_name='Malta', government_form='Republic', head_of_state='Guido de Marco',capital=None,code2='MT') -MLT.save() -MAR = Country(code='MAR', name='Morocco',continent=Africa, region='Northern Africa', surface_area=446550.00, indep_year=1956, population=28351000, life_expectancy=69.1, gnp=36124.00, gnp_old=33514.00, local_name='Al-Maghrib', government_form='Constitutional Monarchy', head_of_state='Mohammed VI',capital=None,code2='MA') -MAR.save() -MHL = Country(code='MHL', name='Marshall Islands',continent=Oceania, region='Micronesia', surface_area=181.00, indep_year=1990, population=64000, life_expectancy=65.5, gnp=97.00, gnp_old=None, local_name='Marshall Islands/Majol', government_form='Republic', head_of_state='Kessai Note',capital=None,code2='MH') -MHL.save() -MTQ = Country(code='MTQ', name='Martinique',continent=North_America, region='Caribbean', surface_area=1102.00, indep_year=None, population=395000, life_expectancy=78.3, gnp=2731.00, gnp_old=2559.00, local_name='Martinique', government_form='Overseas Department of France', head_of_state='Jacques Chirac',capital=None,code2='MQ') -MTQ.save() -MRT = Country(code='MRT', name='Mauritania',continent=Africa, region='Western Africa', surface_area=1025520.00, indep_year=1960, population=2670000, life_expectancy=50.8, gnp=998.00, gnp_old=1081.00, local_name='Muritaniya/Mauritanie', government_form='Republic', head_of_state='Maaouiya Ould Sid´Ahmad Taya',capital=None,code2='MR') -MRT.save() -MUS = Country(code='MUS', name='Mauritius',continent=Africa, region='Eastern Africa', surface_area=2040.00, indep_year=1968, population=1158000, life_expectancy=71.0, gnp=4251.00, gnp_old=4186.00, local_name='Mauritius', government_form='Republic', head_of_state='Cassam Uteem',capital=None,code2='MU') -MUS.save() -MYT = Country(code='MYT', name='Mayotte',continent=Africa, region='Eastern Africa', surface_area=373.00, indep_year=None, population=149000, life_expectancy=59.5, gnp=0.00, gnp_old=None, local_name='Mayotte', government_form='Territorial Collectivity of France', head_of_state='Jacques Chirac',capital=None,code2='YT') -MYT.save() -MEX = Country(code='MEX', name='Mexico',continent=North_America, region='Central America', surface_area=1958201.00, indep_year=1810, population=98881000, life_expectancy=71.5, gnp=414972.00, gnp_old=401461.00, local_name='México', government_form='Federal Republic', head_of_state='Vicente Fox Quesada',capital=None,code2='MX') -MEX.save() -FSM = Country(code='FSM', name='Micronesia, Federated States of',continent=Oceania, region='Micronesia', surface_area=702.00, indep_year=1990, population=119000, life_expectancy=68.6, gnp=212.00, gnp_old=None, local_name='Micronesia', government_form='Federal Republic', head_of_state='Leo A. Falcam',capital=None,code2='FM') -FSM.save() -MDA = Country(code='MDA', name='Moldova',continent=Europe, region='Eastern Europe', surface_area=33851.00, indep_year=1991, population=4380000, life_expectancy=64.5, gnp=1579.00, gnp_old=1872.00, local_name='Moldova', government_form='Republic', head_of_state='Vladimir Voronin',capital=None,code2='MD') -MDA.save() -MCO = Country(code='MCO', name='Monaco',continent=Europe, region='Western Europe', surface_area=1.50, indep_year=1861, population=34000, life_expectancy=78.8, gnp=776.00, gnp_old=None, local_name='Monaco', government_form='Constitutional Monarchy', head_of_state='Rainier III',capital=None,code2='MC') -MCO.save() -MNG = Country(code='MNG', name='Mongolia',continent=Asia, region='Eastern Asia', surface_area=1566500.00, indep_year=1921, population=2662000, life_expectancy=67.3, gnp=1043.00, gnp_old=933.00, local_name='Mongol Uls', government_form='Republic', head_of_state='Natsagiin Bagabandi',capital=None,code2='MN') -MNG.save() -MSR = Country(code='MSR', name='Montserrat',continent=North_America, region='Caribbean', surface_area=102.00, indep_year=None, population=11000, life_expectancy=78.0, gnp=109.00, gnp_old=None, local_name='Montserrat', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='MS') -MSR.save() -MOZ = Country(code='MOZ', name='Mozambique',continent=Africa, region='Eastern Africa', surface_area=801590.00, indep_year=1975, population=19680000, life_expectancy=37.5, gnp=2891.00, gnp_old=2711.00, local_name='Moçambique', government_form='Republic', head_of_state='Joaquím A. Chissano',capital=None,code2='MZ') -MOZ.save() -MMR = Country(code='MMR', name='Myanmar',continent=Asia, region='Southeast Asia', surface_area=676578.00, indep_year=1948, population=45611000, life_expectancy=54.9, gnp=180375.00, gnp_old=171028.00, local_name='Myanma Pye', government_form='Republic', head_of_state='kenraali Than Shwe',capital=None,code2='MM') -MMR.save() -NAM = Country(code='NAM', name='Namibia',continent=Africa, region='Southern Africa', surface_area=824292.00, indep_year=1990, population=1726000, life_expectancy=42.5, gnp=3101.00, gnp_old=3384.00, local_name='Namibia', government_form='Republic', head_of_state='Sam Nujoma',capital=None,code2='NA') -NAM.save() -NRU = Country(code='NRU', name='Nauru',continent=Oceania, region='Micronesia', surface_area=21.00, indep_year=1968, population=12000, life_expectancy=60.8, gnp=197.00, gnp_old=None, local_name='Naoero/Nauru', government_form='Republic', head_of_state='Bernard Dowiyogo',capital=None,code2='NR') -NRU.save() -NPL = Country(code='NPL', name='Nepal',continent=Asia, region='Southern and Central Asia', surface_area=147181.00, indep_year=1769, population=23930000, life_expectancy=57.8, gnp=4768.00, gnp_old=4837.00, local_name='Nepal', government_form='Constitutional Monarchy', head_of_state='Gyanendra Bir Bikram',capital=None,code2='NP') -NPL.save() -NIC = Country(code='NIC', name='Nicaragua',continent=North_America, region='Central America', surface_area=130000.00, indep_year=1838, population=5074000, life_expectancy=68.7, gnp=1988.00, gnp_old=2023.00, local_name='Nicaragua', government_form='Republic', head_of_state='Arnoldo Alemán Lacayo',capital=None,code2='NI') -NIC.save() -NER = Country(code='NER', name='Niger',continent=Africa, region='Western Africa', surface_area=1267000.00, indep_year=1960, population=10730000, life_expectancy=41.3, gnp=1706.00, gnp_old=1580.00, local_name='Niger', government_form='Republic', head_of_state='Mamadou Tandja',capital=None,code2='NE') -NER.save() -NGA = Country(code='NGA', name='Nigeria',continent=Africa, region='Western Africa', surface_area=923768.00, indep_year=1960, population=111506000, life_expectancy=51.6, gnp=65707.00, gnp_old=58623.00, local_name='Nigeria', government_form='Federal Republic', head_of_state='Olusegun Obasanjo',capital=None,code2='NG') -NGA.save() -NIU = Country(code='NIU', name='Niue',continent=Oceania, region='Polynesia', surface_area=260.00, indep_year=None, population=2000, life_expectancy=None, gnp=0.00, gnp_old=None, local_name='Niue', government_form='Nonmetropolitan Territory of New Zealand', head_of_state='Elisabeth II',capital=None,code2='NU') -NIU.save() -NFK = Country(code='NFK', name='Norfolk Island',continent=Oceania, region='Australia and New Zealand', surface_area=36.00, indep_year=None, population=2000, life_expectancy=None, gnp=0.00, gnp_old=None, local_name='Norfolk Island', government_form='Territory of Australia', head_of_state='Elisabeth II',capital=None,code2='NF') -NFK.save() -NOR = Country(code='NOR', name='Norway',continent=Europe, region='Nordic Countries', surface_area=323877.00, indep_year=1905, population=4478500, life_expectancy=78.7, gnp=145895.00, gnp_old=153370.00, local_name='Norge', government_form='Constitutional Monarchy', head_of_state='Harald V',capital=None,code2='NO') -NOR.save() -CIV = Country(code='CIV', name='Côte dIvoire',continent=Africa, region='Western Africa', surface_area=322463.00, indep_year=1960, population=14786000, life_expectancy=45.2, gnp=11345.00, gnp_old=10285.00, local_name='Côte dIvoire', government_form='Republic', head_of_state='Laurent Gbagbo',capital=None,code2='CI') -CIV.save() -OMN = Country(code='OMN', name='Oman',continent=Asia, region='Middle East', surface_area=309500.00, indep_year=1951, population=2542000, life_expectancy=71.8, gnp=16904.00, gnp_old=16153.00, local_name='´Uman', government_form='Monarchy (Sultanate)', head_of_state='Qabus ibn Sa´id',capital=None,code2='OM') -OMN.save() -PAK = Country(code='PAK', name='Pakistan',continent=Asia, region='Southern and Central Asia', surface_area=796095.00, indep_year=1947, population=156483000, life_expectancy=61.1, gnp=61289.00, gnp_old=58549.00, local_name='Pakistan', government_form='Republic', head_of_state='Mohammad Rafiq Tarar',capital=None,code2='PK') -PAK.save() -PLW = Country(code='PLW', name='Palau',continent=Oceania, region='Micronesia', surface_area=459.00, indep_year=1994, population=19000, life_expectancy=68.6, gnp=105.00, gnp_old=None, local_name='Belau/Palau', government_form='Republic', head_of_state='Kuniwo Nakamura',capital=None,code2='PW') -PLW.save() -PAN = Country(code='PAN', name='Panama',continent=North_America, region='Central America', surface_area=75517.00, indep_year=1903, population=2856000, life_expectancy=75.5, gnp=9131.00, gnp_old=8700.00, local_name='Panamá', government_form='Republic', head_of_state='Mireya Elisa Moscoso Rodríguez',capital=None,code2='PA') -PAN.save() -PNG = Country(code='PNG', name='Papua New Guinea',continent=Oceania, region='Melanesia', surface_area=462840.00, indep_year=1975, population=4807000, life_expectancy=63.1, gnp=4988.00, gnp_old=6328.00, local_name='Papua New Guinea/Papua Niugini', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='PG') -PNG.save() -PRY = Country(code='PRY', name='Paraguay',continent=South_America, region='South America', surface_area=406752.00, indep_year=1811, population=5496000, life_expectancy=73.7, gnp=8444.00, gnp_old=9555.00, local_name='Paraguay', government_form='Republic', head_of_state='Luis Ángel González Macchi',capital=None,code2='PY') -PRY.save() -PER = Country(code='PER', name='Peru',continent=South_America, region='South America', surface_area=1285216.00, indep_year=1821, population=25662000, life_expectancy=70.0, gnp=64140.00, gnp_old=65186.00, local_name='Perú/Piruw', government_form='Republic', head_of_state='Valentin Paniagua Corazao',capital=None,code2='PE') -PER.save() -PCN = Country(code='PCN', name='Pitcairn',continent=Oceania, region='Polynesia', surface_area=49.00, indep_year=None, population=50, life_expectancy=None, gnp=0.00, gnp_old=None, local_name='Pitcairn', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='PN') -PCN.save() -MNP = Country(code='MNP', name='Northern Mariana Islands',continent=Oceania, region='Micronesia', surface_area=464.00, indep_year=None, population=78000, life_expectancy=75.5, gnp=0.00, gnp_old=None, local_name='Northern Mariana Islands', government_form='Commonwealth of the US', head_of_state='George W. Bush',capital=None,code2='MP') -MNP.save() -PRT = Country(code='PRT', name='Portugal',continent=Europe, region='Southern Europe', surface_area=91982.00, indep_year=1143, population=9997600, life_expectancy=75.8, gnp=105954.00, gnp_old=102133.00, local_name='Portugal', government_form='Republic', head_of_state='Jorge Sampãio',capital=None,code2='PT') -PRT.save() -PRI = Country(code='PRI', name='Puerto Rico',continent=North_America, region='Caribbean', surface_area=8875.00, indep_year=None, population=3869000, life_expectancy=75.6, gnp=34100.00, gnp_old=32100.00, local_name='Puerto Rico', government_form='Commonwealth of the US', head_of_state='George W. Bush',capital=None,code2='PR') -PRI.save() -POL = Country(code='POL', name='Poland',continent=Europe, region='Eastern Europe', surface_area=323250.00, indep_year=1918, population=38653600, life_expectancy=73.2, gnp=151697.00, gnp_old=135636.00, local_name='Polska', government_form='Republic', head_of_state='Aleksander Kwasniewski',capital=None,code2='PL') -POL.save() -GNQ = Country(code='GNQ', name='Equatorial Guinea',continent=Africa, region='Central Africa', surface_area=28051.00, indep_year=1968, population=453000, life_expectancy=53.6, gnp=283.00, gnp_old=542.00, local_name='Guinea Ecuatorial', government_form='Republic', head_of_state='Teodoro Obiang Nguema Mbasogo',capital=None,code2='GQ') -GNQ.save() -QAT = Country(code='QAT', name='Qatar',continent=Asia, region='Middle East', surface_area=11000.00, indep_year=1971, population=599000, life_expectancy=72.4, gnp=9472.00, gnp_old=8920.00, local_name='Qatar', government_form='Monarchy', head_of_state='Hamad ibn Khalifa al-Thani',capital=None,code2='QA') -QAT.save() -FRA = Country(code='FRA', name='France',continent=Europe, region='Western Europe', surface_area=551500.00, indep_year=843, population=59225700, life_expectancy=78.8, gnp=1424285.00, gnp_old=1392448.00, local_name='France', government_form='Republic', head_of_state='Jacques Chirac',capital=None,code2='FR') -FRA.save() -GUF = Country(code='GUF', name='French Guiana',continent=South_America, region='South America', surface_area=90000.00, indep_year=None, population=181000, life_expectancy=76.1, gnp=681.00, gnp_old=None, local_name='Guyane française', government_form='Overseas Department of France', head_of_state='Jacques Chirac',capital=None,code2='GF') -GUF.save() -PYF = Country(code='PYF', name='French Polynesia',continent=Oceania, region='Polynesia', surface_area=4000.00, indep_year=None, population=235000, life_expectancy=74.8, gnp=818.00, gnp_old=781.00, local_name='Polynésie française', government_form='Nonmetropolitan Territory of France', head_of_state='Jacques Chirac',capital=None,code2='PF') -PYF.save() -REU = Country(code='REU', name='Réunion',continent=Africa, region='Eastern Africa', surface_area=2510.00, indep_year=None, population=699000, life_expectancy=72.7, gnp=8287.00, gnp_old=7988.00, local_name='Réunion', government_form='Overseas Department of France', head_of_state='Jacques Chirac',capital=None,code2='RE') -REU.save() -ROM = Country(code='ROM', name='Romania',continent=Europe, region='Eastern Europe', surface_area=238391.00, indep_year=1878, population=22455500, life_expectancy=69.9, gnp=38158.00, gnp_old=34843.00, local_name='România', government_form='Republic', head_of_state='Ion Iliescu',capital=None,code2='RO') -ROM.save() -RWA = Country(code='RWA', name='Rwanda',continent=Africa, region='Eastern Africa', surface_area=26338.00, indep_year=1962, population=7733000, life_expectancy=39.3, gnp=2036.00, gnp_old=1863.00, local_name='Rwanda/Urwanda', government_form='Republic', head_of_state='Paul Kagame',capital=None,code2='RW') -RWA.save() -SWE = Country(code='SWE', name='Sweden',continent=Europe, region='Nordic Countries', surface_area=449964.00, indep_year=836, population=8861400, life_expectancy=79.6, gnp=226492.00, gnp_old=227757.00, local_name='Sverige', government_form='Constitutional Monarchy', head_of_state='Carl XVI Gustaf',capital=None,code2='SE') -SWE.save() -SHN = Country(code='SHN', name='Saint Helena',continent=Africa, region='Western Africa', surface_area=314.00, indep_year=None, population=6000, life_expectancy=76.8, gnp=0.00, gnp_old=None, local_name='Saint Helena', government_form='Dependent Territory of the UK', head_of_state='Elisabeth II',capital=None,code2='SH') -SHN.save() -KNA = Country(code='KNA', name='Saint Kitts and Nevis',continent=North_America, region='Caribbean', surface_area=261.00, indep_year=1983, population=38000, life_expectancy=70.7, gnp=299.00, gnp_old=None, local_name='Saint Kitts and Nevis', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='KN') -KNA.save() -LCA = Country(code='LCA', name='Saint Lucia',continent=North_America, region='Caribbean', surface_area=622.00, indep_year=1979, population=154000, life_expectancy=72.3, gnp=571.00, gnp_old=None, local_name='Saint Lucia', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='LC') -LCA.save() -VCT = Country(code='VCT', name='Saint Vincent and the Grenadines',continent=North_America, region='Caribbean', surface_area=388.00, indep_year=1979, population=114000, life_expectancy=72.3, gnp=285.00, gnp_old=None, local_name='Saint Vincent and the Grenadines', government_form='Constitutional Monarchy', head_of_state='Elisabeth II',capital=None,code2='VC') -VCT.save() -SPM = Country(code='SPM', name='Saint Pierre and Miquelon',continent=North_America, region='North America', surface_area=242.00, indep_year=None, population=7000, life_expectancy=77.6, gnp=0.00, gnp_old=None, local_name='Saint-Pierre-et-Miquelon', government_form='Territorial Collectivity of France', head_of_state='Jacques Chirac',capital=None,code2='PM') -SPM.save() -DEU = Country(code='DEU', name='Germany',continent=Europe, region='Western Europe', surface_area=357022.00, indep_year=1955, population=82164700, life_expectancy=77.4, gnp=2133367.00, gnp_old=2102826.00, local_name='Deutschland', government_form='Federal Republic', head_of_state='Johannes Rau',capital=None,code2='DE') -DEU.save() -SLB = Country(code='... [truncated message content] |
From: <fwi...@us...> - 2008-07-08 10:01:20
|
Revision: 4874 http://jython.svn.sourceforge.net/jython/?rev=4874&view=rev Author: fwierzbicki Date: 2008-07-08 03:01:19 -0700 (Tue, 08 Jul 2008) Log Message: ----------- sql for demo. Added Paths: ----------- trunk/sandbox/wierzbicki/javaone2008/world.sql Added: trunk/sandbox/wierzbicki/javaone2008/world.sql =================================================================== --- trunk/sandbox/wierzbicki/javaone2008/world.sql (rev 0) +++ trunk/sandbox/wierzbicki/javaone2008/world.sql 2008-07-08 10:01:19 UTC (rev 4874) @@ -0,0 +1,5391 @@ +-- MySQL dump 10.9 +-- +-- Host: localhost Database: world +-- ------------------------------------------------------ +-- Server version 4.1.13-log + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES latin1 */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `City` +-- + +DROP TABLE IF EXISTS `City`; +CREATE TABLE `City` ( + `ID` int(11) NOT NULL auto_increment, + `Name` char(35) NOT NULL default '', + `CountryCode` char(3) NOT NULL default '', + `District` char(20) NOT NULL default '', + `Population` int(11) NOT NULL default '0', + PRIMARY KEY (`ID`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +-- +-- Dumping data for table `City` +-- + +INSERT INTO `City` VALUES (1,'Kabul','AFG','Kabol',1780000); +INSERT INTO `City` VALUES (2,'Qandahar','AFG','Qandahar',237500); +INSERT INTO `City` VALUES (3,'Herat','AFG','Herat',186800); +INSERT INTO `City` VALUES (4,'Mazar-e-Sharif','AFG','Balkh',127800); +INSERT INTO `City` VALUES (5,'Amsterdam','NLD','Noord-Holland',731200); +INSERT INTO `City` VALUES (6,'Rotterdam','NLD','Zuid-Holland',593321); +INSERT INTO `City` VALUES (7,'Haag','NLD','Zuid-Holland',440900); +INSERT INTO `City` VALUES (8,'Utrecht','NLD','Utrecht',234323); +INSERT INTO `City` VALUES (9,'Eindhoven','NLD','Noord-Brabant',201843); +INSERT INTO `City` VALUES (10,'Tilburg','NLD','Noord-Brabant',193238); +INSERT INTO `City` VALUES (11,'Groningen','NLD','Groningen',172701); +INSERT INTO `City` VALUES (12,'Breda','NLD','Noord-Brabant',160398); +INSERT INTO `City` VALUES (13,'Apeldoorn','NLD','Gelderland',153491); +INSERT INTO `City` VALUES (14,'Nijmegen','NLD','Gelderland',152463); +INSERT INTO `City` VALUES (15,'Enschede','NLD','Overijssel',149544); +INSERT INTO `City` VALUES (16,'Haarlem','NLD','Noord-Holland',148772); +INSERT INTO `City` VALUES (17,'Almere','NLD','Flevoland',142465); +INSERT INTO `City` VALUES (18,'Arnhem','NLD','Gelderland',138020); +INSERT INTO `City` VALUES (19,'Zaanstad','NLD','Noord-Holland',135621); +INSERT INTO `City` VALUES (20,'\xB4s-Hertogenbosch','NLD','Noord-Brabant',129170); +INSERT INTO `City` VALUES (21,'Amersfoort','NLD','Utrecht',126270); +INSERT INTO `City` VALUES (22,'Maastricht','NLD','Limburg',122087); +INSERT INTO `City` VALUES (23,'Dordrecht','NLD','Zuid-Holland',119811); +INSERT INTO `City` VALUES (24,'Leiden','NLD','Zuid-Holland',117196); +INSERT INTO `City` VALUES (25,'Haarlemmermeer','NLD','Noord-Holland',110722); +INSERT INTO `City` VALUES (26,'Zoetermeer','NLD','Zuid-Holland',110214); +INSERT INTO `City` VALUES (27,'Emmen','NLD','Drenthe',105853); +INSERT INTO `City` VALUES (28,'Zwolle','NLD','Overijssel',105819); +INSERT INTO `City` VALUES (29,'Ede','NLD','Gelderland',101574); +INSERT INTO `City` VALUES (30,'Delft','NLD','Zuid-Holland',95268); +INSERT INTO `City` VALUES (31,'Heerlen','NLD','Limburg',95052); +INSERT INTO `City` VALUES (32,'Alkmaar','NLD','Noord-Holland',92713); +INSERT INTO `City` VALUES (33,'Willemstad','ANT','Cura\xE7ao',2345); +INSERT INTO `City` VALUES (34,'Tirana','ALB','Tirana',270000); +INSERT INTO `City` VALUES (35,'Alger','DZA','Alger',2168000); +INSERT INTO `City` VALUES (36,'Oran','DZA','Oran',609823); +INSERT INTO `City` VALUES (37,'Constantine','DZA','Constantine',443727); +INSERT INTO `City` VALUES (38,'Annaba','DZA','Annaba',222518); +INSERT INTO `City` VALUES (39,'Batna','DZA','Batna',183377); +INSERT INTO `City` VALUES (40,'S\xE9tif','DZA','S\xE9tif',179055); +INSERT INTO `City` VALUES (41,'Sidi Bel Abb\xE8s','DZA','Sidi Bel Abb\xE8s',153106); +INSERT INTO `City` VALUES (42,'Skikda','DZA','Skikda',128747); +INSERT INTO `City` VALUES (43,'Biskra','DZA','Biskra',128281); +INSERT INTO `City` VALUES (44,'Blida (el-Boulaida)','DZA','Blida',127284); +INSERT INTO `City` VALUES (45,'B\xE9ja\xEFa','DZA','B\xE9ja\xEFa',117162); +INSERT INTO `City` VALUES (46,'Mostaganem','DZA','Mostaganem',115212); +INSERT INTO `City` VALUES (47,'T\xE9bessa','DZA','T\xE9bessa',112007); +INSERT INTO `City` VALUES (48,'Tlemcen (Tilimsen)','DZA','Tlemcen',110242); +INSERT INTO `City` VALUES (49,'B\xE9char','DZA','B\xE9char',107311); +INSERT INTO `City` VALUES (50,'Tiaret','DZA','Tiaret',100118); +INSERT INTO `City` VALUES (51,'Ech-Chleff (el-Asnam)','DZA','Chlef',96794); +INSERT INTO `City` VALUES (52,'Gharda\xEFa','DZA','Gharda\xEFa',89415); +INSERT INTO `City` VALUES (53,'Tafuna','ASM','Tutuila',5200); +INSERT INTO `City` VALUES (54,'Fagatogo','ASM','Tutuila',2323); +INSERT INTO `City` VALUES (55,'Andorra la Vella','AND','Andorra la Vella',21189); +INSERT INTO `City` VALUES (56,'Luanda','AGO','Luanda',2022000); +INSERT INTO `City` VALUES (57,'Huambo','AGO','Huambo',163100); +INSERT INTO `City` VALUES (58,'Lobito','AGO','Benguela',130000); +INSERT INTO `City` VALUES (59,'Benguela','AGO','Benguela',128300); +INSERT INTO `City` VALUES (60,'Namibe','AGO','Namibe',118200); +INSERT INTO `City` VALUES (61,'South Hill','AIA','\x96',961); +INSERT INTO `City` VALUES (62,'The Valley','AIA','\x96',595); +INSERT INTO `City` VALUES (63,'Saint John\xB4s','ATG','St John',24000); +INSERT INTO `City` VALUES (64,'Dubai','ARE','Dubai',669181); +INSERT INTO `City` VALUES (65,'Abu Dhabi','ARE','Abu Dhabi',398695); +INSERT INTO `City` VALUES (66,'Sharja','ARE','Sharja',320095); +INSERT INTO `City` VALUES (67,'al-Ayn','ARE','Abu Dhabi',225970); +INSERT INTO `City` VALUES (68,'Ajman','ARE','Ajman',114395); +INSERT INTO `City` VALUES (69,'Buenos Aires','ARG','Distrito Federal',2982146); +INSERT INTO `City` VALUES (70,'La Matanza','ARG','Buenos Aires',1266461); +INSERT INTO `City` VALUES (71,'C\xF3rdoba','ARG','C\xF3rdoba',1157507); +INSERT INTO `City` VALUES (72,'Rosario','ARG','Santa F\xE9',907718); +INSERT INTO `City` VALUES (73,'Lomas de Zamora','ARG','Buenos Aires',622013); +INSERT INTO `City` VALUES (74,'Quilmes','ARG','Buenos Aires',559249); +INSERT INTO `City` VALUES (75,'Almirante Brown','ARG','Buenos Aires',538918); +INSERT INTO `City` VALUES (76,'La Plata','ARG','Buenos Aires',521936); +INSERT INTO `City` VALUES (77,'Mar del Plata','ARG','Buenos Aires',512880); +INSERT INTO `City` VALUES (78,'San Miguel de Tucum\xE1n','ARG','Tucum\xE1n',470809); +INSERT INTO `City` VALUES (79,'Lan\xFAs','ARG','Buenos Aires',469735); +INSERT INTO `City` VALUES (80,'Merlo','ARG','Buenos Aires',463846); +INSERT INTO `City` VALUES (81,'General San Mart\xEDn','ARG','Buenos Aires',422542); +INSERT INTO `City` VALUES (82,'Salta','ARG','Salta',367550); +INSERT INTO `City` VALUES (83,'Moreno','ARG','Buenos Aires',356993); +INSERT INTO `City` VALUES (84,'Santa F\xE9','ARG','Santa F\xE9',353063); +INSERT INTO `City` VALUES (85,'Avellaneda','ARG','Buenos Aires',353046); +INSERT INTO `City` VALUES (86,'Tres de Febrero','ARG','Buenos Aires',352311); +INSERT INTO `City` VALUES (87,'Mor\xF3n','ARG','Buenos Aires',349246); +INSERT INTO `City` VALUES (88,'Florencio Varela','ARG','Buenos Aires',315432); +INSERT INTO `City` VALUES (89,'San Isidro','ARG','Buenos Aires',306341); +INSERT INTO `City` VALUES (90,'Tigre','ARG','Buenos Aires',296226); +INSERT INTO `City` VALUES (91,'Malvinas Argentinas','ARG','Buenos Aires',290335); +INSERT INTO `City` VALUES (92,'Vicente L\xF3pez','ARG','Buenos Aires',288341); +INSERT INTO `City` VALUES (93,'Berazategui','ARG','Buenos Aires',276916); +INSERT INTO `City` VALUES (94,'Corrientes','ARG','Corrientes',258103); +INSERT INTO `City` VALUES (95,'San Miguel','ARG','Buenos Aires',248700); +INSERT INTO `City` VALUES (96,'Bah\xEDa Blanca','ARG','Buenos Aires',239810); +INSERT INTO `City` VALUES (97,'Esteban Echeverr\xEDa','ARG','Buenos Aires',235760); +INSERT INTO `City` VALUES (98,'Resistencia','ARG','Chaco',229212); +INSERT INTO `City` VALUES (99,'Jos\xE9 C. Paz','ARG','Buenos Aires',221754); +INSERT INTO `City` VALUES (100,'Paran\xE1','ARG','Entre Rios',207041); +INSERT INTO `City` VALUES (101,'Godoy Cruz','ARG','Mendoza',206998); +INSERT INTO `City` VALUES (102,'Posadas','ARG','Misiones',201273); +INSERT INTO `City` VALUES (103,'Guaymall\xE9n','ARG','Mendoza',200595); +INSERT INTO `City` VALUES (104,'Santiago del Estero','ARG','Santiago del Estero',189947); +INSERT INTO `City` VALUES (105,'San Salvador de Jujuy','ARG','Jujuy',178748); +INSERT INTO `City` VALUES (106,'Hurlingham','ARG','Buenos Aires',170028); +INSERT INTO `City` VALUES (107,'Neuqu\xE9n','ARG','Neuqu\xE9n',167296); +INSERT INTO `City` VALUES (108,'Ituzaing\xF3','ARG','Buenos Aires',158197); +INSERT INTO `City` VALUES (109,'San Fernando','ARG','Buenos Aires',153036); +INSERT INTO `City` VALUES (110,'Formosa','ARG','Formosa',147636); +INSERT INTO `City` VALUES (111,'Las Heras','ARG','Mendoza',145823); +INSERT INTO `City` VALUES (112,'La Rioja','ARG','La Rioja',138117); +INSERT INTO `City` VALUES (113,'San Fernando del Valle de Cata','ARG','Catamarca',134935); +INSERT INTO `City` VALUES (114,'R\xEDo Cuarto','ARG','C\xF3rdoba',134355); +INSERT INTO `City` VALUES (115,'Comodoro Rivadavia','ARG','Chubut',124104); +INSERT INTO `City` VALUES (116,'Mendoza','ARG','Mendoza',123027); +INSERT INTO `City` VALUES (117,'San Nicol\xE1s de los Arroyos','ARG','Buenos Aires',119302); +INSERT INTO `City` VALUES (118,'San Juan','ARG','San Juan',119152); +INSERT INTO `City` VALUES (119,'Escobar','ARG','Buenos Aires',116675); +INSERT INTO `City` VALUES (120,'Concordia','ARG','Entre Rios',116485); +INSERT INTO `City` VALUES (121,'Pilar','ARG','Buenos Aires',113428); +INSERT INTO `City` VALUES (122,'San Luis','ARG','San Luis',110136); +INSERT INTO `City` VALUES (123,'Ezeiza','ARG','Buenos Aires',99578); +INSERT INTO `City` VALUES (124,'San Rafael','ARG','Mendoza',94651); +INSERT INTO `City` VALUES (125,'Tandil','ARG','Buenos Aires',91101); +INSERT INTO `City` VALUES (126,'Yerevan','ARM','Yerevan',1248700); +INSERT INTO `City` VALUES (127,'Gjumri','ARM','\x8Airak',211700); +INSERT INTO `City` VALUES (128,'Vanadzor','ARM','Lori',172700); +INSERT INTO `City` VALUES (129,'Oranjestad','ABW','\x96',29034); +INSERT INTO `City` VALUES (130,'Sydney','AUS','New South Wales',3276207); +INSERT INTO `City` VALUES (131,'Melbourne','AUS','Victoria',2865329); +INSERT INTO `City` VALUES (132,'Brisbane','AUS','Queensland',1291117); +INSERT INTO `City` VALUES (133,'Perth','AUS','West Australia',1096829); +INSERT INTO `City` VALUES (134,'Adelaide','AUS','South Australia',978100); +INSERT INTO `City` VALUES (135,'Canberra','AUS','Capital Region',322723); +INSERT INTO `City` VALUES (136,'Gold Coast','AUS','Queensland',311932); +INSERT INTO `City` VALUES (137,'Newcastle','AUS','New South Wales',270324); +INSERT INTO `City` VALUES (138,'Central Coast','AUS','New South Wales',227657); +INSERT INTO `City` VALUES (139,'Wollongong','AUS','New South Wales',219761); +INSERT INTO `City` VALUES (140,'Hobart','AUS','Tasmania',126118); +INSERT INTO `City` VALUES (141,'Geelong','AUS','Victoria',125382); +INSERT INTO `City` VALUES (142,'Townsville','AUS','Queensland',109914); +INSERT INTO `City` VALUES (143,'Cairns','AUS','Queensland',92273); +INSERT INTO `City` VALUES (144,'Baku','AZE','Baki',1787800); +INSERT INTO `City` VALUES (145,'G\xE4nc\xE4','AZE','G\xE4nc\xE4',299300); +INSERT INTO `City` VALUES (146,'Sumqayit','AZE','Sumqayit',283000); +INSERT INTO `City` VALUES (147,'Ming\xE4\xE7evir','AZE','Ming\xE4\xE7evir',93900); +INSERT INTO `City` VALUES (148,'Nassau','BHS','New Providence',172000); +INSERT INTO `City` VALUES (149,'al-Manama','BHR','al-Manama',148000); +INSERT INTO `City` VALUES (150,'Dhaka','BGD','Dhaka',3612850); +INSERT INTO `City` VALUES (151,'Chittagong','BGD','Chittagong',1392860); +INSERT INTO `City` VALUES (152,'Khulna','BGD','Khulna',663340); +INSERT INTO `City` VALUES (153,'Rajshahi','BGD','Rajshahi',294056); +INSERT INTO `City` VALUES (154,'Narayanganj','BGD','Dhaka',202134); +INSERT INTO `City` VALUES (155,'Rangpur','BGD','Rajshahi',191398); +INSERT INTO `City` VALUES (156,'Mymensingh','BGD','Dhaka',188713); +INSERT INTO `City` VALUES (157,'Barisal','BGD','Barisal',170232); +INSERT INTO `City` VALUES (158,'Tungi','BGD','Dhaka',168702); +INSERT INTO `City` VALUES (159,'Jessore','BGD','Khulna',139710); +INSERT INTO `City` VALUES (160,'Comilla','BGD','Chittagong',135313); +INSERT INTO `City` VALUES (161,'Nawabganj','BGD','Rajshahi',130577); +INSERT INTO `City` VALUES (162,'Dinajpur','BGD','Rajshahi',127815); +INSERT INTO `City` VALUES (163,'Bogra','BGD','Rajshahi',120170); +INSERT INTO `City` VALUES (164,'Sylhet','BGD','Sylhet',117396); +INSERT INTO `City` VALUES (165,'Brahmanbaria','BGD','Chittagong',109032); +INSERT INTO `City` VALUES (166,'Tangail','BGD','Dhaka',106004); +INSERT INTO `City` VALUES (167,'Jamalpur','BGD','Dhaka',103556); +INSERT INTO `City` VALUES (168,'Pabna','BGD','Rajshahi',103277); +INSERT INTO `City` VALUES (169,'Naogaon','BGD','Rajshahi',101266); +INSERT INTO `City` VALUES (170,'Sirajganj','BGD','Rajshahi',99669); +INSERT INTO `City` VALUES (171,'Narsinghdi','BGD','Dhaka',98342); +INSERT INTO `City` VALUES (172,'Saidpur','BGD','Rajshahi',96777); +INSERT INTO `City` VALUES (173,'Gazipur','BGD','Dhaka',96717); +INSERT INTO `City` VALUES (174,'Bridgetown','BRB','St Michael',6070); +INSERT INTO `City` VALUES (175,'Antwerpen','BEL','Antwerpen',446525); +INSERT INTO `City` VALUES (176,'Gent','BEL','East Flanderi',224180); +INSERT INTO `City` VALUES (177,'Charleroi','BEL','Hainaut',200827); +INSERT INTO `City` VALUES (178,'Li\xE8ge','BEL','Li\xE8ge',185639); +INSERT INTO `City` VALUES (179,'Bruxelles [Brussel]','BEL','Bryssel',133859); +INSERT INTO `City` VALUES (180,'Brugge','BEL','West Flanderi',116246); +INSERT INTO `City` VALUES (181,'Schaerbeek','BEL','Bryssel',105692); +INSERT INTO `City` VALUES (182,'Namur','BEL','Namur',105419); +INSERT INTO `City` VALUES (183,'Mons','BEL','Hainaut',90935); +INSERT INTO `City` VALUES (184,'Belize City','BLZ','Belize City',55810); +INSERT INTO `City` VALUES (185,'Belmopan','BLZ','Cayo',7105); +INSERT INTO `City` VALUES (186,'Cotonou','BEN','Atlantique',536827); +INSERT INTO `City` VALUES (187,'Porto-Novo','BEN','Ou\xE9m\xE9',194000); +INSERT INTO `City` VALUES (188,'Djougou','BEN','Atacora',134099); +INSERT INTO `City` VALUES (189,'Parakou','BEN','Borgou',103577); +INSERT INTO `City` VALUES (190,'Saint George','BMU','Saint George\xB4s',1800); +INSERT INTO `City` VALUES (191,'Hamilton','BMU','Hamilton',1200); +INSERT INTO `City` VALUES (192,'Thimphu','BTN','Thimphu',22000); +INSERT INTO `City` VALUES (193,'Santa Cruz de la Sierra','BOL','Santa Cruz',935361); +INSERT INTO `City` VALUES (194,'La Paz','BOL','La Paz',758141); +INSERT INTO `City` VALUES (195,'El Alto','BOL','La Paz',534466); +INSERT INTO `City` VALUES (196,'Cochabamba','BOL','Cochabamba',482800); +INSERT INTO `City` VALUES (197,'Oruro','BOL','Oruro',223553); +INSERT INTO `City` VALUES (198,'Sucre','BOL','Chuquisaca',178426); +INSERT INTO `City` VALUES (199,'Potos\xED','BOL','Potos\xED',140642); +INSERT INTO `City` VALUES (200,'Tarija','BOL','Tarija',125255); +INSERT INTO `City` VALUES (201,'Sarajevo','BIH','Federaatio',360000); +INSERT INTO `City` VALUES (202,'Banja Luka','BIH','Republika Srpska',143079); +INSERT INTO `City` VALUES (203,'Zenica','BIH','Federaatio',96027); +INSERT INTO `City` VALUES (204,'Gaborone','BWA','Gaborone',213017); +INSERT INTO `City` VALUES (205,'Francistown','BWA','Francistown',101805); +INSERT INTO `City` VALUES (206,'S\xE3o Paulo','BRA','S\xE3o Paulo',9968485); +INSERT INTO `City` VALUES (207,'Rio de Janeiro','BRA','Rio de Janeiro',5598953); +INSERT INTO `City` VALUES (208,'Salvador','BRA','Bahia',2302832); +INSERT INTO `City` VALUES (209,'Belo Horizonte','BRA','Minas Gerais',2139125); +INSERT INTO `City` VALUES (210,'Fortaleza','BRA','Cear\xE1',2097757); +INSERT INTO `City` VALUES (211,'Bras\xEDlia','BRA','Distrito Federal',1969868); +INSERT INTO `City` VALUES (212,'Curitiba','BRA','Paran\xE1',1584232); +INSERT INTO `City` VALUES (213,'Recife','BRA','Pernambuco',1378087); +INSERT INTO `City` VALUES (214,'Porto Alegre','BRA','Rio Grande do Sul',1314032); +INSERT INTO `City` VALUES (215,'Manaus','BRA','Amazonas',1255049); +INSERT INTO `City` VALUES (216,'Bel\xE9m','BRA','Par\xE1',1186926); +INSERT INTO `City` VALUES (217,'Guarulhos','BRA','S\xE3o Paulo',1095874); +INSERT INTO `City` VALUES (218,'Goi\xE2nia','BRA','Goi\xE1s',1056330); +INSERT INTO `City` VALUES (219,'Campinas','BRA','S\xE3o Paulo',950043); +INSERT INTO `City` VALUES (220,'S\xE3o Gon\xE7alo','BRA','Rio de Janeiro',869254); +INSERT INTO `City` VALUES (221,'Nova Igua\xE7u','BRA','Rio de Janeiro',862225); +INSERT INTO `City` VALUES (222,'S\xE3o Lu\xEDs','BRA','Maranh\xE3o',837588); +INSERT INTO `City` VALUES (223,'Macei\xF3','BRA','Alagoas',786288); +INSERT INTO `City` VALUES (224,'Duque de Caxias','BRA','Rio de Janeiro',746758); +INSERT INTO `City` VALUES (225,'S\xE3o Bernardo do Campo','BRA','S\xE3o Paulo',723132); +INSERT INTO `City` VALUES (226,'Teresina','BRA','Piau\xED',691942); +INSERT INTO `City` VALUES (227,'Natal','BRA','Rio Grande do Norte',688955); +INSERT INTO `City` VALUES (228,'Osasco','BRA','S\xE3o Paulo',659604); +INSERT INTO `City` VALUES (229,'Campo Grande','BRA','Mato Grosso do Sul',649593); +INSERT INTO `City` VALUES (230,'Santo Andr\xE9','BRA','S\xE3o Paulo',630073); +INSERT INTO `City` VALUES (231,'Jo\xE3o Pessoa','BRA','Para\xEDba',584029); +INSERT INTO `City` VALUES (232,'Jaboat\xE3o dos Guararapes','BRA','Pernambuco',558680); +INSERT INTO `City` VALUES (233,'Contagem','BRA','Minas Gerais',520801); +INSERT INTO `City` VALUES (234,'S\xE3o Jos\xE9 dos Campos','BRA','S\xE3o Paulo',515553); +INSERT INTO `City` VALUES (235,'Uberl\xE2ndia','BRA','Minas Gerais',487222); +INSERT INTO `City` VALUES (236,'Feira de Santana','BRA','Bahia',479992); +INSERT INTO `City` VALUES (237,'Ribeir\xE3o Preto','BRA','S\xE3o Paulo',473276); +INSERT INTO `City` VALUES (238,'Sorocaba','BRA','S\xE3o Paulo',466823); +INSERT INTO `City` VALUES (239,'Niter\xF3i','BRA','Rio de Janeiro',459884); +INSERT INTO `City` VALUES (240,'Cuiab\xE1','BRA','Mato Grosso',453813); +INSERT INTO `City` VALUES (241,'Juiz de Fora','BRA','Minas Gerais',450288); +INSERT INTO `City` VALUES (242,'Aracaju','BRA','Sergipe',445555); +INSERT INTO `City` VALUES (243,'S\xE3o Jo\xE3o de Meriti','BRA','Rio de Janeiro',440052); +INSERT INTO `City` VALUES (244,'Londrina','BRA','Paran\xE1',432257); +INSERT INTO `City` VALUES (245,'Joinville','BRA','Santa Catarina',428011); +INSERT INTO `City` VALUES (246,'Belford Roxo','BRA','Rio de Janeiro',425194); +INSERT INTO `City` VALUES (247,'Santos','BRA','S\xE3o Paulo',408748); +INSERT INTO `City` VALUES (248,'Ananindeua','BRA','Par\xE1',400940); +INSERT INTO `City` VALUES (249,'Campos dos Goytacazes','BRA','Rio de Janeiro',398418); +INSERT INTO `City` VALUES (250,'Mau\xE1','BRA','S\xE3o Paulo',375055); +INSERT INTO `City` VALUES (251,'Carapicu\xEDba','BRA','S\xE3o Paulo',357552); +INSERT INTO `City` VALUES (252,'Olinda','BRA','Pernambuco',354732); +INSERT INTO `City` VALUES (253,'Campina Grande','BRA','Para\xEDba',352497); +INSERT INTO `City` VALUES (254,'S\xE3o Jos\xE9 do Rio Preto','BRA','S\xE3o Paulo',351944); +INSERT INTO `City` VALUES (255,'Caxias do Sul','BRA','Rio Grande do Sul',349581); +INSERT INTO `City` VALUES (256,'Moji das Cruzes','BRA','S\xE3o Paulo',339194); +INSERT INTO `City` VALUES (257,'Diadema','BRA','S\xE3o Paulo',335078); +INSERT INTO `City` VALUES (258,'Aparecida de Goi\xE2nia','BRA','Goi\xE1s',324662); +INSERT INTO `City` VALUES (259,'Piracicaba','BRA','S\xE3o Paulo',319104); +INSERT INTO `City` VALUES (260,'Cariacica','BRA','Esp\xEDrito Santo',319033); +INSERT INTO `City` VALUES (261,'Vila Velha','BRA','Esp\xEDrito Santo',318758); +INSERT INTO `City` VALUES (262,'Pelotas','BRA','Rio Grande do Sul',315415); +INSERT INTO `City` VALUES (263,'Bauru','BRA','S\xE3o Paulo',313670); +INSERT INTO `City` VALUES (264,'Porto Velho','BRA','Rond\xF4nia',309750); +INSERT INTO `City` VALUES (265,'Serra','BRA','Esp\xEDrito Santo',302666); +INSERT INTO `City` VALUES (266,'Betim','BRA','Minas Gerais',302108); +INSERT INTO `City` VALUES (267,'Jund\xEDa\xED','BRA','S\xE3o Paulo',296127); +INSERT INTO `City` VALUES (268,'Canoas','BRA','Rio Grande do Sul',294125); +INSERT INTO `City` VALUES (269,'Franca','BRA','S\xE3o Paulo',290139); +INSERT INTO `City` VALUES (270,'S\xE3o Vicente','BRA','S\xE3o Paulo',286848); +INSERT INTO `City` VALUES (271,'Maring\xE1','BRA','Paran\xE1',286461); +INSERT INTO `City` VALUES (272,'Montes Claros','BRA','Minas Gerais',286058); +INSERT INTO `City` VALUES (273,'An\xE1polis','BRA','Goi\xE1s',282197); +INSERT INTO `City` VALUES (274,'Florian\xF3polis','BRA','Santa Catarina',281928); +INSERT INTO `City` VALUES (275,'Petr\xF3polis','BRA','Rio de Janeiro',279183); +INSERT INTO `City` VALUES (276,'Itaquaquecetuba','BRA','S\xE3o Paulo',270874); +INSERT INTO `City` VALUES (277,'Vit\xF3ria','BRA','Esp\xEDrito Santo',270626); +INSERT INTO `City` VALUES (278,'Ponta Grossa','BRA','Paran\xE1',268013); +INSERT INTO `City` VALUES (279,'Rio Branco','BRA','Acre',259537); +INSERT INTO `City` VALUES (280,'Foz do Igua\xE7u','BRA','Paran\xE1',259425); +INSERT INTO `City` VALUES (281,'Macap\xE1','BRA','Amap\xE1',256033); +INSERT INTO `City` VALUES (282,'Ilh\xE9us','BRA','Bahia',254970); +INSERT INTO `City` VALUES (283,'Vit\xF3ria da Conquista','BRA','Bahia',253587); +INSERT INTO `City` VALUES (284,'Uberaba','BRA','Minas Gerais',249225); +INSERT INTO `City` VALUES (285,'Paulista','BRA','Pernambuco',248473); +INSERT INTO `City` VALUES (286,'Limeira','BRA','S\xE3o Paulo',245497); +INSERT INTO `City` VALUES (287,'Blumenau','BRA','Santa Catarina',244379); +INSERT INTO `City` VALUES (288,'Caruaru','BRA','Pernambuco',244247); +INSERT INTO `City` VALUES (289,'Santar\xE9m','BRA','Par\xE1',241771); +INSERT INTO `City` VALUES (290,'Volta Redonda','BRA','Rio de Janeiro',240315); +INSERT INTO `City` VALUES (291,'Novo Hamburgo','BRA','Rio Grande do Sul',239940); +INSERT INTO `City` VALUES (292,'Caucaia','BRA','Cear\xE1',238738); +INSERT INTO `City` VALUES (293,'Santa Maria','BRA','Rio Grande do Sul',238473); +INSERT INTO `City` VALUES (294,'Cascavel','BRA','Paran\xE1',237510); +INSERT INTO `City` VALUES (295,'Guaruj\xE1','BRA','S\xE3o Paulo',237206); +INSERT INTO `City` VALUES (296,'Ribeir\xE3o das Neves','BRA','Minas Gerais',232685); +INSERT INTO `City` VALUES (297,'Governador Valadares','BRA','Minas Gerais',231724); +INSERT INTO `City` VALUES (298,'Taubat\xE9','BRA','S\xE3o Paulo',229130); +INSERT INTO `City` VALUES (299,'Imperatriz','BRA','Maranh\xE3o',224564); +INSERT INTO `City` VALUES (300,'Gravata\xED','BRA','Rio Grande do Sul',223011); +INSERT INTO `City` VALUES (301,'Embu','BRA','S\xE3o Paulo',222223); +INSERT INTO `City` VALUES (302,'Mossor\xF3','BRA','Rio Grande do Norte',214901); +INSERT INTO `City` VALUES (303,'V\xE1rzea Grande','BRA','Mato Grosso',214435); +INSERT INTO `City` VALUES (304,'Petrolina','BRA','Pernambuco',210540); +INSERT INTO `City` VALUES (305,'Barueri','BRA','S\xE3o Paulo',208426); +INSERT INTO `City` VALUES (306,'Viam\xE3o','BRA','Rio Grande do Sul',207557); +INSERT INTO `City` VALUES (307,'Ipatinga','BRA','Minas Gerais',206338); +INSERT INTO `City` VALUES (308,'Juazeiro','BRA','Bahia',201073); +INSERT INTO `City` VALUES (309,'Juazeiro do Norte','BRA','Cear\xE1',199636); +INSERT INTO `City` VALUES (310,'Tabo\xE3o da Serra','BRA','S\xE3o Paulo',197550); +INSERT INTO `City` VALUES (311,'S\xE3o Jos\xE9 dos Pinhais','BRA','Paran\xE1',196884); +INSERT INTO `City` VALUES (312,'Mag\xE9','BRA','Rio de Janeiro',196147); +INSERT INTO `City` VALUES (313,'Suzano','BRA','S\xE3o Paulo',195434); +INSERT INTO `City` VALUES (314,'S\xE3o Leopoldo','BRA','Rio Grande do Sul',189258); +INSERT INTO `City` VALUES (315,'Mar\xEDlia','BRA','S\xE3o Paulo',188691); +INSERT INTO `City` VALUES (316,'S\xE3o Carlos','BRA','S\xE3o Paulo',187122); +INSERT INTO `City` VALUES (317,'Sumar\xE9','BRA','S\xE3o Paulo',186205); +INSERT INTO `City` VALUES (318,'Presidente Prudente','BRA','S\xE3o Paulo',185340); +INSERT INTO `City` VALUES (319,'Divin\xF3polis','BRA','Minas Gerais',185047); +INSERT INTO `City` VALUES (320,'Sete Lagoas','BRA','Minas Gerais',182984); +INSERT INTO `City` VALUES (321,'Rio Grande','BRA','Rio Grande do Sul',182222); +INSERT INTO `City` VALUES (322,'Itabuna','BRA','Bahia',182148); +INSERT INTO `City` VALUES (323,'Jequi\xE9','BRA','Bahia',179128); +INSERT INTO `City` VALUES (324,'Arapiraca','BRA','Alagoas',178988); +INSERT INTO `City` VALUES (325,'Colombo','BRA','Paran\xE1',177764); +INSERT INTO `City` VALUES (326,'Americana','BRA','S\xE3o Paulo',177409); +INSERT INTO `City` VALUES (327,'Alvorada','BRA','Rio Grande do Sul',175574); +INSERT INTO `City` VALUES (328,'Araraquara','BRA','S\xE3o Paulo',174381); +INSERT INTO `City` VALUES (329,'Itabora\xED','BRA','Rio de Janeiro',173977); +INSERT INTO `City` VALUES (330,'Santa B\xE1rbara d\xB4Oeste','BRA','S\xE3o Paulo',171657); +INSERT INTO `City` VALUES (331,'Nova Friburgo','BRA','Rio de Janeiro',170697); +INSERT INTO `City` VALUES (332,'Jacare\xED','BRA','S\xE3o Paulo',170356); +INSERT INTO `City` VALUES (333,'Ara\xE7atuba','BRA','S\xE3o Paulo',169303); +INSERT INTO `City` VALUES (334,'Barra Mansa','BRA','Rio de Janeiro',168953); +INSERT INTO `City` VALUES (335,'Praia Grande','BRA','S\xE3o Paulo',168434); +INSERT INTO `City` VALUES (336,'Marab\xE1','BRA','Par\xE1',167795); +INSERT INTO `City` VALUES (337,'Crici\xFAma','BRA','Santa Catarina',167661); +INSERT INTO `City` VALUES (338,'Boa Vista','BRA','Roraima',167185); +INSERT INTO `City` VALUES (339,'Passo Fundo','BRA','Rio Grande do Sul',166343); +INSERT INTO `City` VALUES (340,'Dourados','BRA','Mato Grosso do Sul',164716); +INSERT INTO `City` VALUES (341,'Santa Luzia','BRA','Minas Gerais',164704); +INSERT INTO `City` VALUES (342,'Rio Claro','BRA','S\xE3o Paulo',163551); +INSERT INTO `City` VALUES (343,'Maracana\xFA','BRA','Cear\xE1',162022); +INSERT INTO `City` VALUES (344,'Guarapuava','BRA','Paran\xE1',160510); +INSERT INTO `City` VALUES (345,'Rondon\xF3polis','BRA','Mato Grosso',155115); +INSERT INTO `City` VALUES (346,'S\xE3o Jos\xE9','BRA','Santa Catarina',155105); +INSERT INTO `City` VALUES (347,'Cachoeiro de Itapemirim','BRA','Esp\xEDrito Santo',155024); +INSERT INTO `City` VALUES (348,'Nil\xF3polis','BRA','Rio de Janeiro',153383); +INSERT INTO `City` VALUES (349,'Itapevi','BRA','S\xE3o Paulo',150664); +INSERT INTO `City` VALUES (350,'Cabo de Santo Agostinho','BRA','Pernambuco',149964); +INSERT INTO `City` VALUES (351,'Cama\xE7ari','BRA','Bahia',149146); +INSERT INTO `City` VALUES (352,'Sobral','BRA','Cear\xE1',146005); +INSERT INTO `City` VALUES (353,'Itaja\xED','BRA','Santa Catarina',145197); +INSERT INTO `City` VALUES (354,'Chapec\xF3','BRA','Santa Catarina',144158); +INSERT INTO `City` VALUES (355,'Cotia','BRA','S\xE3o Paulo',140042); +INSERT INTO `City` VALUES (356,'Lages','BRA','Santa Catarina',139570); +INSERT INTO `City` VALUES (357,'Ferraz de Vasconcelos','BRA','S\xE3o Paulo',139283); +INSERT INTO `City` VALUES (358,'Indaiatuba','BRA','S\xE3o Paulo',135968); +INSERT INTO `City` VALUES (359,'Hortol\xE2ndia','BRA','S\xE3o Paulo',135755); +INSERT INTO `City` VALUES (360,'Caxias','BRA','Maranh\xE3o',133980); +INSERT INTO `City` VALUES (361,'S\xE3o Caetano do Sul','BRA','S\xE3o Paulo',133321); +INSERT INTO `City` VALUES (362,'Itu','BRA','S\xE3o Paulo',132736); +INSERT INTO `City` VALUES (363,'Nossa Senhora do Socorro','BRA','Sergipe',131351); +INSERT INTO `City` VALUES (364,'Parna\xEDba','BRA','Piau\xED',129756); +INSERT INTO `City` VALUES (365,'Po\xE7os de Caldas','BRA','Minas Gerais',129683); +INSERT INTO `City` VALUES (366,'Teres\xF3polis','BRA','Rio de Janeiro',128079); +INSERT INTO `City` VALUES (367,'Barreiras','BRA','Bahia',127801); +INSERT INTO `City` VALUES (368,'Castanhal','BRA','Par\xE1',127634); +INSERT INTO `City` VALUES (369,'Alagoinhas','BRA','Bahia',126820); +INSERT INTO `City` VALUES (370,'Itapecerica da Serra','BRA','S\xE3o Paulo',126672); +INSERT INTO `City` VALUES (371,'Uruguaiana','BRA','Rio Grande do Sul',126305); +INSERT INTO `City` VALUES (372,'Paranagu\xE1','BRA','Paran\xE1',126076); +INSERT INTO `City` VALUES (373,'Ibirit\xE9','BRA','Minas Gerais',125982); +INSERT INTO `City` VALUES (374,'Timon','BRA','Maranh\xE3o',125812); +INSERT INTO `City` VALUES (375,'Luzi\xE2nia','BRA','Goi\xE1s',125597); +INSERT INTO `City` VALUES (376,'Maca\xE9','BRA','Rio de Janeiro',125597); +INSERT INTO `City` VALUES (377,'Te\xF3filo Otoni','BRA','Minas Gerais',124489); +INSERT INTO `City` VALUES (378,'Moji-Gua\xE7u','BRA','S\xE3o Paulo',123782); +INSERT INTO `City` VALUES (379,'Palmas','BRA','Tocantins',121919); +INSERT INTO `City` VALUES (380,'Pindamonhangaba','BRA','S\xE3o Paulo',121904); +INSERT INTO `City` VALUES (381,'Francisco Morato','BRA','S\xE3o Paulo',121197); +INSERT INTO `City` VALUES (382,'Bag\xE9','BRA','Rio Grande do Sul',120793); +INSERT INTO `City` VALUES (383,'Sapucaia do Sul','BRA','Rio Grande do Sul',120217); +INSERT INTO `City` VALUES (384,'Cabo Frio','BRA','Rio de Janeiro',119503); +INSERT INTO `City` VALUES (385,'Itapetininga','BRA','S\xE3o Paulo',119391); +INSERT INTO `City` VALUES (386,'Patos de Minas','BRA','Minas Gerais',119262); +INSERT INTO `City` VALUES (387,'Camaragibe','BRA','Pernambuco',118968); +INSERT INTO `City` VALUES (388,'Bragan\xE7a Paulista','BRA','S\xE3o Paulo',116929); +INSERT INTO `City` VALUES (389,'Queimados','BRA','Rio de Janeiro',115020); +INSERT INTO `City` VALUES (390,'Aragua\xEDna','BRA','Tocantins',114948); +INSERT INTO `City` VALUES (391,'Garanhuns','BRA','Pernambuco',114603); +INSERT INTO `City` VALUES (392,'Vit\xF3ria de Santo Ant\xE3o','BRA','Pernambuco',113595); +INSERT INTO `City` VALUES (393,'Santa Rita','BRA','Para\xEDba',113135); +INSERT INTO `City` VALUES (394,'Barbacena','BRA','Minas Gerais',113079); +INSERT INTO `City` VALUES (395,'Abaetetuba','BRA','Par\xE1',111258); +INSERT INTO `City` VALUES (396,'Ja\xFA','BRA','S\xE3o Paulo',109965); +INSERT INTO `City` VALUES (397,'Lauro de Freitas','BRA','Bahia',109236); +INSERT INTO `City` VALUES (398,'Franco da Rocha','BRA','S\xE3o Paulo',108964); +INSERT INTO `City` VALUES (399,'Teixeira de Freitas','BRA','Bahia',108441); +INSERT INTO `City` VALUES (400,'Varginha','BRA','Minas Gerais',108314); +INSERT INTO `City` VALUES (401,'Ribeir\xE3o Pires','BRA','S\xE3o Paulo',108121); +INSERT INTO `City` VALUES (402,'Sabar\xE1','BRA','Minas Gerais',107781); +INSERT INTO `City` VALUES (403,'Catanduva','BRA','S\xE3o Paulo',107761); +INSERT INTO `City` VALUES (404,'Rio Verde','BRA','Goi\xE1s',107755); +INSERT INTO `City` VALUES (405,'Botucatu','BRA','S\xE3o Paulo',107663); +INSERT INTO `City` VALUES (406,'Colatina','BRA','Esp\xEDrito Santo',107354); +INSERT INTO `City` VALUES (407,'Santa Cruz do Sul','BRA','Rio Grande do Sul',106734); +INSERT INTO `City` VALUES (408,'Linhares','BRA','Esp\xEDrito Santo',106278); +INSERT INTO `City` VALUES (409,'Apucarana','BRA','Paran\xE1',105114); +INSERT INTO `City` VALUES (410,'Barretos','BRA','S\xE3o Paulo',104156); +INSERT INTO `City` VALUES (411,'Guaratinguet\xE1','BRA','S\xE3o Paulo',103433); +INSERT INTO `City` VALUES (412,'Cachoeirinha','BRA','Rio Grande do Sul',103240); +INSERT INTO `City` VALUES (413,'Cod\xF3','BRA','Maranh\xE3o',103153); +INSERT INTO `City` VALUES (414,'Jaragu\xE1 do Sul','BRA','Santa Catarina',102580); +INSERT INTO `City` VALUES (415,'Cubat\xE3o','BRA','S\xE3o Paulo',102372); +INSERT INTO `City` VALUES (416,'Itabira','BRA','Minas Gerais',102217); +INSERT INTO `City` VALUES (417,'Itaituba','BRA','Par\xE1',101320); +INSERT INTO `City` VALUES (418,'Araras','BRA','S\xE3o Paulo',101046); +INSERT INTO `City` VALUES (419,'Resende','BRA','Rio de Janeiro',100627); +INSERT INTO `City` VALUES (420,'Atibaia','BRA','S\xE3o Paulo',100356); +INSERT INTO `City` VALUES (421,'Pouso Alegre','BRA','Minas Gerais',100028); +INSERT INTO `City` VALUES (422,'Toledo','BRA','Paran\xE1',99387); +INSERT INTO `City` VALUES (423,'Crato','BRA','Cear\xE1',98965); +INSERT INTO `City` VALUES (424,'Passos','BRA','Minas Gerais',98570); +INSERT INTO `City` VALUES (425,'Araguari','BRA','Minas Gerais',98399); +INSERT INTO `City` VALUES (426,'S\xE3o Jos\xE9 de Ribamar','BRA','Maranh\xE3o',98318); +INSERT INTO `City` VALUES (427,'Pinhais','BRA','Paran\xE1',98198); +INSERT INTO `City` VALUES (428,'Sert\xE3ozinho','BRA','S\xE3o Paulo',98140); +INSERT INTO `City` VALUES (429,'Conselheiro Lafaiete','BRA','Minas Gerais',97507); +INSERT INTO `City` VALUES (430,'Paulo Afonso','BRA','Bahia',97291); +INSERT INTO `City` VALUES (431,'Angra dos Reis','BRA','Rio de Janeiro',96864); +INSERT INTO `City` VALUES (432,'Eun\xE1polis','BRA','Bahia',96610); +INSERT INTO `City` VALUES (433,'Salto','BRA','S\xE3o Paulo',96348); +INSERT INTO `City` VALUES (434,'Ourinhos','BRA','S\xE3o Paulo',96291); +INSERT INTO `City` VALUES (435,'Parnamirim','BRA','Rio Grande do Norte',96210); +INSERT INTO `City` VALUES (436,'Jacobina','BRA','Bahia',96131); +INSERT INTO `City` VALUES (437,'Coronel Fabriciano','BRA','Minas Gerais',95933); +INSERT INTO `City` VALUES (438,'Birigui','BRA','S\xE3o Paulo',94685); +INSERT INTO `City` VALUES (439,'Tatu\xED','BRA','S\xE3o Paulo',93897); +INSERT INTO `City` VALUES (440,'Ji-Paran\xE1','BRA','Rond\xF4nia',93346); +INSERT INTO `City` VALUES (441,'Bacabal','BRA','Maranh\xE3o',93121); +INSERT INTO `City` VALUES (442,'Camet\xE1','BRA','Par\xE1',92779); +INSERT INTO `City` VALUES (443,'Gua\xEDba','BRA','Rio Grande do Sul',92224); +INSERT INTO `City` VALUES (444,'S\xE3o Louren\xE7o da Mata','BRA','Pernambuco',91999); +INSERT INTO `City` VALUES (445,'Santana do Livramento','BRA','Rio Grande do Sul',91779); +INSERT INTO `City` VALUES (446,'Votorantim','BRA','S\xE3o Paulo',91777); +INSERT INTO `City` VALUES (447,'Campo Largo','BRA','Paran\xE1',91203); +INSERT INTO `City` VALUES (448,'Patos','BRA','Para\xEDba',90519); +INSERT INTO `City` VALUES (449,'Ituiutaba','BRA','Minas Gerais',90507); +INSERT INTO `City` VALUES (450,'Corumb\xE1','BRA','Mato Grosso do Sul',90111); +INSERT INTO `City` VALUES (451,'Palho\xE7a','BRA','Santa Catarina',89465); +INSERT INTO `City` VALUES (452,'Barra do Pira\xED','BRA','Rio de Janeiro',89388); +INSERT INTO `City` VALUES (453,'Bento Gon\xE7alves','BRA','Rio Grande do Sul',89254); +INSERT INTO `City` VALUES (454,'Po\xE1','BRA','S\xE3o Paulo',89236); +INSERT INTO `City` VALUES (455,'\xC1guas Lindas de Goi\xE1s','BRA','Goi\xE1s',89200); +INSERT INTO `City` VALUES (456,'London','GBR','England',7285000); +INSERT INTO `City` VALUES (457,'Birmingham','GBR','England',1013000); +INSERT INTO `City` VALUES (458,'Glasgow','GBR','Scotland',619680); +INSERT INTO `City` VALUES (459,'Liverpool','GBR','England',461000); +INSERT INTO `City` VALUES (460,'Edinburgh','GBR','Scotland',450180); +INSERT INTO `City` VALUES (461,'Sheffield','GBR','England',431607); +INSERT INTO `City` VALUES (462,'Manchester','GBR','England',430000); +INSERT INTO `City` VALUES (463,'Leeds','GBR','England',424194); +INSERT INTO `City` VALUES (464,'Bristol','GBR','England',402000); +INSERT INTO `City` VALUES (465,'Cardiff','GBR','Wales',321000); +INSERT INTO `City` VALUES (466,'Coventry','GBR','England',304000); +INSERT INTO `City` VALUES (467,'Leicester','GBR','England',294000); +INSERT INTO `City` VALUES (468,'Bradford','GBR','England',289376); +INSERT INTO `City` VALUES (469,'Belfast','GBR','North Ireland',287500); +INSERT INTO `City` VALUES (470,'Nottingham','GBR','England',287000); +INSERT INTO `City` VALUES (471,'Kingston upon Hull','GBR','England',262000); +INSERT INTO `City` VALUES (472,'Plymouth','GBR','England',253000); +INSERT INTO `City` VALUES (473,'Stoke-on-Trent','GBR','England',252000); +INSERT INTO `City` VALUES (474,'Wolverhampton','GBR','England',242000); +INSERT INTO `City` VALUES (475,'Derby','GBR','England',236000); +INSERT INTO `City` VALUES (476,'Swansea','GBR','Wales',230000); +INSERT INTO `City` VALUES (477,'Southampton','GBR','England',216000); +INSERT INTO `City` VALUES (478,'Aberdeen','GBR','Scotland',213070); +INSERT INTO `City` VALUES (479,'Northampton','GBR','England',196000); +INSERT INTO `City` VALUES (480,'Dudley','GBR','England',192171); +INSERT INTO `City` VALUES (481,'Portsmouth','GBR','England',190000); +INSERT INTO `City` VALUES (482,'Newcastle upon Tyne','GBR','England',189150); +INSERT INTO `City` VALUES (483,'Sunderland','GBR','England',183310); +INSERT INTO `City` VALUES (484,'Luton','GBR','England',183000); +INSERT INTO `City` VALUES (485,'Swindon','GBR','England',180000); +INSERT INTO `City` VALUES (486,'Southend-on-Sea','GBR','England',176000); +INSERT INTO `City` VALUES (487,'Walsall','GBR','England',174739); +INSERT INTO `City` VALUES (488,'Bournemouth','GBR','England',162000); +INSERT INTO `City` VALUES (489,'Peterborough','GBR','England',156000); +INSERT INTO `City` VALUES (490,'Brighton','GBR','England',156124); +INSERT INTO `City` VALUES (491,'Blackpool','GBR','England',151000); +INSERT INTO `City` VALUES (492,'Dundee','GBR','Scotland',146690); +INSERT INTO `City` VALUES (493,'West Bromwich','GBR','England',146386); +INSERT INTO `City` VALUES (494,'Reading','GBR','England',148000); +INSERT INTO `City` VALUES (495,'Oldbury/Smethwick (Warley)','GBR','England',145542); +INSERT INTO `City` VALUES (496,'Middlesbrough','GBR','England',145000); +INSERT INTO `City` VALUES (497,'Huddersfield','GBR','England',143726); +INSERT INTO `City` VALUES (498,'Oxford','GBR','England',144000); +INSERT INTO `City` VALUES (499,'Poole','GBR','England',141000); +INSERT INTO `City` VALUES (500,'Bolton','GBR','England',139020); +INSERT INTO `City` VALUES (501,'Blackburn','GBR','England',140000); +INSERT INTO `City` VALUES (502,'Newport','GBR','Wales',139000); +INSERT INTO `City` VALUES (503,'Preston','GBR','England',135000); +INSERT INTO `City` VALUES (504,'Stockport','GBR','England',132813); +INSERT INTO `City` VALUES (505,'Norwich','GBR','England',124000); +INSERT INTO `City` VALUES (506,'Rotherham','GBR','England',121380); +INSERT INTO `City` VALUES (507,'Cambridge','GBR','England',121000); +INSERT INTO `City` VALUES (508,'Watford','GBR','England',113080); +INSERT INTO `City` VALUES (509,'Ipswich','GBR','England',114000); +INSERT INTO `City` VALUES (510,'Slough','GBR','England',112000); +INSERT INTO `City` VALUES (511,'Exeter','GBR','England',111000); +INSERT INTO `City` VALUES (512,'Cheltenham','GBR','England',106000); +INSERT INTO `City` VALUES (513,'Gloucester','GBR','England',107000); +INSERT INTO `City` VALUES (514,'Saint Helens','GBR','England',106293); +INSERT INTO `City` VALUES (515,'Sutton Coldfield','GBR','England',106001); +INSERT INTO `City` VALUES (516,'York','GBR','England',104425); +INSERT INTO `City` VALUES (517,'Oldham','GBR','England',103931); +INSERT INTO `City` VALUES (518,'Basildon','GBR','England',100924); +INSERT INTO `City` VALUES (519,'Worthing','GBR','England',100000); +INSERT INTO `City` VALUES (520,'Chelmsford','GBR','England',97451); +INSERT INTO `City` VALUES (521,'Colchester','GBR','England',96063); +INSERT INTO `City` VALUES (522,'Crawley','GBR','England',97000); +INSERT INTO `City` VALUES (523,'Gillingham','GBR','England',92000); +INSERT INTO `City` VALUES (524,'Solihull','GBR','England',94531); +INSERT INTO `City` VALUES (525,'Rochdale','GBR','England',94313); +INSERT INTO `City` VALUES (526,'Birkenhead','GBR','England',93087); +INSERT INTO `City` VALUES (527,'Worcester','GBR','England',95000); +INSERT INTO `City` VALUES (528,'Hartlepool','GBR','England',92000); +INSERT INTO `City` VALUES (529,'Halifax','GBR','England',91069); +INSERT INTO `City` VALUES (530,'Woking/Byfleet','GBR','England',92000); +INSERT INTO `City` VALUES (531,'Southport','GBR','England',90959); +INSERT INTO `City` VALUES (532,'Maidstone','GBR','England',90878); +INSERT INTO `City` VALUES (533,'Eastbourne','GBR','England',90000); +INSERT INTO `City` VALUES (534,'Grimsby','GBR','England',89000); +INSERT INTO `City` VALUES (535,'Saint Helier','GBR','Jersey',27523); +INSERT INTO `City` VALUES (536,'Douglas','GBR','\x96',23487); +INSERT INTO `City` VALUES (537,'Road Town','VGB','Tortola',8000); +INSERT INTO `City` VALUES (538,'Bandar Seri Begawan','BRN','Brunei and Muara',21484); +INSERT INTO `City` VALUES (539,'Sofija','BGR','Grad Sofija',1122302); +INSERT INTO `City` VALUES (540,'Plovdiv','BGR','Plovdiv',342584); +INSERT INTO `City` VALUES (541,'Varna','BGR','Varna',299801); +INSERT INTO `City` VALUES (542,'Burgas','BGR','Burgas',195255); +INSERT INTO `City` VALUES (543,'Ruse','BGR','Ruse',166467); +INSERT INTO `City` VALUES (544,'Stara Zagora','BGR','Haskovo',147939); +INSERT INTO `City` VALUES (545,'Pleven','BGR','Lovec',121952); +INSERT INTO `City` VALUES (546,'Sliven','BGR','Burgas',105530); +INSERT INTO `City` VALUES (547,'Dobric','BGR','Varna',100399); +INSERT INTO `City` VALUES (548,'\x8Aumen','BGR','Varna',94686); +INSERT INTO `City` VALUES (549,'Ouagadougou','BFA','Kadiogo',824000); +INSERT INTO `City` VALUES (550,'Bobo-Dioulasso','BFA','Houet',300000); +INSERT INTO `City` VALUES (551,'Koudougou','BFA','Boulkiemd\xE9',105000); +INSERT INTO `City` VALUES (552,'Bujumbura','BDI','Bujumbura',300000); +INSERT INTO `City` VALUES (553,'George Town','CYM','Grand Cayman',19600); +INSERT INTO `City` VALUES (554,'Santiago de Chile','CHL','Santiago',4703954); +INSERT INTO `City` VALUES (555,'Puente Alto','CHL','Santiago',386236); +INSERT INTO `City` VALUES (556,'Vi\xF1a del Mar','CHL','Valpara\xEDso',312493); +INSERT INTO `City` VALUES (557,'Valpara\xEDso','CHL','Valpara\xEDso',293800); +INSERT INTO `City` VALUES (558,'Talcahuano','CHL','B\xEDob\xEDo',277752); +INSERT INTO `City` VALUES (559,'Antofagasta','CHL','Antofagasta',251429); +INSERT INTO `City` VALUES (560,'San Bernardo','CHL','Santiago',241910); +INSERT INTO `City` VALUES (561,'Temuco','CHL','La Araucan\xEDa',233041); +INSERT INTO `City` VALUES (562,'Concepci\xF3n','CHL','B\xEDob\xEDo',217664); +INSERT INTO `City` VALUES (563,'Rancagua','CHL','O\xB4Higgins',212977); +INSERT INTO `City` VALUES (564,'Arica','CHL','Tarapac\xE1',189036); +INSERT INTO `City` VALUES (565,'Talca','CHL','Maule',187557); +INSERT INTO `City` VALUES (566,'Chill\xE1n','CHL','B\xEDob\xEDo',178182); +INSERT INTO `City` VALUES (567,'Iquique','CHL','Tarapac\xE1',177892); +INSERT INTO `City` VALUES (568,'Los Angeles','CHL','B\xEDob\xEDo',158215); +INSERT INTO `City` VALUES (569,'Puerto Montt','CHL','Los Lagos',152194); +INSERT INTO `City` VALUES (570,'Coquimbo','CHL','Coquimbo',143353); +INSERT INTO `City` VALUES (571,'Osorno','CHL','Los Lagos',141468); +INSERT INTO `City` VALUES (572,'La Serena','CHL','Coquimbo',137409); +INSERT INTO `City` VALUES (573,'Calama','CHL','Antofagasta',137265); +INSERT INTO `City` VALUES (574,'Valdivia','CHL','Los Lagos',133106); +INSERT INTO `City` VALUES (575,'Punta Arenas','CHL','Magallanes',125631); +INSERT INTO `City` VALUES (576,'Copiap\xF3','CHL','Atacama',120128); +INSERT INTO `City` VALUES (577,'Quilpu\xE9','CHL','Valpara\xEDso',118857); +INSERT INTO `City` VALUES (578,'Curic\xF3','CHL','Maule',115766); +INSERT INTO `City` VALUES (579,'Ovalle','CHL','Coquimbo',94854); +INSERT INTO `City` VALUES (580,'Coronel','CHL','B\xEDob\xEDo',93061); +INSERT INTO `City` VALUES (581,'San Pedro de la Paz','CHL','B\xEDob\xEDo',91684); +INSERT INTO `City` VALUES (582,'Melipilla','CHL','Santiago',91056); +INSERT INTO `City` VALUES (583,'Avarua','COK','Rarotonga',11900); +INSERT INTO `City` VALUES (584,'San Jos\xE9','CRI','San Jos\xE9',339131); +INSERT INTO `City` VALUES (585,'Djibouti','DJI','Djibouti',383000); +INSERT INTO `City` VALUES (586,'Roseau','DMA','St George',16243); +INSERT INTO `City` VALUES (587,'Santo Domingo de Guzm\xE1n','DOM','Distrito Nacional',1609966); +INSERT INTO `City` VALUES (588,'Santiago de los Caballeros','DOM','Santiago',365463); +INSERT INTO `City` VALUES (589,'La Romana','DOM','La Romana',140204); +INSERT INTO `City` VALUES (590,'San Pedro de Macor\xEDs','DOM','San Pedro de Macor\xEDs',124735); +INSERT INTO `City` VALUES (591,'San Francisco de Macor\xEDs','DOM','Duarte',108485); +INSERT INTO `City` VALUES (592,'San Felipe de Puerto Plata','DOM','Puerto Plata',89423); +INSERT INTO `City` VALUES (593,'Guayaquil','ECU','Guayas',2070040); +INSERT INTO `City` VALUES (594,'Quito','ECU','Pichincha',1573458); +INSERT INTO `City` VALUES (595,'Cuenca','ECU','Azuay',270353); +INSERT INTO `City` VALUES (596,'Machala','ECU','El Oro',210368); +INSERT INTO `City` VALUES (597,'Santo Domingo de los Colorados','ECU','Pichincha',202111); +INSERT INTO `City` VALUES (598,'Portoviejo','ECU','Manab\xED',176413); +INSERT INTO `City` VALUES (599,'Ambato','ECU','Tungurahua',169612); +INSERT INTO `City` VALUES (600,'Manta','ECU','Manab\xED',164739); +INSERT INTO `City` VALUES (601,'Duran [Eloy Alfaro]','ECU','Guayas',152514); +INSERT INTO `City` VALUES (602,'Ibarra','ECU','Imbabura',130643); +INSERT INTO `City` VALUES (603,'Quevedo','ECU','Los R\xEDos',129631); +INSERT INTO `City` VALUES (604,'Milagro','ECU','Guayas',124177); +INSERT INTO `City` VALUES (605,'Loja','ECU','Loja',123875); +INSERT INTO `City` VALUES (606,'R\xEDobamba','ECU','Chimborazo',123163); +INSERT INTO `City` VALUES (607,'Esmeraldas','ECU','Esmeraldas',123045); +INSERT INTO `City` VALUES (608,'Cairo','EGY','Kairo',6789479); +INSERT INTO `City` VALUES (609,'Alexandria','EGY','Aleksandria',3328196); +INSERT INTO `City` VALUES (610,'Giza','EGY','Giza',2221868); +INSERT INTO `City` VALUES (611,'Shubra al-Khayma','EGY','al-Qalyubiya',870716); +INSERT INTO `City` VALUES (612,'Port Said','EGY','Port Said',469533); +INSERT INTO `City` VALUES (613,'Suez','EGY','Suez',417610); +INSERT INTO `City` VALUES (614,'al-Mahallat al-Kubra','EGY','al-Gharbiya',395402); +INSERT INTO `City` VALUES (615,'Tanta','EGY','al-Gharbiya',371010); +INSERT INTO `City` VALUES (616,'al-Mansura','EGY','al-Daqahliya',369621); +INSERT INTO `City` VALUES (617,'Luxor','EGY','Luxor',360503); +INSERT INTO `City` VALUES (618,'Asyut','EGY','Asyut',343498); +INSERT INTO `City` VALUES (619,'Bahtim','EGY','al-Qalyubiya',275807); +INSERT INTO `City` VALUES (620,'Zagazig','EGY','al-Sharqiya',267351); +INSERT INTO `City` VALUES (621,'al-Faiyum','EGY','al-Faiyum',260964); +INSERT INTO `City` VALUES (622,'Ismailia','EGY','Ismailia',254477); +INSERT INTO `City` VALUES (623,'Kafr al-Dawwar','EGY','al-Buhayra',231978); +INSERT INTO `City` VALUES (624,'Assuan','EGY','Assuan',219017); +INSERT INTO `City` VALUES (625,'Damanhur','EGY','al-Buhayra',212203); +INSERT INTO `City` VALUES (626,'al-Minya','EGY','al-Minya',201360); +INSERT INTO `City` VALUES (627,'Bani Suwayf','EGY','Bani Suwayf',172032); +INSERT INTO `City` VALUES (628,'Qina','EGY','Qina',171275); +INSERT INTO `City` VALUES (629,'Sawhaj','EGY','Sawhaj',170125); +INSERT INTO `City` VALUES (630,'Shibin al-Kawm','EGY','al-Minufiya',159909); +INSERT INTO `City` VALUES (631,'Bulaq al-Dakrur','EGY','Giza',148787); +INSERT INTO `City` VALUES (632,'Banha','EGY','al-Qalyubiya',145792); +INSERT INTO `City` VALUES (633,'Warraq al-Arab','EGY','Giza',127108); +INSERT INTO `City` VALUES (634,'Kafr al-Shaykh','EGY','Kafr al-Shaykh',124819); +INSERT INTO `City` VALUES (635,'Mallawi','EGY','al-Minya',119283); +INSERT INTO `City` VALUES (636,'Bilbays','EGY','al-Sharqiya',113608); +INSERT INTO `City` VALUES (637,'Mit Ghamr','EGY','al-Daqahliya',101801); +INSERT INTO `City` VALUES (638,'al-Arish','EGY','Shamal Sina',100447); +INSERT INTO `City` VALUES (639,'Talkha','EGY','al-Daqahliya',97700); +INSERT INTO `City` VALUES (640,'Qalyub','EGY','al-Qalyubiya',97200); +INSERT INTO `City` VALUES (641,'Jirja','EGY','Sawhaj',95400); +INSERT INTO `City` VALUES (642,'Idfu','EGY','Qina',94200); +INSERT INTO `City` VALUES (643,'al-Hawamidiya','EGY','Giza',91700); +INSERT INTO `City` VALUES (644,'Disuq','EGY','Kafr al-Shaykh',91300); +INSERT INTO `City` VALUES (645,'San Salvador','SLV','San Salvador',415346); +INSERT INTO `City` VALUES (646,'Santa Ana','SLV','Santa Ana',139389); +INSERT INTO `City` VALUES (647,'Mejicanos','SLV','San Salvador',138800); +INSERT INTO `City` VALUES (648,'Soyapango','SLV','San Salvador',129800); +INSERT INTO `City` VALUES (649,'San Miguel','SLV','San Miguel',127696); +INSERT INTO `City` VALUES (650,'Nueva San Salvador','SLV','La Libertad',98400); +INSERT INTO `City` VALUES (651,'Apopa','SLV','San Salvador',88800); +INSERT INTO `City` VALUES (652,'Asmara','ERI','Maekel',431000); +INSERT INTO `City` VALUES (653,'Madrid','ESP','Madrid',2879052); +INSERT INTO `City` VALUES (654,'Barcelona','ESP','Katalonia',1503451); +INSERT INTO `City` VALUES (655,'Valencia','ESP','Valencia',739412); +INSERT INTO `City` VALUES (656,'Sevilla','ESP','Andalusia',701927); +INSERT INTO `City` VALUES (657,'Zaragoza','ESP','Aragonia',603367); +INSERT INTO `City` VALUES (658,'M\xE1laga','ESP','Andalusia',530553); +INSERT INTO `City` VALUES (659,'Bilbao','ESP','Baskimaa',357589); +INSERT INTO `City` VALUES (660,'Las Palmas de Gran Canaria','ESP','Canary Islands',354757); +INSERT INTO `City` VALUES (661,'Murcia','ESP','Murcia',353504); +INSERT INTO `City` VALUES (662,'Palma de Mallorca','ESP','Balears',326993); +INSERT INTO `City` VALUES (663,'Valladolid','ESP','Castilla and Le\xF3n',319998); +INSERT INTO `City` VALUES (664,'C\xF3rdoba','ESP','Andalusia',311708); +INSERT INTO `City` VALUES (665,'Vigo','ESP','Galicia',283670); +INSERT INTO `City` VALUES (666,'Alicante [Alacant]','ESP','Valencia',272432); +INSERT INTO `City` VALUES (667,'Gij\xF3n','ESP','Asturia',267980); +INSERT INTO `City` VALUES (668,'L\xB4Hospitalet de Llobregat','ESP','Katalonia',247986); +INSERT INTO `City` VALUES (669,'Granada','ESP','Andalusia',244767); +INSERT INTO `City` VALUES (670,'A Coru\xF1a (La Coru\xF1a)','ESP','Galicia',243402); +INSERT INTO `City` VALUES (671,'Vitoria-Gasteiz','ESP','Baskimaa',217154); +INSERT INTO `City` VALUES (672,'Santa Cruz de Tenerife','ESP','Canary Islands',213050); +INSERT INTO `City` VALUES (673,'Badalona','ESP','Katalonia',209635); +INSERT INTO `City` VALUES (674,'Oviedo','ESP','Asturia',200453); +INSERT INTO `City` VALUES (675,'M\xF3stoles','ESP','Madrid',195351); +INSERT INTO `City` VALUES (676,'Elche [Elx]','ESP','Valencia',193174); +INSERT INTO `City` VALUES (677,'Sabadell','ESP','Katalonia',184859); +INSERT INTO `City` VALUES (678,'Santander','ESP','Cantabria',184165); +INSERT INTO `City` VALUES (679,'Jerez de la Frontera','ESP','Andalusia',182660); +INSERT INTO `City` VALUES (680,'Pamplona [Iru\xF1a]','ESP','Navarra',180483); +INSERT INTO `City` VALUES (681,'Donostia-San Sebasti\xE1n','ESP','Baskimaa',179208); +INSERT INTO `City` VALUES (682,'Cartagena','ESP','Murcia',177709); +INSERT INTO `City` VALUES (683,'Legan\xE9s','ESP','Madrid',173163); +INSERT INTO `City` VALUES (684,'Fuenlabrada','ESP','Madrid',171173); +INSERT INTO `City` VALUES (685,'Almer\xEDa','ESP','Andalusia',169027); +INSERT INTO `City` VALUES (686,'Terrassa','ESP','Katalonia',168695); +INSERT INTO `City` VALUES (687,'Alcal\xE1 de Henares','ESP','Madrid',164463); +INSERT INTO `City` VALUES (688,'Burgos','ESP','Castilla and Le\xF3n',162802); +INSERT INTO `City` VALUES (689,'Salamanca','ESP','Castilla and Le\xF3n',158720); +INSERT INTO `City` VALUES (690,'Albacete','ESP','Kastilia-La Mancha',147527); +INSERT INTO `City` VALUES (691,'Getafe','ESP','Madrid',145371); +INSERT INTO `City` VALUES (692,'C\xE1diz','ESP','Andalusia',142449); +INSERT INTO `City` VALUES (693,'Alcorc\xF3n','ESP','Madrid',142048); +INSERT INTO `City` VALUES (694,'Huelva','ESP','Andalusia',140583); +INSERT INTO `City` VALUES (695,'Le\xF3n','ESP','Castilla and Le\xF3n',139809); +INSERT INTO `City` VALUES (696,'Castell\xF3n de la Plana [Castell','ESP','Valencia',139712); +INSERT INTO `City` VALUES (697,'Badajoz','ESP','Extremadura',136613); +INSERT INTO `City` VALUES (698,'[San Crist\xF3bal de] la Laguna','ESP','Canary Islands',127945); +INSERT INTO `City` VALUES (699,'Logro\xF1o','ESP','La Rioja',127093); +INSERT INTO `City` VALUES (700,'Santa Coloma de Gramenet','ESP','Katalonia',120802); +INSERT INTO `City` VALUES (701,'Tarragona','ESP','Katalonia',113016); +INSERT INTO `City` VALUES (702,'Lleida (L\xE9rida)','ESP','Katalonia',112207); +INSERT INTO `City` VALUES (703,'Ja\xE9n','ESP','Andalusia',109247); +INSERT INTO `City` VALUES (704,'Ourense (Orense)','ESP','Galicia',109120); +INSERT INTO `City` VALUES (705,'Matar\xF3','ESP','Katalonia',104095); +INSERT INTO `City` VALUES (706,'Algeciras','ESP','Andalusia',103106); +INSERT INTO `City` VALUES (707,'Marbella','ESP','Andalusia',101144); +INSERT INTO `City` VALUES (708,'Barakaldo','ESP','Baskimaa',98212); +INSERT INTO `City` VALUES (709,'Dos Hermanas','ESP','Andalusia',94591); +INSERT INTO `City` VALUES (710,'Santiago de Compostela','ESP','Galicia',93745); +INSERT INTO `City` VALUES (711,'Torrej\xF3n de Ardoz','ESP','Madrid',92262); +INSERT INTO `City` VALUES (712,'Cape Town','ZAF','Western Cape',2352121); +INSERT INTO `City` VALUES (713,'Soweto','ZAF','Gauteng',904165); +INSERT INTO `City` VALUES (714,'Johannesburg','ZAF','Gauteng',756653); +INSERT INTO `City` VALUES (715,'Port Elizabeth','ZAF','Eastern Cape',752319); +INSERT INTO `City` VALUES (716,'Pretoria','ZAF','Gauteng',658630); +INSERT INTO `City` VALUES (717,'Inanda','ZAF','KwaZulu-Natal',634065); +INSERT INTO `City` VALUES (718,'Durban','ZAF','KwaZulu-Natal',566120); +INSERT INTO `City` VALUES (719,'Vanderbijlpark','ZAF','Gauteng',468931); +INSERT INTO `City` VALUES (720,'Kempton Park','ZAF','Gauteng',442633); +INSERT INTO `City` VALUES (721,'Alberton','ZAF','Gauteng',410102); +INSERT INTO `City` VALUES (722,'Pinetown','ZAF','KwaZulu-Natal',378810); +INSERT INTO `City` VALUES (723,'Pietermaritzburg','ZAF','KwaZulu-Natal',370190); +INSERT INTO `City` VALUES (724,'Benoni','ZAF','Gauteng',365467); +INSERT INTO `City` VALUES (725,'Randburg','ZAF','Gauteng',341288); +INSERT INTO `City` VALUES (726,'Umlazi','ZAF','KwaZulu-Natal',339233); +INSERT INTO `City` VALUES (727,'Bloemfontein','ZAF','Free State',334341); +INSERT INTO `City` VALUES (728,'Vereeniging','ZAF','Gauteng',328535); +INSERT INTO `City` VALUES (729,'Wonderboom','ZAF','Gauteng',283289); +INSERT INTO `City` VALUES (730,'Roodepoort','ZAF','Gauteng',279340); +INSERT INTO `City` VALUES (731,'Boksburg','ZAF','Gauteng',262648); +INSERT INTO `City` VALUES (732,'Klerksdorp','ZAF','North West',261911); +INSERT INTO `City` VALUES (733,'Soshanguve','ZAF','Gauteng',242727); +INSERT INTO `City` VALUES (734,'Newcastle','ZAF','KwaZulu-Natal',222993); +INSERT INTO `City` VALUES (735,'East London','ZAF','Eastern Cape',221047); +INSERT INTO `City` VALUES (736,'Welkom','ZAF','Free State',203296); +INSERT INTO `City` VALUES (737,'Kimberley','ZAF','Northern Cape',197254); +INSERT INTO `City` VALUES (738,'Uitenhage','ZAF','Eastern Cape',192120); +INSERT INTO `City` VALUES (739,'Chatsworth','ZAF','KwaZulu-Natal',189885); +INSERT INTO `City` VALUES (740,'Mdantsane','ZAF','Eastern Cape',182639); +INSERT INTO `City` VALUES (741,'Krugersdorp','ZAF','Gauteng',181503); +INSERT INTO `City` VALUES (742,'Botshabelo','ZAF','Free State',177971); +INSERT INTO `City` VALUES (743,'Brakpan','ZAF','Gauteng',171363); +INSERT INTO `City` VALUES (744,'Witbank','ZAF','Mpumalanga',167183); +INSERT INTO `City` VALUES (745,'Oberholzer','ZAF','Gauteng',164367); +INSERT INTO `City` VALUES (746,'Germiston','ZAF','Gauteng',164252); +INSERT INTO `City` VALUES (747,'Springs','ZAF','Gauteng',162072); +INSERT INTO `City` VALUES (748,'Westonaria','ZAF','Gauteng',159632); +INSERT INTO `City` VALUES (749,'Randfontein','ZAF','Gauteng',120838); +INSERT INTO `City` VALUES (750,'Paarl','ZAF','Western Cape',105768); +INSERT INTO `City` VALUES (751,'Potchefstroom','ZAF','North West',101817); +INSERT INTO `City` VALUES (752,'Rustenburg','ZAF','North West',97008); +INSERT INTO `City` VALUES (753,'Nigel','ZAF','Gauteng',96734); +INSERT INTO `City` VALUES (754,'George','ZAF','Western Cape',93818); +INSERT INTO `City` VALUES (755,'Ladysmith','ZAF','KwaZulu-Natal',89292); +INSERT INTO `City` VALUES (756,'Addis Abeba','ETH','Addis Abeba',2495000); +INSERT INTO `City` VALUES (757,'Dire Dawa','ETH','Dire Dawa',164851); +INSERT INTO `City` VALUES (758,'Nazret','ETH','Oromia',127842); +INSERT INTO `City` VALUES (759,'Gonder','ETH','Amhara',112249); +INSERT INTO `City` VALUES (760,'Dese','ETH','Amhara',97314); +INSERT INTO `City` VALUES (761,'Mekele','ETH','Tigray',96938); +INSERT INTO `City` VALUES (762,'Bahir Dar','ETH','Amhara',96140); +INSERT INTO `City` VALUES (763,'Stanley','FLK','East Falkland',1636); +INSERT INTO `City` VALUES (764,'Suva','FJI','Central',77366); +INSERT INTO `City` VALUES (765,'Quezon','PHL','National Capital Reg',2173831); +INSERT INTO `City` VALUES (766,'Manila','PHL','National Capital Reg',1581082); +INSERT INTO `City` VALUES (767,'Kalookan','PHL','National Capital Reg',1177604); +INSERT INTO `City` VALUES (768,'Davao','PHL','Southern Mindanao',1147116); +INSERT INTO `City` VALUES (769,'Cebu','PHL','Central Visayas',718821); +INSERT INTO `City` VALUES (770,'Zamboanga','PHL','Western Mindanao',601794); +INSERT INTO `City` VALUES (771,'Pasig','PHL','National Capital Reg',505058); +INSERT INTO `City` VALUES (772,'Valenzuela','PHL','National Capital Reg',485433); +INSERT INTO `City` VALUES (773,'Las Pi\xF1as','PHL','National Capital Reg',472780); +INSERT INTO `City` VALUES (774,'Antipolo','PHL','Southern Tagalog',470866); +INSERT INTO `City` VALUES (775,'Taguig','PHL','National Capital Reg',467375); +INSERT INTO `City` VALUES (776,'Cagayan de Oro','PHL','Northern Mindanao',461877); +INSERT INTO `City` VALUES (777,'Para\xF1aque','PHL','National Capital Reg',449811); +INSERT INTO `City` VALUES (778,'Makati','PHL','National Capital Reg',444867); +INSERT INTO `City` VALUES (779,'Bacolod','PHL','Western Visayas',429076); +INSERT INTO `City` VALUES (780,'General Santos','PHL','Southern Mindanao',411822); +INSERT INTO `City` VALUES (781,'Marikina','PHL','National Capital Reg',391170); +INSERT INTO `City` VALUES (782,'Dasmari\xF1as','PHL','Southern Tagalog',379520); +INSERT INTO `City` VALUES (783,'Muntinlupa','PHL','National Capital Reg',379310); +INSERT INTO `City` VALUES (784,'Iloilo','PHL','Western Visayas',365820); +INSERT INTO `City` VALUES (785,'Pasay','PHL','National Capital Reg',354908); +INSERT INTO `City` VALUES (786,'Malabon','PHL','National Capital Reg',338855); +INSERT INTO `City` VALUES (787,'San Jos\xE9 del Monte','PHL','Central Luzon',315807); +INSERT INTO `City` VALUES (788,'Bacoor','PHL','Southern Tagalog',305699); +INSERT INTO `City` VALUES (789,'Iligan','PHL','Central Mindanao',285061); +INSERT INTO `City` VALUES (790,'Calamba','PHL','Southern Tagalog',281146); +INSERT INTO `City` VALUES (791,'Mandaluyong','PHL','National Capital Reg',278474); +INSERT INTO `City` VALUES (792,'Butuan','PHL','Caraga',267279); +INSERT INTO `City` VALUES (793,'Angeles','PHL','Central Luzon',263971); +INSERT INTO `City` VALUES (794,'Tarlac','PHL','Central Luzon',262481); +INSERT INTO `City` VALUES (795,'Mandaue','PHL','Central Visayas',259728); +INSERT INTO `City` VALUES (796,'Baguio','PHL','CAR',252386); +INSERT INTO `City` VALUES (797,'Batangas','PHL','Southern Tagalog',247588); +INSERT INTO `City` VALUES (798,'Cainta','PHL','Southern Tagalog',242511); +INSERT INTO `City` VALUES (799,'San Pedro','PHL','Southern Tagalog',231403); +INSERT INTO `City` VALUES (800,'Navotas','PHL','National Capital Reg',230403); +INSERT INTO `City` VALUES (801,'Cabanatuan','PHL','Central Luzon',222859); +INSERT INTO `City` VALUES (802,'San Fernando','PHL','Central Luzon',221857); +INSERT INTO `City` VALUES (803,'Lipa','PHL','Southern Tagalog',218447); +INSERT INTO `City` VALUES (804,'Lapu-Lapu','PHL','Central Visayas',217019); +INSERT INTO `City` VALUES (805,'San Pablo','PHL','Southern Tagalog',207927); +INSERT INTO `City` VALUES (806,'Bi\xF1an','PHL','Southern Tagalog',201186); +INSERT INTO `City` VALUES (807,'Taytay','PHL','Southern Tagalog',198183); +INSERT INTO `City` V... [truncated message content] |