Skip to content

Commit

Permalink
Fix Build workflow on github (FileNotFoundError)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Günther <[email protected]>
  • Loading branch information
tom-hg57 committed Dec 24, 2024
1 parent 39046f4 commit 7ca2257
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions cimgen/languages/java/lang_pack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import shutil
import chevron
from pathlib import Path
Expand Down Expand Up @@ -65,12 +64,13 @@ def run_template(output_path, class_details):
return

for template_info in templates:
class_file = os.path.join(output_path, class_details["class_name"] + template_info["ext"])
class_file = Path(output_path) / (class_details["class_name"] + template_info["ext"])
_write_templated_file(class_file, class_details, template_info["filename"])


def _write_templated_file(class_file, class_details, template_filename):
with open(class_file, "w", encoding="utf-8") as file:
class_file.parent.mkdir(parents=True, exist_ok=True)
with class_file.open("w", encoding="utf-8") as file:
templates = files("cimgen.languages.java.templates")
with templates.joinpath(template_filename).open(encoding="utf-8") as f:
args = {
Expand Down Expand Up @@ -107,19 +107,17 @@ def label(text, render):

def _create_header_include_file(directory, header_include_filename, header, footer, before, after, blacklist):
lines = []
for filename in sorted(os.listdir(directory)):
filepath = os.path.join(directory, filename)
basepath, ext = os.path.splitext(filepath)
basename = os.path.basename(basepath)
if ext == ".java" and basename not in blacklist:
for file in sorted(directory.glob("*.java")):
basename = file.stem
if basename not in blacklist:
lines.append(before + 'Map.entry("' + basename + '", new cim4j.' + basename + after + "),\n")
lines[-1] = lines[-1].replace("),", ")")
for line in lines:
header.append(line)
for line in footer:
header.append(line)
header_include_filepath = os.path.join(directory, header_include_filename)
with open(header_include_filepath, "w", encoding="utf-8") as f:
header_include_filepath = directory / header_include_filename
with header_include_filepath.open("w", encoding="utf-8") as f:
f.writelines(header)


Expand All @@ -139,7 +137,7 @@ def resolve_headers(path: str, version: str): # NOSONAR
class_list_footer = [" );\n", "}\n"]

_create_header_include_file(
path,
Path(path),
"CIMClassMap.java",
class_list_header,
class_list_footer,
Expand Down

0 comments on commit 7ca2257

Please sign in to comment.