Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle new path creation #2839

Closed
wants to merge 1 commit into from
Closed

Handle new path creation #2839

wants to merge 1 commit into from

Conversation

bphd
Copy link
Contributor

@bphd bphd commented Jan 12, 2025

To handle cases where a path, a file, or both need to be created, you can enhance the fname.touch() code as follows:

try:
    # Create parent directories if they don't exist
    fname.parent.mkdir(parents=True, exist_ok=True)
    # Create the file
    fname.touch()
    all_matched_files.add(str(fname))
    self.io.tool_output(f"Created file: {fname}")
except OSError as e:
    self.io.tool_error(f"Error creating file {fname}: {e}")

This code ensures that any necessary parent directories are created before attempting to create the file itself.

(coPilot)

To handle cases where a path, a file, or both need to be created, you can enhance the `fname.touch()` code as follows:

```python
try:
    # Create parent directories if they don't exist
    fname.parent.mkdir(parents=True, exist_ok=True)
    # Create the file
    fname.touch()
    all_matched_files.add(str(fname))
    self.io.tool_output(f"Created file: {fname}")
except OSError as e:
    self.io.tool_error(f"Error creating file {fname}: {e}")
```

This code ensures that any necessary parent directories are created before attempting to create the file itself.
@paul-gauthier
Copy link
Collaborator

Is this trying to a fix a problem you have encountered? If so, can you describe the problem and steps to reproduce it?

@bphd
Copy link
Contributor Author

bphd commented Jan 14, 2025

Is this trying to a fix a problem you have encountered? If so, can you describe the problem and steps to reproduce it?

Error OS 2

@bphd bphd closed this Jan 29, 2025
@bphd bphd deleted the patch-1 branch January 29, 2025 18:12
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.

2 participants