mirror of https://github.com/eyhc1/rendercv.git
data_models: allow list assignment in `set_or_update_a_value`
This commit is contained in:
parent
f2eea31b35
commit
74d5120cdb
|
@ -1133,7 +1133,7 @@ class RenderCVDataModel(RenderCVBaseModel):
|
||||||
def set_or_update_a_value(
|
def set_or_update_a_value(
|
||||||
data_model: pydantic.BaseModel | dict | list,
|
data_model: pydantic.BaseModel | dict | list,
|
||||||
key: str,
|
key: str,
|
||||||
value: Any,
|
value: str,
|
||||||
sub_model: pydantic.BaseModel | dict | list = None,
|
sub_model: pydantic.BaseModel | dict | list = None,
|
||||||
):
|
):
|
||||||
"""Set or update a value in a data model for a specific key. For example, a key can
|
"""Set or update a value in a data model for a specific key. For example, a key can
|
||||||
|
@ -1162,7 +1162,10 @@ def set_or_update_a_value(
|
||||||
if len(keys) == 1:
|
if len(keys) == 1:
|
||||||
# set the value:
|
# set the value:
|
||||||
if value.startswith("{") and value.endswith("}"):
|
if value.startswith("{") and value.endswith("}"):
|
||||||
# allow users to assign dictionaries directly in the input file:
|
# allow users to assign dictionaries:
|
||||||
|
value = eval(value)
|
||||||
|
elif value.startswith("[") and value.endswith("]"):
|
||||||
|
# allow users to assign lists:
|
||||||
value = eval(value)
|
value = eval(value)
|
||||||
|
|
||||||
if isinstance(model, pydantic.BaseModel):
|
if isinstance(model, pydantic.BaseModel):
|
||||||
|
|
Loading…
Reference in New Issue