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 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
from numpy.typing import NDArray
@@ -354,3 +354,5 @@ State = TypedDict('State',
'step_index' : int
})
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 facefusion.types import Wording
WORDING : Dict[str, Any] =\
{
'conda_not_activated': 'Conda is not activated',
@@ -341,13 +343,13 @@ WORDING : Dict[str, Any] =\
}
def get(key: str) -> Optional[str]:
current = WORDING
def get(notation : str) -> Optional[Wording]:
wording = WORDING
for fragment in key.split('.'):
if fragment in current:
current = current.get(fragment)
for fragment in notation.split('.'):
if fragment in wording:
wording = wording.get(fragment)
else:
return None
return current
return wording