Skip to content

Commit

Permalink
Manual flake8 issues fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Jun 11, 2024
1 parent 0cdc1ec commit 8f5ad00
Show file tree
Hide file tree
Showing 72 changed files with 206 additions and 298 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
ignore = C901, W504
extend-ignore = C901, E203, E701
max-line-length = 130
exclude = .git,__pycache__,old,build,dist,*migrations*,*snapshots*
max-complexity = 10
36 changes: 18 additions & 18 deletions api/management/commands/add_action_tooltips.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,76 +14,76 @@ def handle(self, *args, **options):
tts = [
[
"National Society readiness",
"Includes adapting community preparedness, response and DRR measures in view of the pandemic safety measures, especially when they are dealing with compounding disasters. Also includes adjusting contingency plans, updating Risk assessments identifying the different services that will be provided during the current disaster and how do these services fit into the National contingency plans.",
"Includes adapting community preparedness, response and DRR measures in view of the pandemic safety measures, especially when they are dealing with compounding disasters. Also includes adjusting contingency plans, updating Risk assessments identifying the different services that will be provided during the current disaster and how do these services fit into the National contingency plans.", # noqa: E501
],
[
"National Society sustainability",
"Includes identifying Core organizational budget to maintain the minimum structure of a National Society, available unrestricted reserves and unrestricted income and developing and executing business continuity plans.",
"Includes identifying Core organizational budget to maintain the minimum structure of a National Society, available unrestricted reserves and unrestricted income and developing and executing business continuity plans.", # noqa: E501
],
[
"Support to volunteers",
"Includes providing insurance for volunteers as well as access to PPE for volunteers to safely fulfil their duties.",
"Includes providing insurance for volunteers as well as access to PPE for volunteers to safely fulfil their duties.", # nqa: E501 # noqa: E501
],
[
"Epidemic control measures",
"Includes testing, contact tracing and support for quarantine of contacts and isolation of COVID-19 cases not requiring clinical treatment.",
"Includes testing, contact tracing and support for quarantine of contacts and isolation of COVID-19 cases not requiring clinical treatment.", # noqa: E501
],
[
"Risk communication, community engagement, and health and hygiene promotion",
"Includes approaches such as community-based activities, mass media (local radios, TV, press), social media outreach or face-to-face and interpersonal communication (door to door, community dialogues, community meetings) to promote hygiene and other risk reduction interventions.",
"Includes approaches such as community-based activities, mass media (local radios, TV, press), social media outreach or face-to-face and interpersonal communication (door to door, community dialogues, community meetings) to promote hygiene and other risk reduction interventions.", # noqa: E501
],
[
"Community-based surveillance (CBS) for COVID-19",
"Includes staff and volunteers who have completed a training and who are actively reporting health risks through the RC/RC approach to CBS. It does not include point-of-entry screenings, call centers, active surveillance or contact tracing.",
"Includes staff and volunteers who have completed a training and who are actively reporting health risks through the RC/RC approach to CBS. It does not include point-of-entry screenings, call centers, active surveillance or contact tracing.", # noqa: E501
],
[
"Infection prevention and control (IPC) and WASH (health facilities)",
"Includes any form of infection prevention and control (IPC) support provided to health facilities. Support may include donation of personal protective equipment or medical supplies, or other medical, logistics, or coordination support, support for triage of COVID-19 cases, installation of WASH infrastructure to facilitate IPC best practices, and IPC training.",
"Includes any form of infection prevention and control (IPC) support provided to health facilities. Support may include donation of personal protective equipment or medical supplies, or other medical, logistics, or coordination support, support for triage of COVID-19 cases, installation of WASH infrastructure to facilitate IPC best practices, and IPC training.", # noqa: E501
],
[
"Infection prevention and control (IPC) and WASH (community)",
"Includes community WASH activities such as establishing or rehabilitating a drinking water source, toilet, and/or a handwashing facility.",
"Includes community WASH activities such as establishing or rehabilitating a drinking water source, toilet, and/or a handwashing facility.", # noqa: E501
],
[
"Mental health and psychosocial support services (MHPSS)",
"Includes direct mental health and psychosocial support services to community members provided through National Society volunteers or staff.",
"Includes direct mental health and psychosocial support services to community members provided through National Society volunteers or staff.", # noqa: E501
],
[
"Isolation and clinical case management for COVID-19 cases",
"Includes support to health facilities that are actively treating COVID-19 cases or providing observational support and care to COVID-19 cases in isolation. Support can range from donations to staff and volunteer support.",
"Includes support to health facilities that are actively treating COVID-19 cases or providing observational support and care to COVID-19 cases in isolation. Support can range from donations to staff and volunteer support.", # noqa: E501
],
[
"Ambulance services for COVID-19 cases",
"Includes suspected or confirmed COVID-19 patients who have received ambulance transport services by the National Society.",
"Includes suspected or confirmed COVID-19 patients who have received ambulance transport services by the National Society.", # noqa: E501
],
[
"Maintain access to essential health services (community health)",
"Includes supporting essential community health services that have been impacted/reduced as a result of COVID-19, such as community-based malaria interventions, NCD support, and immunization campaigns to counteract the reduction in community health services and/or increased need for community health services resulting from COVID-19.",
"Includes supporting essential community health services that have been impacted/reduced as a result of COVID-19, such as community-based malaria interventions, NCD support, and immunization campaigns to counteract the reduction in community health services and/or increased need for community health services resulting from COVID-19.", # noqa: E501
],
[
"Maintain access to essential health services (clinical and paramedical)",
"Includes supporting health facilities supported to maintain routine essential services such as MCH, NCD, malaria treatment, and other essential services. Support can be through either physical or technical support of volunteers or staff, or support through PPE or medical supplies donation.",
"Includes supporting health facilities supported to maintain routine essential services such as MCH, NCD, malaria treatment, and other essential services. Support can be through either physical or technical support of volunteers or staff, or support through PPE or medical supplies donation.", # noqa: E501
],
[
"Management of the dead",
"Includes direct burial or cremation of human remains of COVID-19 cases, and supervision of safe burial or cremation in the community.",
"Includes direct burial or cremation of human remains of COVID-19 cases, and supervision of safe burial or cremation in the community.", # noqa: E501
],
["Support COVID-19 Vaccination", "Includes activities such as service delivery, campaigns, or distribution."],
[
"Community engagement and accountability (CEA), including community feedback mechanisms",
"Includes systems and approaches to collect community feedback which could mean recorded /tracked suggestions, comments, complaints, concerns, perceptions, praise, question collected through feedback systems and/or through community perception surveys.",
"Includes systems and approaches to collect community feedback which could mean recorded /tracked suggestions, comments, complaints, concerns, perceptions, praise, question collected through feedback systems and/or through community perception surveys.", # noqa: E501
],
[
"Livelihoods, cash support & food aid",
"Includes immediate food assistance or measures to protect households’ livelihoods by provisioning for lost sources of income to meet their basic needs and avoid further assets depletion. This can include all types of cash assistance to address basic needs. Also, activities for skills development such as entrepreneurship, marketing and coaching.",
"Includes immediate food assistance or measures to protect households’ livelihoods by provisioning for lost sources of income to meet their basic needs and avoid further assets depletion. This can include all types of cash assistance to address basic needs. Also, activities for skills development such as entrepreneurship, marketing and coaching.", # noqa: E501
],
[
"Social care and cohesion, and support to vulnerable groups",
"Includes analysis of the specific needs of marginalized groups in the needs assessment, and/or following the PGI minimum standards and/or using equivalent guide on assessing and meeting the needs of marginalized groups.",
"Includes analysis of the specific needs of marginalized groups in the needs assessment, and/or following the PGI minimum standards and/or using equivalent guide on assessing and meeting the needs of marginalized groups.", # noqa: E501
],
[
"Shelter and urban settlements",
"Includes for example, household items to improve shelter conditions (clothing, bed linen, mattress, blanket, etc.), emergency shelter (tents or tool kits), accommodation in collective facilities (camps, collective centers or quarantine facilities), cash and voucher assistance to cover payment of accommodation (rent or loans), utilities and other related cost directly related with the accommodation.",
"Includes for example, household items to improve shelter conditions (clothing, bed linen, mattress, blanket, etc.), emergency shelter (tents or tool kits), accommodation in collective facilities (camps, collective centers or quarantine facilities), cash and voucher assistance to cover payment of accommodation (rent or loans), utilities and other related cost directly related with the accommodation.", # noqa: E501
],
]

