Permalink
Browse files

Continuing e639caa, fix other scripts similarly.

  • Loading branch information...
1 parent 6e70471 commit 790f9932f41764309d02b286f3a45de281dfac29 @dracos dracos committed Dec 19, 2013
Showing with 5 additions and 2 deletions.
  1. +3 −1 mapit/management/commands/mapit_NO_import_osm.py
  2. +2 −1 mapit/management/commands/mapit_import.py
@@ -40,7 +40,9 @@ def handle_label(self, filename, **options):
ds = DataSource(filename)
layer = ds[0]
for feat in layer:
- name = feat['Name'].value.decode('utf-8')
+ name = feat['Name'].value
+ if not isinstance(name, unicode):
+ name = name.decode('utf-8')
name = re.sub('\s+', ' ', name)
print " ", name.encode('utf-8')
@@ -211,7 +211,8 @@ def verbose(*args):
print "Could not find name using name field '%s' - should it be something else? It will be one of these: %s. Specify which with --name_field" % (name_field, choices)
sys.exit(1)
try:
- name = name.decode(encoding)
+ if not isinstance(name, unicode):
+ name = name.decode(encoding)
except:
print "Could not decode name using encoding '%s' - is it in another encoding? Specify one with --encoding" % encoding
sys.exit(1)

0 comments on commit 790f993

Please sign in to comment.