Skip to content

Commit

Permalink
Format fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
azvoleff committed Jul 30, 2024
1 parent 0e7cc46 commit 0caf33c
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 87 deletions.
10 changes: 2 additions & 8 deletions LDMP/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
"""

import io
import sys
import typing

from future import standard_library

Expand All @@ -25,9 +23,7 @@
import requests
import backoff

from dateutil import tz
from qgis.core import (
QgsApplication,
QgsTask,
QgsNetworkAccessManager,
QgsApplication,
Expand All @@ -36,8 +32,6 @@
)
from qgis.PyQt import QtCore, QtWidgets, QtNetwork

from qgis.utils import iface
from qgis.gui import QgsAuthConfigSelect

from . import auth, conf
from .logger import log
Expand Down Expand Up @@ -106,7 +100,7 @@ def run(self):
# dictionaries that contain nested values of OrderedDict.
try:
doc = QtCore.QJsonDocument(self.payload)
except TypeError as te:
except TypeError:
request_data = bytes(json.dumps(self.payload), encoding="utf-8")

request_data = (
Expand Down Expand Up @@ -191,7 +185,7 @@ def finished(self, result):
)
except requests.exceptions.Timeout:
self.error_message = tr_api.tr(
f"Unable to connect to Trends.Earth server."
"Unable to connect to Trends.Earth server."
)

if self.resp is not None:
Expand Down
1 change: 0 additions & 1 deletion LDMP/areaofinterest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import functools
import json
import traceback
import typing
from pathlib import Path

Expand Down
2 changes: 0 additions & 2 deletions LDMP/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import typing
import uuid
from pathlib import Path
from typing import Optional

import qgis.core
import qgis.gui
Expand All @@ -39,7 +38,6 @@
from .conf import REMOTE_DATASETS
from .conf import Setting
from .conf import settings_manager
from .logger import log


DlgCalculateUi, _ = uic.loadUiType(str(Path(__file__).parent / "gui/DlgCalculate.ui"))
Expand Down
6 changes: 1 addition & 5 deletions LDMP/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
from functools import partial
from pathlib import Path

import requests
from qgis.core import QgsApplication
from qgis.core import QgsFileDownloader
from qgis.core import QgsNetworkReplyContent
from qgis.core import QgsSettings
from qgis.core import QgsTask
from qgis.PyQt import QtCore
from qgis.PyQt import QtNetwork
from qgis.PyQt import QtWidgets
Expand Down Expand Up @@ -392,7 +388,7 @@ def start(self):
tr_download.tr("Error"),
tr_download.tr("Download failed. Check your internet connection."),
)
except Exception as err:
except Exception:
QtWidgets.QMessageBox.critical(
None,
tr_download.tr("Error"),
Expand Down
2 changes: 1 addition & 1 deletion LDMP/download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(
max_x = item.get("Max Longitude", None)
min_y = item.get("Min Latitude", None)
max_y = item.get("Max Latitude", None)
if not None in (min_x, max_x, min_y, max_y):
if None not in (min_x, max_x, min_y, max_y):
extent_lat = "{} - {}".format(min_y, max_y)
extent_lon = "{} - {}".format(min_x, max_x)
item.update({"extent_lat": extent_lat, "extent_lon": extent_lon})
Expand Down
5 changes: 2 additions & 3 deletions LDMP/jobs/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import datetime as dt
import json
import logging
Expand Down Expand Up @@ -799,7 +798,7 @@ def create_error_recode(self, task_name, lc, soil, prod, sdg):
status=jobs.JobStatus.DOWNLOADED,
local_context=_get_local_context(),
results=VectorResults(
name=f"False positive/negative",
name="False positive/negative",
type=ResultType.VECTOR_RESULTS,
vector=VectorFalsePositive(
uri=None,
Expand Down Expand Up @@ -1166,7 +1165,7 @@ def _get_local_jobs(self, status: jobs.JobStatus) -> typing.List[Job]:
raw_job = json.load(fh)
job = Job.Schema().load(raw_job)
set_results_extents(job)
except (KeyError, json.decoder.JSONDecodeError) as exc:
except (KeyError, json.decoder.JSONDecodeError):
if conf.settings_manager.get_value(conf.Setting.DEBUG):
log(
f"Unable to decode file {job_metadata_path!r} as valid json"
Expand Down
1 change: 0 additions & 1 deletion LDMP/jobs/mvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from ..conf import settings_manager
from ..data_io import DlgDataIOAddLayersToMap
from ..datasets_dialog import DatasetDetailsDialogue
from ..logger import log
from ..plot import DlgPlotTimeries
from ..reports.mvc import DatasetReportHandler
from ..select_dataset import DlgSelectDataset
Expand Down
4 changes: 2 additions & 2 deletions LDMP/landpks.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(
max_x = item.get("Max Longitude", None)
min_y = item.get("Min Latitude", None)
max_y = item.get("Max Latitude", None)
if not None in (min_x, max_x, min_y, max_y):
if None not in (min_x, max_x, min_y, max_y):
extent_lat = "{} - {}".format(min_y, max_y)
extent_lon = "{} - {}".format(min_x, max_x)
item.update({"extent_lat": extent_lat, "extent_lon": extent_lon})
Expand Down Expand Up @@ -241,7 +241,7 @@ def btn_calculate(self):
log(f"ret: {ret}")
if not ret:
return
log(f"continuing...")
log("continuing...")

rows = list({index.row() for index in self.data_view.selectedIndexes()})
# Construct unique dataset names as the concatenation of the category
Expand Down
4 changes: 2 additions & 2 deletions LDMP/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ def add_layer(
),
)
log(
'No style found for "{}" in {}'.format(
'No style found for "{}" (band {} in {})'.format(
band_info["name"], band_number, layer_path
)
)
Expand Down Expand Up @@ -836,7 +836,7 @@ def add_vector_layer(layer_path: str, name: str) -> "QgsVectorLayer":


def set_default_stats_value(v_path, band_datas):
log(f"setting default stats value function")
log("setting default stats value function")
layer = None
for l in QgsProject.instance().mapLayers().values():
if l.source().split("|")[0] == v_path:
Expand Down
2 changes: 1 addition & 1 deletion LDMP/lc_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def _get_default_matrix():
os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"data",
f"land_cover_transition_matrix_unccd.json",
"land_cover_transition_matrix_unccd.json",
)
)

Expand Down
1 change: 0 additions & 1 deletion LDMP/maptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from qgis.core import QgsRectangle
from qgis.core import QgsUnitTypes
from qgis.core import QgsVectorLayerUtils
from qgis.core import QgsWkbTypes
from qgis.gui import QgsDoubleSpinBox
from qgis.gui import QgsMapCanvas
from qgis.gui import QgsMapMouseEvent
Expand Down
1 change: 0 additions & 1 deletion LDMP/region_selector.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from dataclasses import dataclass

from qgis.core import QgsGeometry
from qgis.core import QgsRectangle
from qgis.PyQt import QtCore
from qgis.PyQt import QtWidgets
from qgis.utils import iface
Expand Down
2 changes: 1 addition & 1 deletion LDMP/reports/mvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def update_report_status(self) -> bool:
def check_job_report_status(self) -> bool:
# Check job status, assert datasets are available and no report has
# been generated yet.
if not self._job.status in (JobStatus.DOWNLOADED, JobStatus.GENERATED_LOCALLY):
if self._job.status not in (JobStatus.DOWNLOADED, JobStatus.GENERATED_LOCALLY):
return False

if not job_has_results(self._job):
Expand Down
7 changes: 3 additions & 4 deletions LDMP/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
email : [email protected]
***************************************************************************/
"""

import os
import typing
import zipfile
Expand All @@ -29,7 +30,6 @@
from qgis.utils import iface
from te_schemas.land_cover import LCClass

from . import __version__
from . import api
from . import auth
from . import binaries_available
Expand Down Expand Up @@ -1325,8 +1325,7 @@ def binaries_download(self):
None,
self.tr("Error"),
self.tr(
"Unable to write to {}. Try a "
"different folder.".format(out_folder)
"Unable to write to {}. Try a different folder.".format(out_folder)
),
)

Expand Down Expand Up @@ -1385,7 +1384,7 @@ def binaries_download(self):
QtWidgets.QMessageBox.critical(
None,
self.tr("Success"),
self.tr("All binaries up to date.".format(out_folder)),
self.tr("All binaries up to date."),
)

def binaries_toggle(self):
Expand Down
22 changes: 10 additions & 12 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def set_tag(c, modules=False):
)
ret.check_returncode()
else:
print("Changes not committed - VERSION TAG NOT SET".format(v))
print("Changes not committed - VERSION TAG NOT SET")

print("Tagging version {} and pushing tag to origin".format(v))
ret = subprocess.run(
Expand Down Expand Up @@ -429,7 +429,7 @@ def tecli_publish(c, script=None, overwrite=False):
script_dir = os.path.join(c.gee.script_dir, dir)

if os.path.exists(os.path.join(script_dir, "configuration.json")) and (
script == None or script == dir
script is None or script == dir
):
print("Publishing {}...".format(dir))
subprocess.check_call(
Expand Down Expand Up @@ -516,7 +516,6 @@ def update_script_ids(c):
scripts = json.load(fin)

dirs = next(os.walk(c.gee.script_dir))[1]
n = 0
script_dir = None

for dir in dirs:
Expand Down Expand Up @@ -568,7 +567,7 @@ def tecli_info(c, script=None):
script_dir = os.path.join(c.gee.script_dir, dir)

if os.path.exists(os.path.join(script_dir, "configuration.json")) and (
script == None or script == dir
script is None or script == dir
):
print("Checking info on {}...".format(dir))
subprocess.check_call(
Expand Down Expand Up @@ -701,16 +700,16 @@ def plugin_setup(c, clean=True, link=False, pip="pip"):

if link:
for module in c.plugin.ext_libs.local_modules:
l = os.path.abspath(c.plugin.ext_libs.path) + os.path.sep + module["name"]
ln = os.path.abspath(c.plugin.ext_libs.path) + os.path.sep + module["name"]

if os.path.islink(l):
print(f"{l} is already a link (to {os.readlink(l)})")
if os.path.islink(ln):
print(f"{ln} is already a link (to {os.readlink(ln)})")
else:
print(
"Linking local repo of {} to plugin ext_libs".format(module["name"])
)
shutil.rmtree(l)
os.symlink(module["path"], l)
shutil.rmtree(ln)
os.symlink(module["path"], ln)


@task(
Expand Down Expand Up @@ -1663,7 +1662,7 @@ def _s3_sync(c, bucket, s3_prefix, local_folder, patterns=["*"]):
if os.path.isdir(f):
continue

if not os.path.basename(f) in s3_object_names:
if os.path.basename(f) not in s3_object_names:
print("S3 is missing {} - copying to S3.".format(f))
data = open(f, "rb")
client.put_object(
Expand All @@ -1687,7 +1686,6 @@ def _check_hash(expected, filename):
def binaries_sync(c, extensions=None):
if not extensions:
extensions = c.plugin.numba.binary_extensions
client = _get_s3_client()
patterns = [os.path.join(c.plugin.numba.binary_folder, "*" + p) for p in extensions]
_s3_sync(
c,
Expand Down Expand Up @@ -1750,7 +1748,7 @@ def binaries_deploy(c, qgis):
# binaries installed in the same folder
moduledir = os.path.join(tmpdir, zipfile_basename, "trends_earth_binaries")
os.makedirs(moduledir)
with open(os.path.join(moduledir, "__init__.py"), "w") as fp:
with open(os.path.join(moduledir, "__init__.py"), "w"):
pass
# Copy binaries to temp folder for later zipping

Expand Down
Loading

0 comments on commit 0caf33c

Please sign in to comment.