Skip to content

Commit

Permalink
ruff formated
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewI26 committed Nov 11, 2024
1 parent 2b1d480 commit b0a859e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 9 additions & 3 deletions scripts/cangen/cangen/can_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ def _create_jninja_environment(

return env


def _create_output_file_name(output_dir: str, bus_name: str, template_file_name: str):
return os.path.join(output_dir, bus_name.lower() + "_" + template_file_name[:-7])


def _generate_jninja_template(template_file_name, output_path, context, env):
template = env.get_template(template_file_name)
rendered_code = template.render(**context)
Expand All @@ -195,6 +197,7 @@ def _generate_jninja_template(template_file_name, output_path, context, env):
output_file.write(rendered_code)
logger.info(f"Rendered code written to '{os.path.abspath(output_file_name)}'")


def _generate_code(bus: Bus, config: Config):
"""
Parses DBC files, extracts information, and generates code using Jinja2
Expand Down Expand Up @@ -229,10 +232,13 @@ def _generate_code(bus: Bus, config: Config):
)
for template_file_name in TEMPLATE_FILE_NAMES:
_generate_jninja_template(
template_file_name,
_create_output_file_name(config.output_dir, bus.bus_name, template_file_name),
template_file_name,
_create_output_file_name(
config.output_dir, bus.bus_name, template_file_name
),
context,
env)
env,
)

logger.info("Code generation complete")

Expand Down
6 changes: 5 additions & 1 deletion scripts/cangen/cangen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def parse():
"DEBUG": "DEBUG",
}

args.level = cmake_to_python_level['VERBOSE'] if args.is_verbose else cmake_to_python_level[args.level]
args.level = (
cmake_to_python_level["VERBOSE"]
if args.is_verbose
else cmake_to_python_level[args.level]
)
return args


Expand Down

0 comments on commit b0a859e

Please sign in to comment.