Skip to content

Commit

Permalink
Remove use of the u() function from the six compatibility library
Browse files Browse the repository at this point in the history
As we definitely expect to turn on Python 3.3+, we can expect the
u prefix to be available and thus no longer need to use this
compatibility function.
  • Loading branch information
M4rtinK committed Apr 12, 2020
1 parent 805c19b commit b9226b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
24 changes: 11 additions & 13 deletions core/poi_db.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""A modRana POI database class"""

import os
import sys
import sqlite3
from core.point import POI
from core.backports.six import u

import logging
log = logging.getLogger("core.poi_db")
Expand Down Expand Up @@ -69,17 +67,17 @@ def create_empty_db(self, db_path):
'CREATE TABLE poi (poi_id integer PRIMARY KEY, lat real, lon real, label text, desc text, cat_id integer)')
# load the predefined categories
# (currently the same ones as in MaemoMapper)
defaultCats = [(1, u('Service Station'), u('Stations for purchasing fuel for vehicles.'), 1),
(2, u('Residence'), u('Houses, apartments, or other residences of import.'), 1),
(3, u('Restaurant'), u('Places to eat or drink.'), 1),
(4, u('Shopping/Services'), u('Places to shop or acquire services.'), 1),
(5, u('Recreation'), u('Indoor or Outdoor places to have fun.'), 1),
(6, u('Transportation'), u('Bus stops, airports, train stations, etc.'), 1),
(7, u('Lodging'), u('Places to stay temporarily or for the night.'), 1),
(8, u('School'), u('Elementary schools, college campuses, etc.'), 1),
(9, u('Business'), u('General places of business.'), 1),
(10, u('Landmark'), u('General landmarks.'), 1),
(11, u('Other'), u('Miscellaneous category for everything else.'), 1)]
defaultCats = [(1, u'Service Station', u'Stations for purchasing fuel for vehicles.', 1),
(2, u'Residence', u'Houses, apartments, or other residences of import.', 1),
(3, u'Restaurant', u'Places to eat or drink.', 1),
(4, u'Shopping/Services', u'Places to shop or acquire services.', 1),
(5, u'Recreation', u'Indoor or Outdoor places to have fun.', 1),
(6, u'Transportation', u'Bus stops, airports, train stations, etc.', 1),
(7, u'Lodging', u'Places to stay temporarily or for the night.', 1),
(8, u'School', u'Elementary schools, college campuses, etc.', 1),
(9, u'Business', u'General places of business.', 1),
(10, u'Landmark', u'General landmarks.', 1),
(11, u'Other', u'Miscellaneous category for everything else.', 1)]
for cat in defaultCats:
conn.execute('insert into category values(?,?,?,?)', cat)
# commit the changes
Expand Down
5 changes: 2 additions & 3 deletions core/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from core import constants
from core.singleton import modrana
from core.backports.six import u

import logging
log = logging.getLogger("core.point")
Expand Down Expand Up @@ -153,8 +152,8 @@ class POI(Point):
def __init__(self, name, description, lat, lon, db_cat_id, db_poi_id=None):
self.id = db_poi_id
# this probably handles some Unicode encoding issues
name = u('%s') % name
description = u('%s') % description
name = u'%s' % name
description = u'%s' % description
Point.__init__(self, lat, lon, name=name, message=description)
self._db_category_index = db_cat_id

Expand Down
7 changes: 3 additions & 4 deletions modules/mod_route/mod_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from core.point import Waypoint, TurnByTurnPoint
from core.signal import Signal
from core.way import Way
from core.backports.six import u
from core import routing_providers


Expand Down Expand Up @@ -130,8 +129,8 @@ def _load_directions_filter(self):
self._directions_filter_rules = []
for row in CSVReader:
if row[0] != '#' and len(row) >= 2:
regex = re.compile(u(row[0]))
self._directions_filter_rules.append((regex, u(row[1])))
regex = re.compile(row[0])
self._directions_filter_rules.append((regex, row[1]))
f.close()
self._directions_filter_rules_loaded = True
self.log.debug("directions filter loaded in %1.2f ms", (time.time() - start) * 1000)
Expand Down Expand Up @@ -743,7 +742,7 @@ def _process_cyrillic_string(self, inputString, voiceCode):
# test if the word has any cyrillic characters (a single one is enough)
for character in substring:
try: # there are probably some characters that dont have a known name
unicode_name = unicodedata.name(u(character))
unicode_name = unicodedata.name(character)
if unicode_name.find('CYRILLIC') != -1:
cyrillic_char_found = True
break
Expand Down

0 comments on commit b9226b7

Please sign in to comment.