Allow deep nested wording
This commit is contained in:
@@ -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]]
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user