Skip to content

Commit

Permalink
changed order of cleaning output dir
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewI26 committed Nov 4, 2024
1 parent f47a88e commit 9caba19
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions scripts/cangen/cangen/can_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,20 @@ def generate_code(bus: Bus, config: Config):


def _prepare_output_directory(output_dir):
if os.path.exists(output_dir):
shutil.rmtree(output_dir)

"""Deletes previously generated files and creates a gitignore for the directory"""
os.makedirs(output_dir, exist_ok=True)
shutil.rmtree(output_dir)

os.makedirs(output_dir, exist_ok=True)

# Create a git ignore for everything in the generated path. Ignore everything.
gitignore_path = os.path.join(output_dir, ".gitignore")
if not os.path.exists(gitignore_path):
with open(gitignore_path, "w") as f:
f.write("*")
with open(gitignore_path, "w") as f:
f.write("*")


def generate_can_from_dbc(project_folder_name: str):
os.chdir(project_folder_name)
config = Config.from_yaml("config.yaml")

# Deletes previously generated files and creates a gitignore for the directory
_prepare_output_directory(config.output_dir)

for bus in config.busses:
Expand Down

0 comments on commit 9caba19

Please sign in to comment.