Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"

Expand Down Expand Up @@ -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'
Expand Down
12 changes: 6 additions & 6 deletions html-generators/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("#"):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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}")
Expand All @@ -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")
Expand Down Expand Up @@ -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")

Expand All @@ -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"),
Expand Down
6 changes: 3 additions & 3 deletions html-generators/generateog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("#"):
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down