Add a parameter create to resolve() to create the directory/file if it doesn't exist.#2751
Add a parameter create to resolve() to create the directory/file if it doesn't exist.#2751JackAshwell11 wants to merge 1 commit intopythonarcade:developmentfrom JackAshwell11:resolve_create
create to resolve() to create the directory/file if it doesn't exist.#2751Conversation
…if it doesn't exist.
DragonMoffon
left a comment
There was a problem hiding this comment.
Looks good otherwise.
Since this PR modifies this code already, could we add an additional check. importlib.resources.Traversable is also a common type passed into this method, and it doesn't have a consistent interface with pathlib.Path. See the docs.
We should either have the function work perfectly with either a Path or Traversable or check for and change a Traversable to a Path
| Create a file or directory at the given path. | ||
| If the path has a suffix, it's treated as a file, otherwise, as a directory. | ||
| """ | ||
| if path.suffix: |
There was a problem hiding this comment.
Path objects have an is_dir method, which is probably a safer check.
| if create: | ||
| create_path(path) |
There was a problem hiding this comment.
Should this not also check if the path exists?
IIRC, there was a discussion in Discord which deemed that there was a better way to accomplish what I was trying to do with the MR without requiring changes to Arcade. This PR should probably be closed now |
No description provided.