You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using blobmaker in an optimisation workflow, we already need to track the majority of filepaths. Thus, it's more straightforward to pass the full filepath directly to methods such as GeometryMaker.export_exodus. However, currently this causes filenames with two extensions like so: filename.e.e. This can be avoided by removing the extension when passing to such methods, but it would be preferable if blobmaker could check for the extension before adding it.
Consider the following code block to achieve this:
frompathlibimportPath# Get required extension, e.g. for exodus:ext=".e"# Add required extension if it is not already present.filepath=Path(filepath) # Ensure path is a pathlib.Path objectiffilepath.suffix!=ext: # Check for extensionfilepath=filepath.parent/ (filepath.name+ext) # Add the extension# If you need the filepath as a string again, just pass it like so:str(filepath)
As shown, pathlib makes it quite easy to check the file extension (or suffix) and is a built-in module for python so doesn't require adding a dependency.
The text was updated successfully, but these errors were encountered:
When using blobmaker in an optimisation workflow, we already need to track the majority of filepaths. Thus, it's more straightforward to pass the full filepath directly to methods such as
GeometryMaker.export_exodus
. However, currently this causes filenames with two extensions like so:filename.e.e
. This can be avoided by removing the extension when passing to such methods, but it would be preferable ifblobmaker
could check for the extension before adding it.Consider the following code block to achieve this:
As shown,
pathlib
makes it quite easy to check the file extension (or suffix) and is a built-in module for python so doesn't require adding a dependency.The text was updated successfully, but these errors were encountered: