diff options
| author | 2023-03-02 17:14:32 -0500 | |
|---|---|---|
| committer | 2023-03-02 17:14:32 -0500 | |
| commit | 3854079b52b3395ba59526b9b730b4cc40ede4b9 (patch) | |
| tree | 2def7627f59e306ac22e7966f2dbe0df6a76a446 | |
| parent | Update unit tests for home output directory (diff) | |
Refactor FileAttachment.save_to() to return the saved file Path object
Diffstat (limited to '')
| -rw-r--r-- | snekbox/snekio.py | 5 | 
1 files changed, 3 insertions, 2 deletions
| diff --git a/snekbox/snekio.py b/snekbox/snekio.py index 45ebc61..821f057 100644 --- a/snekbox/snekio.py +++ b/snekbox/snekio.py @@ -80,12 +80,13 @@ class FileAttachment:          """Size of the attachment."""          return len(self.content) -    def save_to(self, directory: Path | str) -> None: -        """Write the attachment to a file in `directory`.""" +    def save_to(self, directory: Path | str) -> Path: +        """Write the attachment to a file in `directory`. Return a Path of the file."""          file = Path(directory, self.path)          # Create directories if they don't exist          file.parent.mkdir(parents=True, exist_ok=True)          file.write_bytes(self.content) +        return file      @cached_property      def as_dict(self) -> dict[str, str | int]: | 
