From e89d382ebf3ad6ad0698ae357e7ac027d793b281 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 04:46:23 +0000 Subject: [PATCH 1/2] Initial plan From de1014159f0bf429b8691cfab52cbd8bbef92dca Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 2 Mar 2026 04:59:59 +0000 Subject: [PATCH 2/2] Fix Windows benchmark: add encoding='utf-8' to all open() calls in generators Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com> --- .github/workflows/benchmark.yml | 4 ++-- html-generators/generate.py | 12 ++++++------ html-generators/generateog.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 87b8507..69def7e 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -44,7 +44,7 @@ jobs: OG_AOT="html-generators/generateog.aot" STEADY_RUNS=5 - snippet_count=$(find content -name '*.json' | wc -l | tr -d ' ') + snippet_count=$(find content \( -name '*.json' -o -name '*.yaml' -o -name '*.yml' \) -not -name 'template.*' | wc -l | tr -d ' ') java_ver=$(java -version 2>&1 | head -1 | sed 's/.*"\(.*\)".*/\1/') os_name="${{ matrix.os }}" @@ -232,7 +232,7 @@ jobs: run: | os_name="${{ matrix.os }}" java_ver=$(java -version 2>&1 | head -1 | sed 's/.*"\(.*\)".*/\1/') - snippet_count=$(find content -name '*.json' | wc -l | tr -d ' ') + snippet_count=$(find content \( -name '*.json' -o -name '*.yaml' -o -name '*.yml' \) -not -name 'template.*' | wc -l | tr -d ' ') measure() { TIMEFORMAT='%R' diff --git a/html-generators/generate.py b/html-generators/generate.py index c21f2e2..e63f362 100644 --- a/html-generators/generate.py +++ b/html-generators/generate.py @@ -40,7 +40,7 @@ def _load_properties(path): """Load a .properties file into an OrderedDict, preserving insertion order.""" props = OrderedDict() - with open(path) as f: + with open(path, encoding="utf-8") as f: for line in f: line = line.strip() if not line or line.startswith("#"): @@ -70,7 +70,7 @@ def _find_with_extensions(directory, base_name): def _read_auto(path): """Read a JSON or YAML file based on its extension.""" - with open(path) as f: + with open(path, encoding="utf-8") as f: if path.endswith(".yaml") or path.endswith(".yml"): return yaml.safe_load(f) return json.load(f) @@ -604,7 +604,7 @@ def build_locale(locale, templates, all_snippets): out_dir = os.path.join(SITE_DIR, locale, snippet["category"]) os.makedirs(out_dir, exist_ok=True) out_path = os.path.join(out_dir, f"{snippet['slug']}.html") - with open(out_path, "w", newline="") as f: + with open(out_path, "w", newline="", encoding="utf-8") as f: f.write(html_content) print(f"Generated {len(all_snippets)} HTML files for {locale}") @@ -622,7 +622,7 @@ def build_locale(locale, templates, all_snippets): else os.path.join(SITE_DIR, locale, "data") ) os.makedirs(data_dir, exist_ok=True) - with open(os.path.join(data_dir, "snippets.json"), "w") as f: + with open(os.path.join(data_dir, "snippets.json"), "w", encoding="utf-8") as f: json.dump(snippets_list, f, indent=2, ensure_ascii=False) f.write("\n") print(f"Rebuilt data/snippets.json for {locale} with {len(snippets_list)} entries") @@ -655,7 +655,7 @@ def build_locale(locale, templates, all_snippets): index_dir = os.path.join(SITE_DIR, locale) os.makedirs(index_dir, exist_ok=True) index_path = os.path.join(index_dir, "index.html") - with open(index_path, "w") as f: + with open(index_path, "w", encoding="utf-8") as f: f.write(index_html) print(f"Generated index.html for {locale} with {len(all_snippets)} cards") @@ -667,7 +667,7 @@ def build_locale(locale, templates, all_snippets): def load_templates(): """Load all HTML templates.""" def _read(path): - with open(path) as f: + with open(path, encoding="utf-8") as f: return f.read() return { "page": _read("templates/slug-template.html"), diff --git a/html-generators/generateog.py b/html-generators/generateog.py index b76005e..2d2e4d9 100644 --- a/html-generators/generateog.py +++ b/html-generators/generateog.py @@ -98,7 +98,7 @@ def load_properties(path): props = OrderedDict() - with open(path) as f: + with open(path, encoding="utf-8") as f: for line in f: line = line.strip() if not line or line.startswith("#"): @@ -113,7 +113,7 @@ def load_properties(path): def read_auto(path): - with open(path) as f: + with open(path, encoding="utf-8") as f: if path.endswith((".yaml", ".yml")): if yaml is None: raise ImportError("PyYAML is required for YAML files: pip install pyyaml") @@ -320,7 +320,7 @@ def main(): svg = generate_svg(data) svg_path = os.path.join(out_dir, f"{slug}.svg") - with open(svg_path, "w") as f: + with open(svg_path, "w", encoding="utf-8") as f: f.write(svg) png_path = os.path.join(out_dir, f"{slug}.png")