Skip to content
Snippets Groups Projects

Feature/comp 114 python code quality

Merged Remco Tukker requested to merge feature/COMP-114_python_code_quality into develop
4 files
+ 32
0
Compare changes
  • Side-by-side
  • Inline
Files
4
"""
survey_publisher_2022
=========================
This module loads the survey data from 2022 from the survey database.
Registered as click cli command when installing compendium-v2.
"""
import logging
import click
import enum
@@ -136,15 +144,11 @@ def transfer_budget():
try:
budget = float(_budget.replace('"', '').replace(',', ''))
except ValueError:
logger.info(
f'{nren_name} has no budget for 2022. Skipping.'
f' ({_budget}))')
logger.info(f'{nren_name} has no budget for 2022. Skipping. ({_budget}))')
continue
if budget > 200:
logger.info(
f'{nren_name} has budget set to >200M EUR for 2022.'
f' ({budget})')
logger.info(f'{nren_name} has budget set to >200M EUR for 2022. ({budget})')
if nren_name not in nren_dict:
logger.info(f'{nren_name} unknown. Skipping.')
@@ -172,9 +176,7 @@ def transfer_funding_sources():
value = float(_value.replace('"', '').replace(',', ''))
except ValueError:
name = source.name
logger.info(
f'{nren_name} has invalid value for {name}.'
+ f' ({_value}))')
logger.info(f'{nren_name} has invalid value for {name}. ({_value}))')
value = 0
nren_info = sourcedata.setdefault(
@@ -196,8 +198,7 @@ def transfer_funding_sources():
funding_source = model.FundingSource(
nren=nren_dict[nren_name],
year=2022,
client_institutions=nren_info[
FundingSource.CLIENT_INSTITUTIONS],
client_institutions=nren_info[FundingSource.CLIENT_INSTITUTIONS],
european_funding=nren_info[FundingSource.EUROPEAN_FUNDING],
gov_public_bodies=nren_info[FundingSource.GOV_PUBLIC_BODIES],
commercial=nren_info[FundingSource.COMMERCIAL],
@@ -241,11 +242,8 @@ def transfer_staff_data():
employed = nren_info[StaffQuestion.PERMANENT_FTE] + nren_info[StaffQuestion.SUBCONTRACTED_FTE]
technical = nren_info[StaffQuestion.TECHNICAL_FTE] + nren_info[StaffQuestion.NON_TECHNICAL_FTE]
if not math.isclose(
employed,
technical,
abs_tol=0.01,
):
if not math.isclose(employed, technical, abs_tol=0.01):
logger.info(f'{nren_name} FTE do not equal across employed/technical categories.'
f' ({employed} != {technical})')
@@ -354,15 +352,15 @@ def transfer_charging_structure():
continue
if "do not charge" in value:
charging_structure = FeeType.no_charge.value
charging_structure = FeeType.no_charge
elif "combination" in value:
charging_structure = FeeType.combination.value
charging_structure = FeeType.combination
elif "flat" in value:
charging_structure = FeeType.flat_fee.value
charging_structure = FeeType.flat_fee
elif "usage-based" in value:
charging_structure = FeeType.usage_based_fee.value
charging_structure = FeeType.usage_based_fee
elif "Other" in value:
charging_structure = FeeType.other.value
charging_structure = FeeType.other
else:
charging_structure = None
Loading