Introduce the File tool and tweak stub binary implementation#1871
Introduce the File tool and tweak stub binary implementation#1871freakboy3742 merged 3 commits intobeeware:mainfrom
File tool and tweak stub binary implementation#1871Conversation
src/briefcase/exceptions.py
Outdated
| def __init__(self, filename): | ||
| self.filename = filename | ||
| super().__init__(f"Unable to unpack support package {filename!r}") | ||
| super().__init__(f"Unable to unpack support package '{filename}'.") |
There was a problem hiding this comment.
If you just call repr() here and filename is a Path, it looks like this:
Unable to unpack support package PosixPath("/asdf")
so, this strategy gets what we actually want.
Unable to unpack support package '/asdf'
There was a problem hiding this comment.
Torn between whether we should use the explicit ', or {str(filename)!r} - that should ensure that any inline quotes are correctly escaped (I think...)
There was a problem hiding this comment.
You mean like these differences?
>>> file_path=Path("/pa't'h/to/file")
>>>
>>> print(f"File is {file_path}")
File is /pa't'h/to/file
>>>
>>> print(f"File is {str(file_path)!r}")
File is "/pa't'h/to/file"
>>>
>>> print(f"File is '{file_path}'")
File is '/pa't'h/to/file'Manually calling str() does seem to handle that edge case best.
There was a problem hiding this comment.
That's what I had in mind, yes.
|
ive nerdsniped myself in to implementing a |
File tool and tweak stub binary implementation
- Encapsulates complex file operations such as archive unpacking - Incorporates the (now removed) Download tool's functionality
|
The updates for the |
freakboy3742
left a comment
There was a problem hiding this comment.
A large PR, but largely straightforward, with some nice cleanups along the way. One minor suggestion about some possibly overenthusiastic modularity; weak preference would be to remove it, but if you feel particularly strongly to the contrary, I'm not going to fight you too hard over it.
src/briefcase/integrations/file.py
Outdated
| }, | ||
| ) | ||
|
|
||
| def _unpack_archive_kwargs(self, archive_path: str | os.PathLike) -> dict[str, str]: |
There was a problem hiding this comment.
Possibly a little over-enthusiastic refactoring here; function calls aren't free, and in practice, this method can't be overwritten by a subclass. Given it's wrapping a single if clause that won't be needed in a couple of Python releases, I'm not sure the extra method is worth it.
There was a problem hiding this comment.
That makes sense. I also tweaked it a bit so (in theory, anyway) pyupgrade should have an easier time trimming it down later on.
|
A new problem from this is a corrupted Wasn't there work being done to ensure the bundle was deleted if the |
Changes
FiletoolNotes
PR Checklist: