Allow deep nested wording

This commit is contained in:
henryruhs
2025-04-19 19:37:04 +02:00
parent ff645b9069
commit b6156f6073
2 changed files with 11 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
from collections import namedtuple from collections import namedtuple
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, TypeAlias, TypedDict from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, TypeAlias, TypedDict, Union
import numpy import numpy
from numpy.typing import NDArray from numpy.typing import NDArray
@@ -354,3 +354,5 @@ State = TypedDict('State',
'step_index' : int 'step_index' : int
}) })
StateSet : TypeAlias = Dict[AppContext, State] StateSet : TypeAlias = Dict[AppContext, State]
Wording : TypeAlias = Union[str, Dict[str, str]]

View File

@@ -1,5 +1,7 @@
from typing import Any, Dict, Optional from typing import Any, Dict, Optional
from facefusion.types import Wording
WORDING : Dict[str, Any] =\ WORDING : Dict[str, Any] =\
{ {
'conda_not_activated': 'Conda is not activated', 'conda_not_activated': 'Conda is not activated',
@@ -341,13 +343,13 @@ WORDING : Dict[str, Any] =\
} }
def get(key: str) -> Optional[str]: def get(notation : str) -> Optional[Wording]:
current = WORDING wording = WORDING
for fragment in key.split('.'): for fragment in notation.split('.'):
if fragment in current: if fragment in wording:
current = current.get(fragment) wording = wording.get(fragment)
else: else:
return None return None
return current return wording