From b9226b7ca21d7c14ea94fd691b6f0144262b05a6 Mon Sep 17 00:00:00 2001 From: Martin Kolman Date: Sun, 12 Apr 2020 21:55:29 +0200 Subject: [PATCH] Remove use of the u() function from the six compatibility library 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. --- core/poi_db.py | 24 +++++++++++------------- core/point.py | 5 ++--- modules/mod_route/mod_route.py | 7 +++---- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/core/poi_db.py b/core/poi_db.py index 7975e779..f17de1ca 100644 --- a/core/poi_db.py +++ b/core/poi_db.py @@ -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") @@ -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 diff --git a/core/point.py b/core/point.py index 9320f5e7..256d3e3a 100644 --- a/core/point.py +++ b/core/point.py @@ -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") @@ -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 diff --git a/modules/mod_route/mod_route.py b/modules/mod_route/mod_route.py index 64afe80f..ee2b0f29 100644 --- a/modules/mod_route/mod_route.py +++ b/modules/mod_route/mod_route.py @@ -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 @@ -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) @@ -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