Skip to content

Commit

Permalink
Merge pull request #1 from kartoza/fix-unused-codes
Browse files Browse the repository at this point in the history
remove unused default values and functions
  • Loading branch information
danangmassandy authored Jun 5, 2024
2 parents 67ba848 + 790bdba commit 910cac9
Show file tree
Hide file tree
Showing 7 changed files with 358 additions and 338 deletions.
24 changes: 12 additions & 12 deletions cplus_core/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
)
from ..models.base import ScenarioResult
from ..models.helpers import clone_activity
from ..utils.helper import align_rasters, clean_filename, tr, log, FileUtils
from ..utils.helper import align_rasters, clean_filename, tr, log, BaseFileUtils


class ScenarioAnalysisTask(QgsTask):
Expand Down Expand Up @@ -121,7 +121,7 @@ def run(self):

self.scenario_directory = self.get_scenario_directory()

FileUtils.create_new_dir(self.scenario_directory)
BaseFileUtils.create_new_dir(self.scenario_directory)

selected_pathway = None
pathway_found = False
Expand Down Expand Up @@ -510,7 +510,7 @@ def run_pathways_analysis(self, activities, extent, temporary_output=False):
self.scenario_directory, "pathways_carbon_layers"
)

FileUtils.create_new_dir(new_carbon_directory)
BaseFileUtils.create_new_dir(new_carbon_directory)

output_file = os.path.join(
new_carbon_directory, f"{file_name}_{str(uuid.uuid4())[:4]}.tif"
Expand Down Expand Up @@ -641,7 +641,7 @@ def snap_analysis_data(self, activities, extent):
self.scenario_directory, "pathways"
)

FileUtils.create_new_dir(snapped_pathways_directory)
BaseFileUtils.create_new_dir(snapped_pathways_directory)

for pathway in pathways:
pathway_layer = QgsRasterLayer(pathway.path, pathway.name)
Expand All @@ -664,7 +664,7 @@ def snap_analysis_data(self, activities, extent):
self.scenario_directory, "carbon_layers"
)

FileUtils.create_new_dir(snapped_carbon_directory)
BaseFileUtils.create_new_dir(snapped_carbon_directory)

snapped_carbon_paths = []

Expand Down Expand Up @@ -723,7 +723,7 @@ def snap_analysis_data(self, activities, extent):
self.scenario_directory, "priority_layers"
)

FileUtils.create_new_dir(snapped_priority_directory)
BaseFileUtils.create_new_dir(snapped_priority_directory)

priority_layers = []
for priority_layer in activity.priority_layers:
Expand Down Expand Up @@ -913,7 +913,7 @@ def run_pathways_normalization(self, activities, extent, temporary_output=False)
normalized_pathways_directory = os.path.join(
self.scenario_directory, "normalized_pathways"
)
FileUtils.create_new_dir(normalized_pathways_directory)
BaseFileUtils.create_new_dir(normalized_pathways_directory)
file_name = clean_filename(pathway.name.replace(" ", "_"))

output_file = os.path.join(
Expand Down Expand Up @@ -1031,7 +1031,7 @@ def run_activities_analysis(self, activities, extent, temporary_output=False):
activities_directory = os.path.join(
self.scenario_directory, "activities"
)
FileUtils.create_new_dir(activities_directory)
BaseFileUtils.create_new_dir(activities_directory)
file_name = clean_filename(activity.name.replace(" ", "_"))

layers = []
Expand Down Expand Up @@ -1209,7 +1209,7 @@ def run_activities_masking(
masked_activities_directory = os.path.join(
self.scenario_directory, "masked_activities"
)
FileUtils.create_new_dir(masked_activities_directory)
BaseFileUtils.create_new_dir(masked_activities_directory)
file_name = clean_filename(activity.name.replace(" ", "_"))

output_file = os.path.join(
Expand Down Expand Up @@ -1413,7 +1413,7 @@ def run_activities_sieve(self, models, temporary_output=False):
sieved_ims_directory = os.path.join(
self.scenario_directory, "sieved_ims"
)
FileUtils.create_new_dir(sieved_ims_directory)
BaseFileUtils.create_new_dir(sieved_ims_directory)
file_name = clean_filename(model.name.replace(" ", "_"))

output_file = os.path.join(
Expand Down Expand Up @@ -1527,7 +1527,7 @@ def run_activities_normalization(self, activities, extent, temporary_output=Fals
normalized_activities_directory = os.path.join(
self.scenario_directory, "normalized_activities"
)
FileUtils.create_new_dir(normalized_activities_directory)
BaseFileUtils.create_new_dir(normalized_activities_directory)
file_name = clean_filename(activity.name.replace(" ", "_"))

output_file = os.path.join(
Expand Down Expand Up @@ -1739,7 +1739,7 @@ def run_activities_weighting(
self.scenario_directory, "weighted_activities"
)

FileUtils.create_new_dir(weighted_activities_directory)
BaseFileUtils.create_new_dir(weighted_activities_directory)

file_name = clean_filename(activity.name.replace(" ", "_"))
output_file = os.path.join(
Expand Down
2 changes: 2 additions & 0 deletions cplus_core/definitions/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@
CPLUS_OPTIONS_KEY = "cplus_main"
LOG_OPTIONS_KEY = "cplus_log"
REPORTS_OPTIONS_KEY = "cplus_report"

NO_DATA_VALUE = -9999
130 changes: 0 additions & 130 deletions cplus_core/definitions/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,130 +15,11 @@

DEFAULT_CRS_ID = 4326

DOCUMENTATION_SITE = "https://conservationinternational.github.io/cplus-plugin"
USER_DOCUMENTATION_SITE = (
"https://conservationinternational.github.io/cplus-plugin/user/guide"
)
ABOUT_DOCUMENTATION_SITE = (
"https://conservationinternational.github.io/cplus-plugin/about/ci"
)
REPORT_DOCUMENTATION = "https://conservationinternational.github.io/cplus-plugin/user/guide/#report-generating"

OPTIONS_TITLE = "CPLUS" # Title in the QGIS settings
GENERAL_OPTIONS_TITLE = "General"
REPORT_OPTIONS_TITLE = "Reporting"
LOG_OPTIONS_TITLE = "Logs"
ICON_PATH = ":/plugins/cplus_plugin/icon.svg"
REPORT_SETTINGS_ICON_PATH = str(
os.path.normpath(
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ "/icons/report_settings.svg"
)
)
LOG_SETTINGS_ICON_PATH = str(
os.path.normpath(
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ "/icons/log_settings.svg"
)
)
ICON_PDF = (
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ "/icons/mActionSaveAsPDF.svg"
)
ICON_LAYOUT = (
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ "/icons/mActionNewLayout.svg"
)
ICON_REPORT = (
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ "/icons/mIconReport.svg"
)
ICON_HELP = (
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ "/icons/mActionHelpContents_green.svg"
)

ADD_LAYER_ICON_PATH = ":/plugins/cplus_plugin/cplus_left_arrow.svg"
REMOVE_LAYER_ICON_PATH = ":/plugins/cplus_plugin/cplus_right_arrow.svg"

SCENARIO_OUTPUT_FILE_NAME = "cplus_scenario_output"
SCENARIO_OUTPUT_LAYER_NAME = "scenario_result"

PILOT_AREA_SCENARIO_SYMBOLOGY = {
"Agroforestry": {"val": 1, "color": "#d80007"},
"Alien Plant Removal": {"val": 2, "color": "#6f6f6f"},
"Applied Nucleation": {"val": 3, "color": "#81c4ff"},
"Assisted Natural Regeneration": {"val": 4, "color": "#e8ec18"},
"Avoided Deforestation and Degradation": {"val": 5, "color": "#ff4c84"},
"Avoided Wetland Conversion/Restoration": {"val": 6, "color": "#1f31d3"},
"Bioproducts": {"val": 7, "color": "#67593f"},
"Bush Thinning": {"val": 8, "color": "#30ff01"},
"Direct Tree Seeding": {"val": 9, "color": "#bd6b70"},
"Livestock Market Access": {"val": 10, "color": "#6c0009"},
"Livestock Rangeland Management": {"val": 11, "color": "#ffa500"},
"Natural Woodland Livestock Management": {"val": 12, "color": "#007018"},
"Sustainable Crop Farming & Aquaponics": {"val": 13, "color": "#781a8b"},
}

ACTIVITY_COLOUR_RAMPS = {
"Agroforestry": "Reds",
"Alien Plant Removal": "Greys",
"Alien_Plant_Removal": "Greys",
"Applied Nucleation": "PuBu",
"Applied_Nucleation": "PuBu",
"Assisted Natural Regeneration": "YlOrRd",
"Assisted_Natural_Regeneration": "YlOrRd",
"Avoided Deforestation and Degradation": "RdPu",
"Avoided_Deforestation_and_Degradation": "RdPu",
"Avoided Wetland Conversion/Restoration": "Blues",
"Avoided_Wetland_Conversion_Restoration": "Blues",
"Bioproducts": "BrBG",
"Bush Thinning": "BuGn",
"Bush_Thinning": "BuGn",
"Direct Tree Seeding": "PuRd",
"Direct_Tree_Seeding": "PuRd",
"Livestock Market Access": "Rocket",
"Livestock_Market_Access": "Rocket",
"Livestock Rangeland Management": "YlOrBr",
"Livestock_Rangeland_Management": "YlOrBr",
"Natural Woodland Livestock Management": "Greens",
"Natural_Woodland_Livestock_Management": "Greens",
"Sustainable Crop Farming & Aquaponics": "Purples",
"Sustainable_Crop_Farming_&_Aquaponics": "Purples",
}

QGIS_GDAL_PROVIDER = "gdal"

DEFAULT_LOGO_PATH = (
os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + "/icons/ci_logo.png"
)
CPLUS_LOGO_PATH = str(
os.path.normpath(
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ "/icons/cplus_logo.svg"
)
)
CI_LOGO_PATH = str(
os.path.normpath(
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ "/icons/ci_logo.svg"
)
)

# Default template file name
TEMPLATE_NAME = "main.qpt"

# Minimum sizes (in mm) for repeat items in the template
MINIMUM_ITEM_WIDTH = 100
MINIMUM_ITEM_HEIGHT = 100

# Report font
REPORT_FONT_NAME = "Ubuntu"

# IDs for the given tables in the report template
ACTIVITY_AREA_TABLE_ID = "activity_area_table"
PRIORITY_GROUP_WEIGHT_TABLE_ID = "assigned_weights_table"

# Initiliazing the plugin default data as found in the data directory
priority_layer_path = (
Path(__file__).parent.parent.resolve()
Expand Down Expand Up @@ -219,14 +100,3 @@
"description": "Placeholder text for finance carbon",
},
]

DEFAULT_REPORT_DISCLAIMER = (
"The boundaries, names, and designations "
"used in this report do not imply official "
"endorsement or acceptance by Conservation "
"International Foundation, or its partner "
"organizations and contributors."
)
DEFAULT_REPORT_LICENSE = (
"Creative Commons Attribution 4.0 International " "License (CC BY 4.0)"
)
2 changes: 1 addition & 1 deletion cplus_core/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""Helper functions for supporting model management."""

from dataclasses import field, fields
from dataclasses import fields
import typing
import uuid

Expand Down
Loading

0 comments on commit 910cac9

Please sign in to comment.