From 3047ab303171db4210209b73e8455e4e044d2b04 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 16 Feb 2022 17:29:48 -0300 Subject: [PATCH] Fixed the YAML example, wrongly quoted string --- docs/samples/generic_plot.kibot.yaml | 2 +- kibot/config_reader.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/samples/generic_plot.kibot.yaml b/docs/samples/generic_plot.kibot.yaml index 5af7d05c..3412bf81 100644 --- a/docs/samples/generic_plot.kibot.yaml +++ b/docs/samples/generic_plot.kibot.yaml @@ -1190,7 +1190,7 @@ outputs: # 3D render of the PCB: - name: 'render_3d_example' - comment: 'Exports the image generated by KiCad's 3D viewer.' + comment: "Exports the image generated by KiCad's 3D viewer." type: 'render_3d' dir: 'Example/render_3d_dir' options: diff --git a/kibot/config_reader.py b/kibot/config_reader.py index e39c9bba..8af10afc 100644 --- a/kibot/config_reader.py +++ b/kibot/config_reader.py @@ -562,6 +562,12 @@ def print_filters_help(): print_output_options(n, o, 2) +def quoted(val): + if "'" in val: + return '"{}"'.format(val) + return "'{}'".format(val) + + def print_example_options(f, cls, name, indent, po, is_list=False): ind_str = indent*' ' obj = cls() @@ -591,7 +597,7 @@ def print_example_options(f, cls, name, indent, po, is_list=False): else: val = getattr(obj, k) if isinstance(val, str): - val = "'{}'".format(val) + val = quoted(val) elif isinstance(val, bool): val = str(val).lower() if isinstance(val, type): @@ -662,7 +668,7 @@ def create_example(pcb_file, out_dir, copy_options, copy_expand): for ln in range(2, len(lines)): f.write(' # '+lines[ln].rstrip()+'\n') f.write(" - name: '{}_example'\n".format(n)) - f.write(" comment: '{}'\n".format(lines[1])) + f.write(" comment: {}\n".format(quoted(lines[1]))) f.write(" type: '{}'\n".format(n)) f.write(" dir: 'Example/{}_dir'\n".format(n)) f.write(" options:\n")