Expand Down
4 changes: 2 additions & 2 deletions api/management/commands/generate-admin2-shp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class Command(BaseCommand):
help = "Converting Shapefiles from different sources to custom file for go-api. To run, python manage.py generate-admin2-shp input.shp output.shp --source=fews"
help = "Converting Shapefiles from different sources to custom file for go-api. To run, python manage.py generate-admin2-shp input.shp output.shp --source=fews" # noqa: E501

missing_args_message = "Filename is missing. A shapefile with valid admin polygons is required."

Expand All @@ -18,7 +18,7 @@ def handle(self, *args, **options):
output_filename = options["filename"][1]
try:
gdf = gpd.read_file(input_filename)
except:
except Exception:
raise CommandError("Could not open file")
if options["source"] == "fews":
gdf.rename(columns={"shapeName": "name"}, inplace=True)
Expand Down
12 changes: 4 additions & 8 deletions api/management/commands/import-admin0-data.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import csv
import json
import os
import sys

from django.contrib.gis.gdal import DataSource
from django.contrib.gis.geos import GEOSGeometry, MultiPolygon, Point
from django.contrib.gis.utils import LayerMapping
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
Expand All @@ -14,7 +10,7 @@


class Command(BaseCommand):
help = "import a shapefile of adminstrative boundary level 0 data to the GO database. To run, python manage.py import-admin0-data input.shp"
help = "import a shapefile of adminstrative boundary level 0 data to the GO database. To run, python manage.py import-admin0-data input.shp" # noqa: E501

