Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make empty field checks pythonic #778

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions workbench_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def create(self, config, field_definitions, entity, row, field_name):
dictionary
A dictionary represeting the entity that is POSTed to Drupal as JSON.
"""
if row[field_name] is None:
if not row[field_name]:
return entity

if field_name in config["field_text_format_ids"]:
Expand Down Expand Up @@ -124,7 +124,7 @@ def update(
entity[field_name] = []
return entity

if row[field_name] is None:
if not row[field_name]:
return entity

if field_name in config["field_text_format_ids"]:
Expand Down Expand Up @@ -336,7 +336,7 @@ def create(self, config, field_definitions, entity, row, field_name):
dictionary
A dictionary represeting the entity that is POSTed to Drupal as JSON.
"""
if row[field_name] is None:
if not row[field_name]:
return entity

id_field = row.get(config.get("id_field", "not_applicable"), "not_applicable")
Expand Down Expand Up @@ -386,7 +386,7 @@ def update(
entity[field_name] = []
return entity

if row[field_name] is None:
if not row[field_name]:
return entity

if config["task"] == "update_terms":
Expand Down Expand Up @@ -530,7 +530,7 @@ def create(self, config, field_definitions, entity, row, field_name):
dictionary
A dictionary represeting the entity that is POSTed to Drupal as JSON.
"""
if row[field_name] is None:
if not row[field_name]:
return entity

id_field = row.get(config.get("id_field", "not_applicable"), "not_applicable")
Expand Down Expand Up @@ -581,7 +581,7 @@ def update(
entity[field_name] = []
return entity

if row[field_name] is None:
if not row[field_name]:
return entity

if config["task"] == "update_terms":
Expand Down Expand Up @@ -731,7 +731,7 @@ def create(self, config, field_definitions, entity, row, field_name):
dictionary
A dictionary represeting the entity that is POSTed to Drupal as JSON.
"""
if row[field_name] is None:
if not row[field_name]:
return entity

id_field = row.get(config.get("id_field", "not_applicable"), "not_applicable")
Expand Down Expand Up @@ -802,7 +802,7 @@ def update(
entity[field_name] = []
return entity

if row[field_name] is None:
if not row[field_name]:
return entity

if config["task"] == "update_terms":
Expand Down Expand Up @@ -984,7 +984,7 @@ def create(self, config, field_definitions, entity, row, field_name):
dictionary
A dictionary represeting the entity that is POSTed to Drupal as JSON.
"""
if row[field_name] is None:
if not row[field_name]:
return entity

id_field = row.get(config.get("id_field", "not_applicable"), "not_applicable")
Expand Down Expand Up @@ -1041,7 +1041,7 @@ def update(
entity[field_name] = []
return entity

if row[field_name] is None:
if not row[field_name]:
return entity

if config["task"] == "update_terms":
Expand Down Expand Up @@ -1208,7 +1208,7 @@ def create(self, config, field_definitions, entity, row, field_name):
dictionary
A dictionary represeting the entity that is POSTed to Drupal as JSON.
"""
if row[field_name] is None:
if not row[field_name]:
return entity

id_field = row.get(config.get("id_field", "not_applicable"), "not_applicable")
Expand Down Expand Up @@ -1254,7 +1254,7 @@ def update(
entity[field_name] = []
return entity

if row[field_name] is None:
if not row[field_name]:
return entity

if config["task"] == "update_terms":
Expand Down Expand Up @@ -1411,7 +1411,7 @@ def create(self, config, field_definitions, entity, row, field_name):
dictionary
A dictionary represeting the entity that is POSTed to Drupal as JSON.
"""
if row[field_name] is None:
if not row[field_name]:
return entity

id_field = row.get(config.get("id_field", "not_applicable"), "not_applicable")
Expand Down Expand Up @@ -1460,7 +1460,7 @@ def update(
entity[field_name] = []
return entity

if row[field_name] is None:
if not row[field_name]:
return entity

cardinality = int(field_definitions[field_name].get("cardinality", -1))
Expand Down Expand Up @@ -1616,7 +1616,7 @@ def create(self, config, field_definitions, entity, row, field_name):
dictionary
A dictionary represeting the entity that is POSTed to Drupal as JSON.
"""
if row[field_name] is None:
if not row[field_name]:
logging.warning(f'Did not find "{field_name}" in row.')
return entity
id_field = row.get(config.get("id_field", "not_applicable"), "not_applicable")
Expand Down Expand Up @@ -1855,7 +1855,7 @@ def update(
entity[field_name] = []
return entity

if row[field_name] is None:
if not row[field_name]:
return entity

if config["update_mode"] == "replace":
Expand Down