mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
rename 'DefaultValueDict' to 'DefaultKeysDict'
This commit is contained in:
parent
4fca5bcde5
commit
f35521a943
2 changed files with 9 additions and 7 deletions
|
|
@ -73,6 +73,7 @@ from .log import (
|
|||
)
|
||||
|
||||
from .path_templates import (
|
||||
DefaultKeysDict,
|
||||
TemplateUnsolved,
|
||||
StringTemplate,
|
||||
FormatObject,
|
||||
|
|
@ -228,6 +229,7 @@ __all__ = [
|
|||
"get_version_from_path",
|
||||
"get_last_version_from_path",
|
||||
|
||||
"DefaultKeysDict",
|
||||
"TemplateUnsolved",
|
||||
"StringTemplate",
|
||||
"FormatObject",
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ class TemplateUnsolved(Exception):
|
|||
)
|
||||
|
||||
|
||||
class DefaultValueDict(dict):
|
||||
class DefaultKeysDict(dict):
|
||||
"""Dictionary that supports the default key to use for str conversion.
|
||||
|
||||
Is helpful for changes of a key in a template from string to dictionary
|
||||
for example '{folder}' -> '{folder[name]}'.
|
||||
>>> data = DefaultValueDict(
|
||||
>>> data = DefaultKeysDict(
|
||||
>>> "name",
|
||||
>>> {"folder": {"name": "FolderName"}}
|
||||
>>> )
|
||||
|
|
@ -80,17 +80,17 @@ class DefaultValueDict(dict):
|
|||
def __str__(self) -> str:
|
||||
return str(self.get_default_value())
|
||||
|
||||
def __copy__(self) -> "DefaultValueDict":
|
||||
return DefaultValueDict(
|
||||
def __copy__(self) -> "DefaultKeysDict":
|
||||
return DefaultKeysDict(
|
||||
self.get_default_keys(), dict(self.items())
|
||||
)
|
||||
|
||||
def __deepcopy__(self) -> "DefaultValueDict":
|
||||
def __deepcopy__(self) -> "DefaultKeysDict":
|
||||
data_copy = {
|
||||
key: copy.deepcopy(value)
|
||||
for key, value in self.items()
|
||||
}
|
||||
return DefaultValueDict(self.get_default_keys(), data_copy)
|
||||
return DefaultKeysDict(self.get_default_keys(), data_copy)
|
||||
|
||||
def get_default_keys(self) -> list[str]:
|
||||
return list(self._default_keys)
|
||||
|
|
@ -696,7 +696,7 @@ class FormattingPart:
|
|||
result.add_output(self.template)
|
||||
return result
|
||||
|
||||
if isinstance(value, DefaultValueDict):
|
||||
if isinstance(value, DefaultKeysDict):
|
||||
try:
|
||||
value = value.get_default_value()
|
||||
except KeyError:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue