Skip to content

Commit

Permalink
Merge branch 'wip/dev-3544-lists-compliance-checks' of https://github…
Browse files Browse the repository at this point in the history
….com/dasch-swiss/dsp-tools into wip/dev-3544-lists-compliance-checks
  • Loading branch information
Nora-Olivia-Ammann committed Apr 26, 2024
2 parents 9511542 + 90a5750 commit 2646acd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/dsp_tools/commands/excel2json/new_lists.py
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import Any
from typing import cast

import pandas as pd
import regex
Expand Down Expand Up @@ -67,9 +68,10 @@ def _make_one_list(df: pd.DataFrame, sheet_name: str) -> ListRoot | ListSheetPro
)
match (root, node_problems):
case (ListRoot(), list(ListNodeProblem())):
return ListSheetProblem(sheet_name, root_problems={}, nodes=node_problems)
return ListSheetProblem(sheet_name, root_problems={}, node_problems=node_problems)
case (ListSheetProblem(), _):
root.nodes = node_problems
root = cast(ListSheetProblem, root)
root.node_problems = node_problems
return root


Expand Down Expand Up @@ -154,7 +156,7 @@ def _get_all_languages_for_columns(columns: pd.Index[str], ending: str) -> set[s
return set(res for x in columns if (res := _get_lang_string_from_column_names(x, ending)))


def _get_preferred_language(columns: pd.Index[str], ending: str) -> str:
def _get_preferred_language(columns: pd.Index[str], ending: str = r"(\d+|list)") -> str:
match = [res.group(1) for x in columns if (res := regex.search(rf"^(en|de|fr|it|rm)_{ending}+$", x))]
if "en" in match:
return "en"
Expand Down

0 comments on commit 2646acd

Please sign in to comment.