[Thuban-commits] r2839 - in branches/WIP-pyshapelib-Unicode/thuban: . Thuban/Model test

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 14 01:19:15 CET 2008


Author: bernhard
Date: 2008-02-14 01:19:14 +0100 (Thu, 14 Feb 2008)
New Revision: 2839

Modified:
   branches/WIP-pyshapelib-Unicode/thuban/ChangeLog
   branches/WIP-pyshapelib-Unicode/thuban/Thuban/Model/table.py
   branches/WIP-pyshapelib-Unicode/thuban/test/test_load.py
Log:
* Thuban/Model/table.py: Using internal_from_unicode() when reading
dbflib column names and unicode_from_internal() when writing them.

* test/test_load.py(TestNonAsciiColumnName), applied change rev2838 from
  test/test_load_1_0.py(TestNonAsciiColumnName),


Modified: branches/WIP-pyshapelib-Unicode/thuban/ChangeLog
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/ChangeLog	2008-02-13 23:47:20 UTC (rev 2838)
+++ branches/WIP-pyshapelib-Unicode/thuban/ChangeLog	2008-02-14 00:19:14 UTC (rev 2839)
@@ -1,6 +1,10 @@
 2008-02-14  Bernhard Reiter <bernhard at intevation.de>
+	
+	* Thuban/Model/table.py: Using internal_from_unicode() when reading
+	dbflib column names and unicode_from_internal() when writing them.
 
-	* test/test_load_1_0.py( TestNonAsciiColumnName): Compare result
+	* test/test_load_1_0.py(TestNonAsciiColumnName),
+	test/test_load.py(TestNonAsciiColumnName): Compare result
 	of layer.GetClassificationColumn() with string in internal encoding,
 	this makes this test work with --internal-encoding=uncode.
 	Given that the new dbflib should deal with unicode objects,

Modified: branches/WIP-pyshapelib-Unicode/thuban/Thuban/Model/table.py
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/Thuban/Model/table.py	2008-02-13 23:47:20 UTC (rev 2838)
+++ branches/WIP-pyshapelib-Unicode/thuban/Thuban/Model/table.py	2008-02-14 00:19:14 UTC (rev 2839)
@@ -19,6 +19,8 @@
 
 from base import TitledObject
 
+from Thuban import internal_from_unicode, unicode_from_internal
+
 import dbflib
 
 # the field types supported by a Table instance.
@@ -96,8 +98,10 @@
         self.column_map = {}
         for i in range(self.NumColumns()):
             ftype, name, width, prec = self.dbf.field_info(i)
+            name = internal_from_unicode(name)
             ftype = dbflib_fieldtypes[ftype]
             index = len(self.columns)
+
             col = DBFColumn(name, ftype, width, prec, index)
             self.columns.append(col)
             self.column_map[name] = col
@@ -478,7 +482,8 @@
             prec = getattr(col, "prec", 12)
         else:
             prec = 0
-        dbf.add_field(name_map[col.name], dbflib_fieldtypes[col.type],
+        dbf.add_field(unicode_from_internal(name_map[col.name]), 
+                      dbflib_fieldtypes[col.type],
                       width, prec)
 
     if rows is None:

Modified: branches/WIP-pyshapelib-Unicode/thuban/test/test_load.py
===================================================================
--- branches/WIP-pyshapelib-Unicode/thuban/test/test_load.py	2008-02-13 23:47:20 UTC (rev 2838)
+++ branches/WIP-pyshapelib-Unicode/thuban/test/test_load.py	2008-02-14 00:19:14 UTC (rev 2839)
@@ -318,7 +318,7 @@
         dbffile = self.temp_file_name("TestNonAsciiColumnName.dbf")
         shpfile = self.temp_file_name("TestNonAsciiColumnName.shp")
         dbf = dbflib.create(dbffile)
-        dbf.add_field('Fl\xe4che', dbflib.FTDouble, 10, 5)
+        dbf.add_field(u'Fl\xe4che', dbflib.FTDouble, 10, 5)
         dbf.write_record(0, (0.0,))
         dbf.close()
         shp = shapelib.create(shpfile, shapelib.SHPT_POLYGON)
@@ -348,7 +348,8 @@
         # too
         layer = session.Maps()[0].Layers()[0]
         try:
-            self.assertEquals(layer.GetClassificationColumn(), 'Fl\xe4che')
+            self.assertEquals(layer.GetClassificationColumn(), 
+                internal_from_unicode(u'Fl\xe4che'))
         except UnicodeError:
             # FIXME: Obviously this will have to change if Thuban ever
             # supports unicode properly.



More information about the Thuban-commits mailing list