diff --git a/gui/wxpython/core/gcmd.py b/gui/wxpython/core/gcmd.py index 0c64f0d0973..70c3e806121 100644 --- a/gui/wxpython/core/gcmd.py +++ b/gui/wxpython/core/gcmd.py @@ -25,17 +25,17 @@ @author Martin Landa """ +import errno +import locale import os +import signal +import subprocess import sys import time -import errno -import signal import traceback -import locale -import subprocess from threading import Thread -import wx +import wx from core.debug import Debug from core.globalvar import SCT_EXT @@ -43,13 +43,15 @@ from grass.script.utils import decode, encode is_mswindows = sys.platform == "win32" + if is_mswindows: + import msvcrt + from win32file import ReadFile, WriteFile from win32pipe import PeekNamedPipe - import msvcrt else: - import select import fcntl + import select def DecodeString(string): diff --git a/gui/wxpython/core/watchdog.py b/gui/wxpython/core/watchdog.py index 76302aeea0a..be147736bcb 100644 --- a/gui/wxpython/core/watchdog.py +++ b/gui/wxpython/core/watchdog.py @@ -19,7 +19,6 @@ import os import time - from pathlib import Path import wx @@ -29,11 +28,8 @@ watchdog_used = True try: + from watchdog.events import FileSystemEventHandler, PatternMatchingEventHandler from watchdog.observers import Observer - from watchdog.events import ( - PatternMatchingEventHandler, - FileSystemEventHandler, - ) except ImportError: watchdog_used = False PatternMatchingEventHandler = object diff --git a/gui/wxpython/gmodeler/frame.py b/gui/wxpython/gmodeler/frame.py index 5ad7b6c34e0..359de2d7ef8 100644 --- a/gui/wxpython/gmodeler/frame.py +++ b/gui/wxpython/gmodeler/frame.py @@ -18,12 +18,10 @@ import os import wx - from core import globalvar -from gui_core.menu import Menu as Menubar - from gmodeler.menudata import ModelerMenuData from gmodeler.panels import ModelerPanel +from gui_core.menu import Menu as Menubar class ModelerFrame(wx.Frame): diff --git a/gui/wxpython/startup/locdownload.py b/gui/wxpython/startup/locdownload.py index 7e24724d862..66ff4e4a2a9 100644 --- a/gui/wxpython/startup/locdownload.py +++ b/gui/wxpython/startup/locdownload.py @@ -17,20 +17,12 @@ """ import os -import sys import shutil +import sys import textwrap import time import wx -from wx.lib.newevent import NewEvent - -from grass.script.utils import try_rmdir, legalize_vector_name -from grass.utils.download import download_and_extract, name_from_url, DownloadError -from grass.grassdb.checks import is_location_valid -from grass.script.setup import set_gui_path - -set_gui_path() # flake8: noqa: E402 from core.debug import Debug @@ -38,7 +30,14 @@ from gui_core.wrap import Button, StaticText # flakes8: qa +from wx.lib.newevent import NewEvent + +from grass.grassdb.checks import is_location_valid +from grass.script.setup import set_gui_path +from grass.script.utils import legalize_vector_name, try_rmdir +from grass.utils.download import DownloadError, download_and_extract, name_from_url +set_gui_path() # TODO: labels (and descriptions) translatable? LOCATIONS = [ diff --git a/gui/wxpython/web_services/widgets.py b/gui/wxpython/web_services/widgets.py index db057313831..1cb325cce5b 100644 --- a/gui/wxpython/web_services/widgets.py +++ b/gui/wxpython/web_services/widgets.py @@ -16,39 +16,20 @@ @author Stepan Turek """ -import re import os -import sys +import re import shutil - +import sys from copy import deepcopy -from core import globalvar - from xml.etree.ElementTree import ParseError import wx - -if globalvar.wxPythonPhoenix: - try: - import agw.flatnotebook as FN - except ImportError: # if it's not there locally, try the wxPython lib. - import wx.lib.agw.flatnotebook as FN -else: - import wx.lib.flatnotebook as FN import wx.lib.colourselect as csel - +from core import globalvar from core.debug import Debug from core.gcmd import GMessage -from core.gconsole import CmdThread, GStderr, EVT_CMD_DONE, EVT_CMD_OUTPUT - -from web_services.cap_interface import ( - WMSCapabilities, - WMTSCapabilities, - OnEarthCapabilities, -) - -from gui_core.widgets import GNotebook -from gui_core.widgets import ManageSettingsWidget +from core.gconsole import EVT_CMD_DONE, EVT_CMD_OUTPUT, CmdThread, GStderr +from gui_core.widgets import GNotebook, ManageSettingsWidget from gui_core.wrap import ( Button, ScrolledPanel, @@ -58,6 +39,11 @@ TextCtrl, TreeCtrl, ) +from web_services.cap_interface import ( + OnEarthCapabilities, + WMSCapabilities, + WMTSCapabilities, +) import grass.script as gs from grass.pydispatch.signal import Signal @@ -66,8 +52,8 @@ if rinwms_path not in sys.path: sys.path.append(rinwms_path) -from wms_base import WMSDriversInfo # noqa:E402 from srs import Srs # noqa:E402 +from wms_base import WMSDriversInfo # noqa:E402 class WSPanel(wx.Panel): diff --git a/python/grass/docs/conf.py b/python/grass/docs/conf.py index 2d6a564cac0..bf85d82ce3e 100644 --- a/python/grass/docs/conf.py +++ b/python/grass/docs/conf.py @@ -10,10 +10,10 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os -from datetime import date import string +import sys +from datetime import date from shutil import copy # If extensions (or modules to document with autodoc) are in another directory, diff --git a/python/grass/pygrass/raster/__init__.py b/python/grass/pygrass/raster/__init__.py index b00e832b8ea..1ac81011c72 100644 --- a/python/grass/pygrass/raster/__init__.py +++ b/python/grass/pygrass/raster/__init__.py @@ -6,7 +6,6 @@ # from grass.script import fatal from grass.exceptions import OpenError - import grass.lib.gis as libgis import grass.lib.raster as libraster import grass.lib.rowio as librowio diff --git a/python/grass/pygrass/vector/__init__.py b/python/grass/pygrass/vector/__init__.py index b36fae9fa4f..0307998077c 100644 --- a/python/grass/pygrass/vector/__init__.py +++ b/python/grass/pygrass/vector/__init__.py @@ -1,23 +1,20 @@ -from os.path import join, exists -import grass.lib.gis as libgis import ctypes +from os.path import exists, join +import grass.lib.gis as libgis # flake8: noqa: E402 libgis.G_gisinit("") import grass.lib.vector as libvect -from grass.pygrass.vector.vector_type import VTYPE from grass.pygrass.errors import GrassError, must_be_open from grass.pygrass.gis import Location -from grass.pygrass.vector.geometry import ( - GEOOBJ as _GEOOBJ, - read_line, - read_next_line, - Area as _Area, -) from grass.pygrass.vector.abstract import Info from grass.pygrass.vector.basic import Bbox, Cats, Ilist +from grass.pygrass.vector.geometry import GEOOBJ as _GEOOBJ +from grass.pygrass.vector.geometry import Area as _Area +from grass.pygrass.vector.geometry import read_line, read_next_line +from grass.pygrass.vector.vector_type import VTYPE # flake8: qa @@ -972,6 +969,7 @@ def areas_to_wkb_list(self, bbox=None, field=1): if __name__ == "__main__": import doctest + from grass.pygrass import utils utils.create_test_vector_map(test_vector_name) diff --git a/scripts/r.in.wms/wms_drv.py b/scripts/r.in.wms/wms_drv.py index e46eace4b72..7f0c8558528 100644 --- a/scripts/r.in.wms/wms_drv.py +++ b/scripts/r.in.wms/wms_drv.py @@ -18,7 +18,16 @@ """ import socket +from http.client import HTTPException +from math import floor, pi from time import sleep +from urllib.error import HTTPError +from xml.etree.ElementTree import ParseError + +import numpy as np +from srs import Srs +from wms_base import GetEpsg, GetSRSParamVal, WMSBase +from wms_cap_parsers import OnEarthCapabilitiesTree, WMTSCapabilitiesTree import grass.script as gs @@ -32,17 +41,6 @@ ) ) -from http.client import HTTPException -from math import floor, pi -from urllib.error import HTTPError -from xml.etree.ElementTree import ParseError - -import numpy as np - -from srs import Srs -from wms_base import GetEpsg, GetSRSParamVal, WMSBase -from wms_cap_parsers import OnEarthCapabilitiesTree, WMTSCapabilitiesTree - class WMSDrv(WMSBase): def _download(self):