diff --git a/LDMP/api.py b/LDMP/api.py index 1a0b276d5..bafc888cc 100644 --- a/LDMP/api.py +++ b/LDMP/api.py @@ -263,7 +263,7 @@ def login(self, authConfigId=None): except KeyError: log("API unable to login - check username and password") error_message = tr_api.tr( - "Unable to login to Trends.Earth. " "Check username and password." + "Unable to login to Trends.Earth. Check username and password." ) ret = None else: @@ -271,8 +271,7 @@ def login(self, authConfigId=None): else: log("Unable to access Trends.Earth server") error_message = tr_api.tr( - "Unable to access Trends.Earth server. Check your " - "internet connection" + "Unable to access Trends.Earth server. Check your internet connection" ) ret = None @@ -291,9 +290,7 @@ def login_test(self, email, password): return True else: if not email or not password: - log( - "API unable to login during login test - check " "username/password" - ) + log("API unable to login during login test - check username/password") QtWidgets.QMessageBox.critical( None, tr_api.tr("Error"), diff --git a/LDMP/areaofinterest.py b/LDMP/areaofinterest.py index b685c6043..4a8de96dc 100644 --- a/LDMP/areaofinterest.py +++ b/LDMP/areaofinterest.py @@ -222,10 +222,10 @@ def meridian_split(self, out_type="extent", out_format="geojson", warn=True): # original layer (or extent) if the area of the combined pieces # from both hemispheres is not significantly smaller than that of # the original polygon. - log("AOI being processed in one piece " "(does not cross 180th meridian)") + log("AOI being processed in one piece (does not cross 180th meridian)") return (False, [pieces_union_txt]) else: - log("AOI crosses 180th meridian - " "splitting AOI into two geojsons.") + log("AOI crosses 180th meridian - splitting AOI into two geojsons.") return (True, pieces_txt) def get_aligned_output_bounds(self, f): diff --git a/LDMP/calculate_drought_vulnerability.py b/LDMP/calculate_drought_vulnerability.py index 1d5c2f61c..a8a146e21 100644 --- a/LDMP/calculate_drought_vulnerability.py +++ b/LDMP/calculate_drought_vulnerability.py @@ -245,9 +245,7 @@ def validate_layer_extents(self, combo_boxes): QtWidgets.QMessageBox.critical( None, self.tr("Error"), - self.tr( - "Area of interest is not entirely within the " "drought dataset." - ), + self.tr("Area of interest is not entirely within the drought dataset."), ) return False diff --git a/LDMP/calculate_ldn.py b/LDMP/calculate_ldn.py index 98472082a..8fbc474dd 100644 --- a/LDMP/calculate_ldn.py +++ b/LDMP/calculate_ldn.py @@ -616,7 +616,7 @@ def btn_calculate(self): } ) - log(f'period is: {payload["period"]}') + log(f"period is: {payload['period']}") payloads.append(payload) @@ -1149,7 +1149,7 @@ def set_layer_filter(self): "layer_type", ld_config.SOC_DEG_BAND_NAME ) self.combo_layer_input.populate() - log(f'filter set to {self.combo_layer_input.property("layer_type")}') + log(f"filter set to {self.combo_layer_input.property('layer_type')}") def btn_calculate(self): # Note that the super class has several tests in it - if they fail it diff --git a/LDMP/conf.py b/LDMP/conf.py index 94db36ddc..29af493a6 100644 --- a/LDMP/conf.py +++ b/LDMP/conf.py @@ -304,8 +304,7 @@ def _load_algorithm_config( "id": "277f87e6-5362-4533-ab1d-c28251576884", "name": tr_conf.tr("Land cover change"), "description": tr_conf.tr( - "Land cover is the physical material at the surface of " - "the earth. " + "Land cover is the physical material at the surface of the earth. " ), "scripts": [ { @@ -323,7 +322,7 @@ def _load_algorithm_config( "name": tr_conf.tr("Soil Organic Carbon"), "description": ( tr_conf.tr( - "Soil organic carbon is a measure of soil organic " "matter" + "Soil organic carbon is a measure of soil organic matter" ) ), "scripts": [ @@ -473,7 +472,7 @@ def _load_algorithm_config( "id": "a753f2c9-be4c-4d97-9e21-09b8882e8899", "name": tr_conf.tr("Change in carbon summary table"), "description": tr_conf.tr( - "Calculate table summarizing change in " "total carbon" + "Calculate table summarizing change in total carbon" ), "scripts": [ { @@ -492,7 +491,7 @@ def _load_algorithm_config( "id": "61839d52-0d81-428d-90e6-83ea5ed3c032", "name": tr_conf.tr("Estimate potential impacts of restoration"), "description": tr_conf.tr( - "Estimate potential change in biomass due to " "restoration" + "Estimate potential change in biomass due to restoration" ), "scripts": [ { diff --git a/LDMP/data_io.py b/LDMP/data_io.py index cb76c6a34..1288db183 100644 --- a/LDMP/data_io.py +++ b/LDMP/data_io.py @@ -1067,7 +1067,7 @@ def validate_overlap(self, user_warning=True) -> bool: if user_warning: reg_name = self.region_selector.region_info.area_name self.msg_bar.pushMessage( - self.tr(f"Output file will be resized " f"to '{reg_name}' extent."), + self.tr(f"Output file will be resized to '{reg_name}' extent."), qgis.core.Qgis.MessageLevel.Warning, 8, ) diff --git a/LDMP/download.py b/LDMP/download.py index 7dc479048..b7acba759 100644 --- a/LDMP/download.py +++ b/LDMP/download.py @@ -338,11 +338,7 @@ def update_progress(self, value, total): self.progress.emit(value * 100 / total) def download_error(self, error): - log( - tr_download.tr( - f"Error while downloading file to" f" {self.outfile}, {error}" - ) - ) + log(tr_download.tr(f"Error while downloading file to {self.outfile}, {error}")) raise DownloadError( "Unable to start download of {}, {}".format(self.url, error) ) diff --git a/LDMP/jobs/manager.py b/LDMP/jobs/manager.py index ee403bbe2..3528d2644 100644 --- a/LDMP/jobs/manager.py +++ b/LDMP/jobs/manager.py @@ -1367,7 +1367,7 @@ def _delete_job_datasets(job: Job): path = os.path.split(job_manager.get_job_file_path(job))[0] shutil.rmtree(path) except OSError: - log(f"Could not remove directory {path!r}, " "skipping deletion...") + log(f"Could not remove directory {path!r}, skipping deletion...") else: log("This job has no results to be deleted, skipping...") diff --git a/LDMP/layers.py b/LDMP/layers.py index 46c158b1d..52bcd2044 100644 --- a/LDMP/layers.py +++ b/LDMP/layers.py @@ -349,10 +349,10 @@ def get_sample(f, band_number, n=1e6): ) log( "Resampling to " - f'/vsimem/resample_{Path(f).with_suffix(".tif").name}, from {f}' + f"/vsimem/resample_{Path(f).with_suffix('.tif').name}, from {f}" ) ds_resamp = gdal.Translate( - f'/vsimem/{Path(f).with_suffix(".tif").name}', + f"/vsimem/{Path(f).with_suffix('.tif').name}", f, bandList=[band_number], width=xsize_new, diff --git a/LDMP/lc_setup.py b/LDMP/lc_setup.py index 3eb8756ce..d8f53cb33 100644 --- a/LDMP/lc_setup.py +++ b/LDMP/lc_setup.py @@ -373,7 +373,7 @@ def read_lc_nesting_file(f): with open(f) as nesting_file: nesting = LCLegendNesting.Schema().loads(nesting_file.read()) except ValidationError as e: - log("Error loading land cover legend " f"nesting definition from {f}: {e}") + log(f"Error loading land cover legend nesting definition from {f}: {e}") QtWidgets.QMessageBox.critical( None, tr_lc_setup.tr("Error"), @@ -1755,8 +1755,7 @@ def sync_trans_matrix(ref_lcc_infos: list[LCClassInfo]): trans_matrix_to_settings(matrix) if conf.settings_manager.get_value(conf.Setting.DEBUG): log( - f"{LccInfoUtils.CUSTOM_LEGEND_NAME} - Saved updated matrix to " - f"settings." + f"{LccInfoUtils.CUSTOM_LEGEND_NAME} - Saved updated matrix to settings." ) @staticmethod @@ -1915,8 +1914,7 @@ def save_lc_nesting_esa(ref_lcc_infos: list[LCClassInfo]): log(f"child codes are {current_nesting.child.codes()}") log( - f"{LccInfoUtils.CUSTOM_LEGEND_NAME} - Saved ESA lc " - f"nesting to settings." + f"{LccInfoUtils.CUSTOM_LEGEND_NAME} - Saved ESA lc nesting to settings." ) @staticmethod diff --git a/LDMP/localexecution/biomassrestoration.py b/LDMP/localexecution/biomassrestoration.py index f01c5a5a1..589a6a5a2 100644 --- a/LDMP/localexecution/biomassrestoration.py +++ b/LDMP/localexecution/biomassrestoration.py @@ -75,7 +75,7 @@ def compute_biomass_restoration( ) clip_worker = worker.StartWorker( calculate.ClipWorker, - f"masking layers (part {n+1} of {len(wkts)})", + f"masking layers (part {n + 1} of {len(wkts)})", in_file, str(output_biomass_diff_tif), geojson, @@ -88,7 +88,7 @@ def compute_biomass_restoration( logger.log("Calculating summary table...") rest_summary_worker = worker.StartWorker( RestBiomassSummaryWorker, - f"calculating summary table (part {n+1} of {len(wkts)})", + f"calculating summary table (part {n + 1} of {len(wkts)})", str(output_biomass_diff_tif), ) diff --git a/LDMP/localexecution/unccd.py b/LDMP/localexecution/unccd.py index b3ae33cdb..2453d2c6e 100644 --- a/LDMP/localexecution/unccd.py +++ b/LDMP/localexecution/unccd.py @@ -172,9 +172,9 @@ def _set_error_recode(in_file, out_file, error_recode_polys): sdg_areas[recode_from] -= area sdg_areas["Improved"] += area - assert all( - value >= 0 for value in sdg_areas.values() - ), f"sdg_areas should all be greater than zero, but values are {sdg_areas}" + assert all(value >= 0 for value in sdg_areas.values()), ( + f"sdg_areas should all be greater than zero, but values are {sdg_areas}" + ) total_area_final = sum(sdg_areas.values()) assert abs(total_area_initial - total_area_final) < 0.001, ( f"total_area_initial ({total_area_initial}) differs " @@ -222,7 +222,7 @@ def compute_unccd_report( for i in range(len(params["so1_so2_all_paths"])): if params["so1_so2_all_paths"][i] == str(orig_summary_path_so1_so2): log( - f'Replacing {str(params["so1_so2_all_paths"][i])} with ' + f"Replacing {str(params['so1_so2_all_paths'][i])} with " f"{str(new_summary_path_so1_so2)}" ) params["so1_so2_all_paths"][i] = str(new_summary_path_so1_so2) diff --git a/LDMP/main_widget.py b/LDMP/main_widget.py index 596a3a39b..89175b87d 100644 --- a/LDMP/main_widget.py +++ b/LDMP/main_widget.py @@ -591,7 +591,7 @@ def setup_algorithms_tree(self): def create_error_recode(self): dlg = DlgSelectDataset(self, validate_all=True) - win_title = f'{dlg.windowTitle()} - {self.tr("False positive/negative")}' + win_title = f"{dlg.windowTitle()} - {self.tr('False positive/negative')}" dlg.setWindowTitle(win_title) if dlg.exec_() == QtWidgets.QDialog.Accepted: self.pause_scheduler() diff --git a/LDMP/reports/charts.py b/LDMP/reports/charts.py index b907da6c0..4b818ab1d 100644 --- a/LDMP/reports/charts.py +++ b/LDMP/reports/charts.py @@ -311,7 +311,7 @@ def export(self) -> typing.Tuple[bool, list]: if not file_name_base: file_name_base = self.layer_name() - output_file_path = f"{self.root_output_dir}/" f"chart-{file_name_base}.png" + output_file_path = f"{self.root_output_dir}/chart-{file_name_base}.png" labels = [] values = [] @@ -903,7 +903,7 @@ def _add_charts(self): productivity_barchart.data_items = lc_prod_info_items productivity_barchart.use_value_type = InfoValueType.PERCENT productivity_barchart.base_chart_name = ( - f"land-cover-change-by-" f"productivity-{init_year!s}" f"-{final_year!s}" + f"land-cover-change-by-productivity-{init_year!s}-{final_year!s}" ) productivity_barchart.value_axis_label = tr_reports_charts.tr("%") self._charts.append(productivity_barchart) diff --git a/LDMP/reports/generator.py b/LDMP/reports/generator.py index f07a0a602..eab46eaf5 100644 --- a/LDMP/reports/generator.py +++ b/LDMP/reports/generator.py @@ -354,7 +354,7 @@ def _restore_base_layers(self): basemap_group = root_tree.findGroup(self.BASE_MAP_GROUP) if basemap_group is None: self._append_warning_msg( - "Basemap root group not found, unable to restore basemap " "layer." + "Basemap root group not found, unable to restore basemap layer." ) return @@ -1013,8 +1013,7 @@ def process_report_task(self, ctx: ReportTaskContext) -> bool: # Assert if qgis_process path could be found if not self._qgis_proc_path: tr_msg = self.tr( - "could not be found in your system. Unable to run the " - "report generator." + "could not be found in your system. Unable to run the report generator." ) self._push_warning_message(f"'qgis_process' {tr_msg}") return False @@ -1042,7 +1041,7 @@ def process_report_task(self, ctx: ReportTaskContext) -> bool: # Notify user tr_msg = self.tr( - f"are being processed (id " f"{[str(job.id) for job in ctx.jobs]})..." + f"are being processed (id {[str(job.id) for job in ctx.jobs]})..." ) self._push_info_message(f"{ctx_display_name} {tr_msg}") @@ -1136,7 +1135,7 @@ def on_task_status_changed(self, task_id: int, status: QgsTask.TaskStatus): ctx_file = QFile(ctx_file_path) status = ctx_file.remove() if not status: - log(f"Unable to remove report context " f"file: {ctx_file_path}") + log(f"Unable to remove report context file: {ctx_file_path}") # Remove from list of submitted tasks self.remove_task_context(ctx) diff --git a/LDMP/settings.py b/LDMP/settings.py index f18a6f008..8b5103731 100644 --- a/LDMP/settings.py +++ b/LDMP/settings.py @@ -115,8 +115,7 @@ def _get_user_email(auth_setup, warn=True): None, tr_settings.tr("Error"), tr_settings.tr( - "Please setup access to {auth_setup.name} before " - "using this function." + "Please setup access to {auth_setup.name} before using this function." ), ) return None @@ -1744,7 +1743,7 @@ def on_save_file(self): lcc_infos = self.class_infos() status = LccInfoUtils.save_file(lcc_save_path, lcc_infos) if not status: - log(f"Unable to save land cover " f"classes to '{lcc_save_path}'") + log(f"Unable to save land cover classes to '{lcc_save_path}'") return fi = QtCore.QFileInfo(lcc_save_path) diff --git a/LDMP/timeseries.py b/LDMP/timeseries.py index 8f3c704ac..1a1fed2ec 100644 --- a/LDMP/timeseries.py +++ b/LDMP/timeseries.py @@ -250,8 +250,7 @@ def get_plot_title(self): ) else: return ( - f"{self.traj_indic.currentText()} " - f"- {self.dataset_ndvi.currentText()}" + f"{self.traj_indic.currentText()} - {self.dataset_ndvi.currentText()}" ) def btn_calculate(self): diff --git a/LDMP/utils.py b/LDMP/utils.py index 8f1b7d1cf..96397db62 100644 --- a/LDMP/utils.py +++ b/LDMP/utils.py @@ -205,7 +205,7 @@ def qgis_process_path() -> str: # Check execution permissions if not os.access(proc_script_path, os.X_OK): - log(f"User does not have execute permission " f"for '{proc_script_path}'.") + log(f"User does not have execute permission for '{proc_script_path}'.") return "" return proc_script_path diff --git a/LDMP/visualization.py b/LDMP/visualization.py index 3d68c1c68..848186a71 100644 --- a/LDMP/visualization.py +++ b/LDMP/visualization.py @@ -246,7 +246,7 @@ def country_data_path() -> str: """ Returns the path for the vector file containing country data. """ - return f"{FileUtils.plugin_dir()}/data/" f"ne_10m_admin_0_countries.shp" + return f"{FileUtils.plugin_dir()}/data/ne_10m_admin_0_countries.shp" def sub_national_data_path() -> str: @@ -254,7 +254,7 @@ def sub_national_data_path() -> str: Returns the path for the vector file containing sub-national data. """ root_dir = FileUtils.plugin_dir() - return f"{root_dir}/data/" f"ne_10m_admin_1_states_provinces.shp" + return f"{root_dir}/data/ne_10m_admin_1_states_provinces.shp" def places_data_path() -> str: @@ -262,7 +262,7 @@ def places_data_path() -> str: Returns the path for the vector file containing data on populated places. """ root_dir = FileUtils.plugin_dir() - return f"{root_dir}/data/" f"ne_10m_populated_places.shp" + return f"{root_dir}/data/ne_10m_populated_places.shp" class ExtractAdministrativeArea: diff --git a/gee/sdg-15-3-1-sub-indicators/src/main.py b/gee/sdg-15-3-1-sub-indicators/src/main.py index 8fe412d52..79bf71a08 100644 --- a/gee/sdg-15-3-1-sub-indicators/src/main.py +++ b/gee/sdg-15-3-1-sub-indicators/src/main.py @@ -318,11 +318,11 @@ def run_period(params, max_workers, EXECUTION_ID, logger): def _gen_metadata_str_te(params): metadata = { "visible_metadata": { - "one liner": f'{params["script"]["name"]} ({params["period"]["name"]}, {params["period"]["year_initial"]}-{params["period"]["year_final"]})', - "full": f'{params["script"]["name"]}\n' - f'Period: {params["period"]["name"]} ({params["period"]["year_initial"]}-{params["period"]["year_final"]})' - f'Productivity {params["productivity"]["mode"]}:\n' - f'\tTrajectory ({params["productivity"]["traj_year_initial"]} {params["productivity"]["traj_year_final"]}', + "one liner": f"{params['script']['name']} ({params['period']['name']}, {params['period']['year_initial']}-{params['period']['year_final']})", + "full": f"{params['script']['name']}\n" + f"Period: {params['period']['name']} ({params['period']['year_initial']}-{params['period']['year_final']})" + f"Productivity {params['productivity']['mode']}:\n" + f"\tTrajectory ({params['productivity']['traj_year_initial']} {params['productivity']['traj_year_final']}", } } @@ -332,10 +332,10 @@ def _gen_metadata_str_te(params): def _gen_metadata_str_precalculated_lpd(params): metadata = { "visible_metadata": { - "one liner": f'{params["script"]["name"]} ({params["period"]["name"]}, {params["period"]["year_initial"]}-{params["period"]["year_final"]})', - "full": f'{params["script"]["name"]}\n' - f'Period: {params["period"]["name"]} ({params["period"]["year_initial"]}-{params["period"]["year_final"]})' - f'Productivity {params["productivity"]["mode"]}: {params["productivity"]["year_initial"]}-{params["productivity"]["year_final"]}', + "one liner": f"{params['script']['name']} ({params['period']['name']}, {params['period']['year_initial']}-{params['period']['year_final']})", + "full": f"{params['script']['name']}\n" + f"Period: {params['period']['name']} ({params['period']['year_initial']}-{params['period']['year_final']})" + f"Productivity {params['productivity']['mode']}: {params['productivity']['year_initial']}-{params['productivity']['year_final']}", } } diff --git a/tasks.py b/tasks.py index 6d901799e..73ee74052 100644 --- a/tasks.py +++ b/tasks.py @@ -51,7 +51,7 @@ def query_yes_no(question, default="yes"): elif choice in valid: return valid[choice] else: - sys.stdout.write("Please respond with 'yes' or 'no' " "(or 'y' or 'n').\n") + sys.stdout.write("Please respond with 'yes' or 'no' (or 'y' or 'n').\n") def get_version(c): @@ -315,9 +315,7 @@ def release_github(c): @task( - help={ - "modules": "Also set tag for any modules specified " "in ext_libs.local_modules" - } + help={"modules": "Also set tag for any modules specified in ext_libs.local_modules"} ) def set_tag(c, modules=False): v = get_version(c) @@ -1360,16 +1358,16 @@ def _make_download_link(c, title, key, data): def _make_sdg_download_row(c, iso, data): return ( f"| {iso} | " - + f'{_make_download_link(c, f"{iso} (JRC LPD)", "JRC-LPD-5", data)} | ' - + f'{_make_download_link(c, f"{iso} (Trends.Earth LPD)", "TrendsEarth-LPD-5", data)} | ' - + f'{_make_download_link(c, f"{iso} (FAO-WOCAT LPD)", "FAO-WOCAT-LPD-5", data)} |\n' + + f"{_make_download_link(c, f'{iso} (JRC LPD)', 'JRC-LPD-5', data)} | " + + f"{_make_download_link(c, f'{iso} (Trends.Earth LPD)', 'TrendsEarth-LPD-5', data)} | " + + f"{_make_download_link(c, f'{iso} (FAO-WOCAT LPD)', 'FAO-WOCAT-LPD-5', data)} |\n" ) def _make_drought_download_row(c, iso, data): return ( f"| {iso} | " - + f'{_make_download_link(c, f"{iso} (Drought)", "Drought", data)} |\n' + + f"{_make_download_link(c, f'{iso} (Drought)', 'Drought', data)} |\n" ) diff --git a/test/test_qgis_environment.py b/test/test_qgis_environment.py index fa886e0ab..bcb0a7612 100644 --- a/test/test_qgis_environment.py +++ b/test/test_qgis_environment.py @@ -11,7 +11,7 @@ __author__ = "tim@kartoza.com" __date__ = "20/01/2011" -__copyright__ = "Copyright 2012, Australia Indonesia Facility for " "Disaster Reduction" +__copyright__ = "Copyright 2012, Australia Indonesia Facility for Disaster Reduction" import os import unittest