diff --git a/core/routing_providers.py b/core/routing_providers.py index d3caab8d..1723d170 100644 --- a/core/routing_providers.py +++ b/core/routing_providers.py @@ -3,7 +3,6 @@ import time from core import constants from core.way import Way -from core.backports import six from urllib.request import urlopen @@ -199,9 +198,9 @@ def _googleDirections(start, destination, waypoints, params): # check if start and destination are string, # otherwise convert to lat,lon strings from Points - if not isinstance(start, six.string_types): + if not isinstance(start, str): start = "%f,%f" % (start.lat, start.lon) - if not isinstance(destination, six.string_types): + if not isinstance(destination, str): destination = "%f,%f" % (destination.lat, destination.lon) if not waypoints: waypoints = [] diff --git a/core/tile_storage/utils.py b/core/tile_storage/utils.py index fc9b6991..d9a3e794 100644 --- a/core/tile_storage/utils.py +++ b/core/tile_storage/utils.py @@ -1,6 +1,4 @@ """Various tile handling utility functions""" -import six -from six import b import os import logging @@ -17,13 +15,13 @@ def is_an_image(tile_data): # NOTE: magic numbers taken from imghdr source code # as most tiles are PNGs, check for PNG first - if h[:8] == b("\211PNG\r\n\032\n"): + if h[:8] == b"\211PNG\r\n\032\n": return "png" - elif h[6:10] in (b('JFIF'), b('Exif')): # JPEG in JFIF or Exif format + elif h[6:10] in (b'JFIF', b'Exif'): # JPEG in JFIF or Exif format return "jpg" - elif h[:6] in (b('GIF87a'), b('GIF89a')): # GIF ('87 and '89 variants) + elif h[:6] in (b'GIF87a', b'GIF89a'): # GIF ('87 and '89 variants) return "gif" - elif h[:2] in (b('MM'), b('II'), b('BM')): # tiff or BMP + elif h[:2] in (b'MM', b'II', b'BM'): # tiff or BMP return "bmp" else: # probably not an image file return False diff --git a/core/utils.py b/core/utils.py index d3eb8e7e..caad53a6 100644 --- a/core/utils.py +++ b/core/utils.py @@ -9,10 +9,6 @@ from core import constants from core import qrc -from core.backports.six import b -from core.backports import six - -StringIO = six.moves.cStringIO from urllib.parse import urlparse as urllib_parse @@ -165,13 +161,13 @@ def is_the_string_an_image(s): # NOTE: magic numbers taken from imghdr source code # as most tiles are PNGs, check for PNG first - if s[:8] == b("\211PNG\r\n\032\n"): + if s[:8] == b"\211PNG\r\n\032\n": return True - elif s[6:10] in (b('JFIF'), b('Exif')): # JPEG in JFIF or Exif format + elif s[6:10] in (b'JFIF', b'Exif'): # JPEG in JFIF or Exif format return True - elif s[:6] in (b('GIF87a'), b('GIF89a')): # GIF ('87 and '89 variants) + elif s[:6] in (b'GIF87a', b'GIF89a'): # GIF ('87 and '89 variants) return True - elif s[:2] in (b('MM'), b('II'), b('BM')): # tiff or BMP + elif s[:2] in (b'MM', b'II', b'BM'): # tiff or BMP return True else: # probably not an image file return False diff --git a/modrana.py b/modrana.py index 9621f2ea..414806bf 100755 --- a/modrana.py +++ b/modrana.py @@ -86,7 +86,6 @@ def set_correct_CWD(): from core import threads from core import gs from core import singleton -from core.backports import six # record that imports-done timestamp importsDoneTimestamp = time.time() @@ -866,7 +865,7 @@ def _remove_non_persistent_options(self, inputDict): ASSUMPTION: keys are strings of length>=1 """ try: - return dict((k, v) for k, v in six.iteritems(inputDict) if k[0] != '#') + return dict((k, v) for k, v in inputDict.items() if k[0] != '#') except Exception: log.exception('options: error while filtering options\nsome nonpersistent keys might have been left in\nNOTE: keys should be strings of length>=1') return self.d diff --git a/modules/gui_modules/gui_qt5/gui_qt5.py b/modules/gui_modules/gui_qt5/gui_qt5.py index 6b50a057..c531ff63 100644 --- a/modules/gui_modules/gui_qt5/gui_qt5.py +++ b/modules/gui_modules/gui_qt5/gui_qt5.py @@ -864,11 +864,6 @@ def _addressSearchCB(self, results): self._addressSearchInProgress = False self._addressSignal.emit() - #addressStatus = QtCore.Property(six.text_type, - # lambda x: x._addressSearchStatus, notify=_addressSignal) - # - #addressInProgress = QtCore.Property(bool, - # lambda x: x._addressSearchInProgress, notify=_addressSignal) class ModRana(object): """ diff --git a/modules/mod_location/gps_module/misc.py b/modules/mod_location/gps_module/misc.py index 6f5e0209..51243ce1 100644 --- a/modules/mod_location/gps_module/misc.py +++ b/modules/mod_location/gps_module/misc.py @@ -4,7 +4,6 @@ # BSD terms apply: see the file COPYING in the distribution root for details. import time, calendar, math -from core.backports import six # some multipliers for interpreting GPS output METERS_TO_FEET = 3.2808399 # Meters to U.S./British feet @@ -61,7 +60,7 @@ def isotime(s): msec = s - date date = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(s)) return date + "." + repr(msec)[3:] - elif type(s) == type("") or type(s) == type(six.u("")): + elif type(s) == type("") or type(s) == type(u""): if s[-1] == "Z": s = s[:-1] if "." in s: diff --git a/modules/mod_mapLayers/mod_mapLayers.py b/modules/mod_mapLayers/mod_mapLayers.py index 0c8deeda..94d63712 100644 --- a/modules/mod_mapLayers/mod_mapLayers.py +++ b/modules/mod_mapLayers/mod_mapLayers.py @@ -21,7 +21,6 @@ from modules.base_module import RanaModule from core.signal import Signal -from core.backports import six from core.layers import MapLayer, MapLayerGroup from .overlay_groups import OverlayGroup @@ -167,7 +166,7 @@ def _parseLayers(self): # check if there is at least one valid layer layerDefinitions = self.modrana.configs.map_config.get('layers', {}) - for layerId, layerDefinition in six.iteritems(layerDefinitions): + for layerId, layerDefinition in layerDefinitions.items(): if self._hasRequiredKeys(layerDefinition, MAP_LAYER_REQUIRED_KEYS): self._layers[layerId] = MapLayer(layerId, layerDefinition) else: @@ -184,7 +183,7 @@ def _parseGroups(self): # configuration file has any if self.modrana.configs.map_config: groupsDict = self.modrana.configs.map_config.get('groups', {}) - for groupId, groupDefinition in six.iteritems(groupsDict): + for groupId, groupDefinition in groupsDict.items(): if self._hasRequiredKeys(groupDefinition, MAP_LAYER_GROUP_REQUIRED_KEYS): self._groups[groupId] = MapLayerGroup(self, groupId, groupDefinition) diff --git a/modules/mod_mapTiles/mod_mapTiles.py b/modules/mod_mapTiles/mod_mapTiles.py index 0bd6481e..0116ed19 100644 --- a/modules/mod_mapTiles/mod_mapTiles.py +++ b/modules/mod_mapTiles/mod_mapTiles.py @@ -18,22 +18,22 @@ # along with this program. If not, see . #--------------------------------------------------------------------------- from modules.base_module import RanaModule + import threading import time +from queue import Queue + import urllib3 from core import utils from core import tiles from core import constants -from core.backports import six from core.signal import Signal from core import threads from .tile_downloader import Downloader -StringIO = six.moves.cStringIO - #import socket #timeout = 30 # this sets timeout for all sockets #socket.setdefaulttimeout(timeout) @@ -109,7 +109,7 @@ def __init__(self, *args, **kwargs): self._tileDownloaded = Signal() - self._dlRequestQueue = six.moves.queue.Queue() + self._dlRequestQueue = Queue() self._downloader = None @property diff --git a/modules/mod_theme.py b/modules/mod_theme.py index 7003238b..38c893d0 100644 --- a/modules/mod_theme.py +++ b/modules/mod_theme.py @@ -21,7 +21,6 @@ from modules.base_module import RanaModule from core.signal import Signal -from core.backports import six from core import qrc from core import utils @@ -165,7 +164,7 @@ def _loadConfigFile(self, path): if 'colors' in config: colors = config['colors'] colorObjects = {} - for key, color in six.iteritems(colors): + for key, color in colors.items(): if len(color) == 2: # hex color/color name and alpha as float 0-1 colorString = color[0] colorObjects[key] = colorString diff --git a/modules/mod_tileserver.py b/modules/mod_tileserver.py index bea5859f..6b40f98b 100644 --- a/modules/mod_tileserver.py +++ b/modules/mod_tileserver.py @@ -19,19 +19,19 @@ #--------------------------------------------------------------------------- import random import sys -from threading import Thread -from core.backports import six - -# TODO replace this with something Python 3 compatible -SimpleHTTPServer = six.moves.SimpleHTTPServer -SocketServer = six.moves.socketserver +from threading import Thread +from http.server import SimpleHTTPRequestHandler +from socketserver import TCPServer from urllib.error import HTTPError from io import StringIO from modules.base_module import RanaModule from modules import tileserver_callback_proxy +import logging +server_log = logging.getLogger("mod.tileserver.server") + def getModule(*args, **kwargs): return Tileserver(*args, **kwargs) @@ -64,7 +64,7 @@ def runServer(self): # self.tileserverPort = random.randint(8000,9000) - # Handler = SimpleHTTPServer.SimpleHTTPRequestHandler + # Handler = SimpleHTTPRequestHandler try: @@ -109,17 +109,17 @@ def shutdown(self): self.stopServer() -class Server(SocketServer.TCPServer): +class Server(TCPServer): # def __init__(self, tuple, callback): # SocketServer.TCPServer.init(tuple, "") # self.callback = callback - class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): + class Proxy(SimpleHTTPRequestHandler): def __init__(self, request, client_address): try: - SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self, request, client_address, self) + SimpleHTTPRequestHandler.__init__(self, request, client_address, self) except: - SimpleHTTPServer.SimpleHTTPRequestHandler.__init__(self, request, client_address, self) + SimpleHTTPRequestHandler.__init__(self, request, client_address, self) def do_GET(self): split = self.path.split("/") @@ -127,8 +127,8 @@ def do_GET(self): z = int(split[2]) x = int(split[3]) y = int(split[4].split(".")[0]) - self.log.debug(self.path) - self.log.debug(tileserver_callback_proxy.cb._mapTiles) + server_log.debug(self.path) + server_log.debug(tileserver_callback_proxy.cb._mapTiles) try: tileData = tileserver_callback_proxy.cb._mapTiles.getTile(layer, z, x, y) if tileData: @@ -141,12 +141,12 @@ def do_GET(self): # self.send_header('Date', self.date_time_string()) self.end_headers() - self.log.debug("GET returning file") + server_log.debug("GET returning file") self.wfile.write(StringIO(tileData).read()) return True else: - self.log.debug("GET tile not found") + server_log.debug("GET tile not found") return False except HTTPError: e = sys.exc_info()[1]