Skip to content

Commit

Permalink
workaround for flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi committed Aug 8, 2023
1 parent 80e5712 commit c90d631
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def __init__(self, blocks, blocks_layout):

if not blocks:
return None
fakeObj = FakeObject(
blocks.get("blocks", ""), blocks.get("blocks_layout", "")
)
fakeObj = FakeObject(blocks.get("blocks", ""), blocks.get("blocks_layout", ""))
return SearchableText_blocks(fakeObj)()


Expand All @@ -50,9 +48,7 @@ def is_anonymous(self):

def get_canale_accesso_info(self, servizio):
canale_fisico = getattr(servizio, "canale_fisico", None)
canale_digitale = text_in_block(
getattr(servizio, "canale_digitale", None)
)
canale_digitale = text_in_block(getattr(servizio, "canale_digitale", None))
canale_digitale_link = getattr(servizio, "canale_digitale_link", None)
if canale_digitale and canale_digitale_link and canale_fisico:
return "D e F"
Expand All @@ -68,12 +64,8 @@ def information_dict(self, servizio):
return {
"title": getattr(servizio, "title"),
"description": getattr(servizio, "description", None),
"condizioni_di_servizio": getattr(
servizio, "condizioni_di_servizio", None
),
"tassonomia_argomenti": getattr(
servizio, "tassonomia_argomenti", None
),
"condizioni_di_servizio": getattr(servizio, "condizioni_di_servizio", None),
"tassonomia_argomenti": getattr(servizio, "tassonomia_argomenti", None),
"a_chi_si_rivolge": text_in_block(
getattr(servizio, "a_chi_si_rivolge", None)
),
Expand All @@ -86,9 +78,7 @@ def information_dict(self, servizio):
"tempi_e_scadenze": text_in_block(
getattr(servizio, "tempi_e_scadenze", None)
),
"ufficio_responsabile": getattr(
servizio, "ufficio_responsabile", None
),
"ufficio_responsabile": getattr(servizio, "ufficio_responsabile", None),
"contact_info": getattr(servizio, "contact_info", None),
}

Expand Down Expand Up @@ -158,29 +148,16 @@ def get_servizi(self):
)
and FLAG
or "",
"a_chi_si_rivolge": information_dict.get(
"a_chi_si_rivolge"
)
"a_chi_si_rivolge": information_dict.get("a_chi_si_rivolge")
and FLAG
or "",
"come_si_fa": information_dict.get("come_si_fa")
"come_si_fa": information_dict.get("come_si_fa") and FLAG or "",
"cosa_si_ottiene": information_dict.get("cosa_si_ottiene")
and FLAG
or "",
"cosa_si_ottiene": information_dict.get(
"cosa_si_ottiene"
)
and FLAG
or "",
"canale_accesso": information_dict.get(
"canale_accesso"
)
or "",
"cosa_serve": information_dict.get("cosa_serve")
and FLAG
or "",
"tempi_e_scadenze": information_dict.get(
"tempi_e_scadenze"
)
"canale_accesso": information_dict.get("canale_accesso") or "",
"cosa_serve": information_dict.get("cosa_serve") and FLAG or "",
"tempi_e_scadenze": information_dict.get("tempi_e_scadenze")
and FLAG
or "",
"ufficio_responsabile": information_dict.get(
Expand Down Expand Up @@ -248,9 +225,7 @@ def __call__(self):
]
if cds:
condizioni_di_servizio = (
servizio["data"]["condizioni_di_servizio"]
and "V"
or ""
servizio["data"]["condizioni_di_servizio"] and "V" or ""
)
dati_servizio.insert(2, condizioni_di_servizio)
data.append(dati_servizio)
Expand Down
4 changes: 2 additions & 2 deletions src/design/plone/contenttypes/upgrades/to_7001.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def migrated_contact_info(source):
# finally we check if we have at least a value.
if (
safe_hasattr(source, "contact_info")
and type(obj.contact_info) == list
and type(obj.contact_info) == list # noqa
and len(obj.contact_info) > 0
):
return True
Expand Down Expand Up @@ -271,7 +271,7 @@ def migrated_contact_info(source):
field_value = getattr(obj, field, None)
if not field_value:
continue
if type(field_value) != list:
if type(field_value) != list: # noqa
# in some case we have a f*****g list
field_value = [
field_value,
Expand Down
14 changes: 4 additions & 10 deletions src/design/plone/contenttypes/upgrades/to_7002.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
TAXONOMIES_MAPPING = {}
for portal_type in TYPE_TO_TAXONOMIES_MAPPING:
for TAXONOMY in TYPE_TO_TAXONOMIES_MAPPING[portal_type]:
TAXONOMIES_MAPPING[TAXONOMY] = TYPE_TO_TAXONOMIES_MAPPING[portal_type][
TAXONOMY
]
TAXONOMIES_MAPPING[TAXONOMY] = TYPE_TO_TAXONOMIES_MAPPING[portal_type][TAXONOMY]


def update_taxonomies(context):
Expand All @@ -72,7 +70,7 @@ def update_taxonomies(context):
obj_language
]
old_value = getattr(aq_base(obj), taxonomy, None)
if type(old_value) == list:
if type(old_value) == list: # noqa
# this is a sort of race condition.
# we already have created ct Documento for attonomina
# in case we are using atto di nomina, skip
Expand Down Expand Up @@ -117,9 +115,7 @@ def update_taxonomies_on_blocks(context):
if blocks:
for block in blocks.values():
if block.get("@type", "") == "listing":
for query in block.get("querystring", {}).get(
"query", []
):
for query in block.get("querystring", {}).get("query", []):
if query["i"] in [
"tipologia_notizia",
"tipologia_documento",
Expand All @@ -130,9 +126,7 @@ def update_taxonomies_on_blocks(context):
old_value = query["v"]
if (
v
in TAXONOMIES_MAPPING[query["i"]][
item_language
]
in TAXONOMIES_MAPPING[query["i"]][item_language]
):
v = TAXONOMIES_MAPPING[query["i"]][
item_language
Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/contenttypes/upgrades/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ def update_uo_contact_info(context):
)
for brain in brains:
obj = brain.getObject()
if type(obj.contact_info) == dict:
if type(obj.contact_info) == dict: # noqa
del obj.contact_info
logger.info(
f"{colors.GREEN} Modifica della UO senza punto di contatto {colors.ENDC}" # noqa
Expand Down

0 comments on commit c90d631

Please sign in to comment.