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
This is merely a suggestion, but I think it would be beneficial to use the pathlib library instead of the os.path library. The pathlib library is more modern and has a more object-oriented approach to working with file paths. It also has better support for working with different operating systems.
I have created a code snippet of the same code but with pathlib instead of os.path:
defremove_files(
directory: str,
file_types: list= [".log", ".lck", ".SMABulk",
".rec", ".SMAFocus",
".exception", ".simlog", ".023", ".exception"],
) ->None:
"""Remove files of specified types in a directory. Parameters ---------- directory : str Target folder. file_types : list List of file extensions to be removed. """# Create a Path object for the directorydir_path=Path(directory)
fortarget_fileinfile_types:
# Use glob to find files matching the target extensiontarget_files=dir_path.glob(f"*{target_file}")
# Remove the target files if they existforfileintarget_files:
iffile.is_file():
file.unlink()
This is merely a suggestion, but I think it would be beneficial to use the pathlib library instead of the os.path library. The pathlib library is more modern and has a more object-oriented approach to working with file paths. It also has better support for working with different operating systems.
I have created a code snippet of the same code but with pathlib instead of os.path:
Assignees:
Labels:
rvesimulator/src/rvesimulator/abaqus2py/abaqus_simulator.py
Lines 367 to 403 in ea31752
The text was updated successfully, but these errors were encountered: