Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
Remove py3-incompatible use of unicode() function.
Browse files Browse the repository at this point in the history
Finishing off changes started in e639caa and carried on in a9bd342.
  • Loading branch information
dracos committed Jul 14, 2015
1 parent 0e4e559 commit e21448e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mapit_gb/management/commands/mapit_UK_fix_2011-10.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from optparse import make_option
from django.core.management.base import LabelCommand
from django.contrib.gis.gdal import DataSource
from django.utils import six

from mapit.models import Area, CodeType
from utils import save_polygons

Expand All @@ -19,7 +21,9 @@ class Command(LabelCommand):
def handle_label(self, filename, **options):
code_version = CodeType.objects.get(code='gss')
for feat in DataSource(filename)[0]:
name = unicode(feat['NAME'].value, 'iso-8859-1')
name = feat['NAME'].value
if not isinstance(name, six.text_type):
name = name.decode('iso-8859-1')
ons_code = feat['CODE'].value
if ons_code in ('E04008782', 'E05004419'):
m = Area.objects.get(codes__type=code_version, codes__code=ons_code)
Expand Down
6 changes: 5 additions & 1 deletion mapit_gb/management/commands/mapit_UK_fix_2012-05.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from optparse import make_option
from django.core.management.base import LabelCommand
from django.contrib.gis.gdal import DataSource
from django.utils import six

from mapit.models import Area, CodeType, Type, Country, Generation, NameType
from utils import save_polygons

Expand All @@ -23,7 +25,9 @@ def handle_label(self, filename, **options):
code_version = CodeType.objects.get(code='gss')
name_type = NameType.objects.get(code='O')
for feat in DataSource(filename)[0]:
name = unicode(feat['NAME'].value, 'iso-8859-1')
name = feat['NAME'].value
if not isinstance(name, six.text_type):
name = name.decode('iso-8859-1')
name = re.sub('\s*\(DET( NO \d+|)\)\s*(?i)', '', name)
name = re.sub('\s+', ' ', name)
ons_code = feat['CODE'].value
Expand Down

0 comments on commit e21448e

Please sign in to comment.