Skip to content

Commit

Permalink
Re-hoise for loop and add spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis authored and Ekikereabasi-Nk committed Oct 19, 2024
1 parent c4ce985 commit c7d0f7a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/scribe_data/cli/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,24 @@
# Process each language and its potential sub-languages in one pass.
for lang, lang_data in language_metadata.items():
lang_lower = lang.lower()

if "sub_languages" in lang_data:
for sub_lang, sub_lang_data in lang_data["sub_languages"].items():
sub_lang_lower = sub_lang.lower()
sub_qid = sub_lang_data.get("qid")

if sub_qid is None:
print(f"Warning: 'qid' missing for sub-language {sub_lang} of {lang}")

else:
language_map[sub_lang_lower] = sub_lang_data
language_to_qid[sub_lang_lower] = sub_qid

else:
qid = lang_data.get("qid")
if qid is None:
print(f"Warning: 'qid' missing for language {lang}")

else:
language_map[lang_lower] = lang_data
language_to_qid[lang_lower] = qid
Expand Down Expand Up @@ -145,13 +148,7 @@ def print_formatted_data(data: Union[dict, list], data_type: str) -> None:
for item in value:
if isinstance(item, dict):
for sub_key, sub_value in item.items():
print(f" {sub_key:<{max_key_length}} : {sub_value}")
elif isinstance(value, list):
print(f"{key:<{max_key_length}} : ")
for item in value:
if isinstance(item, dict):
for sub_key, sub_value in item.items():
print(f" {sub_key:<{max_sub_key_length}} : {sub_value}")
print(f" {sub_key:<{max_sub_key_length}} : {sub_value}")

else:
print(f" {item}")
Expand Down

0 comments on commit c7d0f7a

Please sign in to comment.