Skip to content

Use os.path.join for path operations to avoid trailing slashes#5

Open
michael-hoss wants to merge 1 commit into
CommonRoad:developfrom
michael-hoss:path_handling
Open

Use os.path.join for path operations to avoid trailing slashes#5
michael-hoss wants to merge 1 commit into
CommonRoad:developfrom
michael-hoss:path_handling

Conversation

@michael-hoss

Copy link
Copy Markdown

When I set my own paths in GeneralConfiguration using os.path.join commands, there won't be trailing /, e.g.

own_paths = GeneralConfiguration(
    path_scenarios=get_own_scenarios_dir(),
    path_scenarios_batch=os.path.join(get_own_scenarios_dir(), "batch"),
    path_output_abs=os.path.join(get_own_root(), "data/crime_outputs"),
    path_logs=os.path.join(get_own_root(), "data/crime_outputs/logs"),
    path_icons=os.path.join(get_local_crime_root(), "docs/icons"),
)

However, without the trailing /, the path concatenation in the properties path_scenario or path_output breaks.

Hence, I suggest avoiding trailing / (as these would get eliminated in os.path.normpath, too), and using os.path.join whenever possible.

Are there further locations that would need adaptation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant