Skip to content

Commit

Permalink
Removing assignments that used to have .lower()
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Nov 8, 2024
1 parent 24c0e8f commit a6c7fe8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
12 changes: 4 additions & 8 deletions src/scribe_data/cli/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,15 @@ def convert_to_json(
-------
None
"""
normalized_language = language

if not normalized_language:
if not language:
raise ValueError(f"Language '{language.capitalize()}' is not recognized.")

data_types = [data_type] if isinstance(data_type, str) else data_type

if output_dir is None:
output_dir = DEFAULT_JSON_EXPORT_DIR

json_output_dir = Path(output_dir) / normalized_language.capitalize()
json_output_dir = Path(output_dir) / language.capitalize()
json_output_dir.mkdir(parents=True, exist_ok=True)

for dtype in data_types:
Expand Down Expand Up @@ -159,7 +157,7 @@ def convert_to_json(
f"File '{output_file}' already exists. Overwrite? (y/n): "
)
if user_input.lower() != "y":
print(f"Skipping {normalized_language['language']} - {dtype}")
print(f"Skipping {language['language']} - {dtype}")
continue

try:
Expand Down Expand Up @@ -211,9 +209,7 @@ def convert_to_csv_or_tsv(
-------
None
"""
normalized_language = language

if not normalized_language:
if not language:
raise ValueError(f"Language '{language.capitalize()}' is not recognized.")

if isinstance(data_type, str):
Expand Down
9 changes: 4 additions & 5 deletions src/scribe_data/cli/total.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ def get_qid_by_input(input_str):
The QID corresponding to the input string, or- None if not found.
"""
if input_str:
input_str_lower = input_str
if input_str_lower in language_to_qid:
return language_to_qid[input_str_lower]
if input_str in language_to_qid:
return language_to_qid[input_str]

elif input_str_lower in data_type_metadata:
return data_type_metadata[input_str_lower]
elif input_str in data_type_metadata:
return data_type_metadata[input_str]

return None

Expand Down
6 changes: 2 additions & 4 deletions src/scribe_data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@

# Process each language and its potential sub-languages in one pass.
for lang, lang_data in language_metadata.items():
lang_lower = lang

if "sub_languages" in lang_data:
for sub_lang, sub_lang_data in lang_data["sub_languages"].items():
sub_lang_lower = sub_lang
Expand All @@ -98,8 +96,8 @@
print(f"Warning: 'qid' missing for language {lang.capitalize()}")

else:
language_map[lang_lower] = lang_data
language_to_qid[lang_lower] = qid
language_map[lang] = lang_data
language_to_qid[lang] = qid


def _load_json(package_path: str, file_name: str) -> Any:
Expand Down

0 comments on commit a6c7fe8

Please sign in to comment.