Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options: fix yaml export corner case "6_2" #3529

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1426,14 +1426,18 @@ def dictify_range(option: Range):

return data, notes

def yaml_dump_scalar(scalar) -> str:
# yaml dump may add end of document marker and newlines.
return yaml.dump(scalar).replace("...\n", "").strip()

for game_name, world in AutoWorldRegister.world_types.items():
if not world.hidden or generate_hidden:
grouped_options = get_option_groups(world)
option_groups = get_option_groups(world)
with open(local_path("data", "options.yaml")) as f:
file_data = f.read()
res = Template(file_data).render(
option_groups=grouped_options,
__version__=__version__, game=game_name, yaml_dump=yaml.dump,
option_groups=option_groups,
__version__=__version__, game=game_name, yaml_dump=yaml_dump_scalar,
dictify_range=dictify_range,
)

Expand Down
8 changes: 4 additions & 4 deletions data/options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ requires:

{%- elif option.options -%}
{%- for suboption_option_id, sub_option_name in option.name_lookup.items() %}
{{ sub_option_name }}: {% if suboption_option_id == option.default %}50{% else %}0{% endif %}
{{ yaml_dump(sub_option_name) }}: {% if suboption_option_id == option.default %}50{% else %}0{% endif %}
{%- endfor -%}

{%- if option.name_lookup[option.default] not in option.options %}
{{ option.default }}: 50
{{ yaml_dump(option.default) }}: 50
{%- endif -%}

{%- elif option.default is string %}
{{ option.default }}: 50
{{ yaml_dump(option.default) }}: 50

{%- elif option.default is iterable and option.default is not mapping %}
{{ option.default | list }}

{%- else %}
{{ yaml_dump(option.default) | trim | indent(4, first=false) }}
{{ yaml_dump(option.default) | indent(4, first=false) }}
{%- endif -%}
{{ "\n" }}
{%- endfor %}
Expand Down
Loading