Fix get_value - 1
This commit is contained in:
parent
eb347a3b71
commit
938ebcc6f2
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
{% import "_macros.jinja2" as macros %}
|
||||
|
||||
{% set min_sdk_version = macros.get_value(cookiecutter.pyproject.tool, "flet.android.min_sdk_version") %}
|
||||
{% set min_sdk_version = macros.get_value(cookiecutter.pyproject, "tool.flet.android.min_sdk_version") %}
|
||||
min_sdk_version: {{ min_sdk_version }}
|
||||
|
|
@ -3,22 +3,14 @@
|
|||
{% macro get_value(dict, path) %}
|
||||
{# Split the path into keys #}
|
||||
{% set keys = path.split('.') %}
|
||||
|
||||
{# Initialize the result with the input dictionary #}
|
||||
{% set result = dict %}
|
||||
|
||||
{# Use a flag to detect when to stop processing #}
|
||||
{% set valid = true %}
|
||||
|
||||
{# Iterate through the keys and traverse the dictionary #}
|
||||
{% for key in keys %}
|
||||
{% if valid and result is mapping and key in result %}
|
||||
{% set result = result[key] %}
|
||||
{% if keys and dict is mapping and keys[0] in dict %}
|
||||
{% set next_value = dict[keys[0]] %}
|
||||
{% if keys | length == 1 %}
|
||||
{{ next_value }}
|
||||
{% else %}
|
||||
{% set result = none %}
|
||||
{% set valid = false %}
|
||||
{{ get_value(next_value, keys[1:] | join('.')) }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ none }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{{ result }}
|
||||
{% endmacro %}
|
||||
Loading…
Reference in New Issue