missing_args_message = "Filename is missing. A shapefile with valid admin polygons is required."
region_enum = {"Africa": 0, "Americas": 1, "Asia-Pacific": 2, "Europe": 3, "Middle East and North Africa": 4}
Expand All @@ -25,11 +21,11 @@ def add_arguments(self, parser):
parser.add_argument(
"--update-bbox",
action="store_true",
help="Update the bbox of the country geometry. Used if you want to overwrite changes that are made by users via the Django Admin",
help="Update the bbox of the country geometry. Used if you want to overwrite changes that are made by users via the Django Admin", # noqa: E501
)
parser.add_argument(
"--update-centroid",
help="Update the centroid of the country using a CSV file provided. If the CSV does not have the country iso, then we use the geometric centroid",
help="Update the centroid of the country using a CSV file provided. If the CSV does not have the country iso, then we use the geometric centroid", # noqa: E501
)
parser.add_argument("--import-missing", help="Import missing countries for iso codes mentioned in this file.")
parser.add_argument("--update-iso3", help="Import missing iso3 codes from this file.")
Expand Down Expand Up @@ -73,7 +69,7 @@ def handle(self, *args, **options):

try:
data = DataSource(filename)
except:
except Exception:
raise CommandError("Could not open file")

fields = data[0].fields
Expand Down
15 changes: 5 additions & 10 deletions api/management/commands/import-admin1-data.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import csv
import os
import sys

from django.contrib.gis.gdal import DataSource
from django.contrib.gis.geos import GEOSGeometry, MultiPolygon
from django.contrib.gis.utils import LayerMapping
from django.core.exceptions import ObjectDoesNotExist
from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
Expand All @@ -13,7 +10,7 @@


class Command(BaseCommand):
help = "import a shapefile of administrative boundary level 1 data to the GO database. To run, python manage.py import-admin1-data input.shp"
help = "import a shapefile of administrative boundary level 1 data to the GO database. To run, python manage.py import-admin1-data input.shp" # noqa: E501

missing_args_message = "Filename is missing. A shapefile with valid admin polygons is required."

Expand All @@ -23,12 +20,12 @@ def add_arguments(self, parser):
parser.add_argument(
"--update-bbox",
action="store_true",
help="Update the bbox of the district geometry. Used if you want to overwrite changes that are made by users via the Django Admin",
help="Update the bbox of the district geometry. Used if you want to overwrite changes that are made by users via the Django Admin", # noqa: E501
)
parser.add_argument(
"--update-centroid",
action="store_true",
help="Update the centroid of the district geometry. Used if you want to overwrite changes that are made by users via the Django Admin",
help="Update the centroid of the district geometry. Used if you want to overwrite changes that are made by users via the Django Admin", # noqa: E501
)
parser.add_argument("--import-missing", help="Import missing districts for codes mentioned in this file.")
parser.add_argument("--import-all", action="store_true", help="Import all districts in the shapefile, if possible.")
Expand All @@ -55,15 +52,13 @@ def handle(self, *args, **options):

try:
data = DataSource(filename)
except:
except Exception:
raise CommandError("Could not open file")

# loop through each feature in the shapefile
for feature in data[0]:
code = feature.get("ADMIN01COD")
name = feature.get("ADMIN01NAM")
country_iso2 = feature.get("ISO2")
country_name = feature.get("COUNTRY")

geom_wkt = feature.geom.wkt
geom = GEOSGeometry(geom_wkt, srid=4326)
Expand Down Expand Up @@ -91,7 +86,7 @@ def handle(self, *args, **options):
# if there are more than one district with the same code, filter also using name
if len(districts) > 1:
district = District.objects.filter(code=code, name__icontains=name)
# if we get a match, update geometry. otherwise consider this as missing because it's possible the names aren't matching.
# if we get a match, update geometry. otherwise consider this as missing because it's possible the names aren't matching. # noqa: E501
if len(district):
# update geom, centroid and bbox
d = district[0]
Expand Down
Loading

0 comments on commit 8f5ad00

Please sign in to comment.