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
Replace use of os.path with pathlib #156
base: main
Are you sure you want to change the base?
Conversation
Tested on Linux (Solus) for basic functionality |
good job, this was really needed 👍 |
Co-authored-by: yed podtrzitko <yedpodtrzitko@users.noreply.github.com>
@yedpodtrzitko Thanks for the comments, I think I've resolved most of them. I'll have to test with the changes and ruff-format it again. |
Fixed some issues that cropped up with the modularized GUI files. |
I think all the basics are working now, tested creating/opening library, adding tags/fields, and removing unlinked files (on Solus Linux) |
I'll get that going soon here |
qim = ImageQt.ImageQt(final) | ||
final.save(f'/home/icosahunter/Documents/test/{filepath.stem}.png') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, I'll need to fix that 🤦♂️
Tested basic functionality on my Linux distro (Solus) and seems to be working. At one point I did get a segfault... but it didn't happen in later testing. |
else os.path.normpath(f"{results_filepath}") | ||
) | ||
if os.path.exists(full_results_path): | ||
full_results_path = Path(results_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
full_results_path = Path(results_path) | |
full_results_path = Path(results_filepath) |
at this moment methods without any type annotations in their declaration arent checked (which is the case of refresh_dupe_files()
here), so this undefined variable isnt caught.
Adding either the return type, or type for the param results_filepath
would help here.
with rawpy.imread(filepath) as raw: | ||
rgb = raw.postprocess() | ||
image = Image.new( | ||
"L", (rgb.shape[1], rgb.shape[0]), color="black" | ||
) | ||
elif extension in VIDEO_TYPES: | ||
elif filepath.suffix in VIDEO_TYPES: | ||
video = cv2.VideoCapture(filepath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
video = cv2.VideoCapture(filepath) | |
video = cv2.VideoCapture(str(filepath)) |
cv2.VideoCapture expects a string here, and throws an error when given a Path object such as:
[PreviewPanel][ERROR] Couldn't Render thumbnail for F:\Example 4\Folder A\yoink\video.mp4 (because of OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'VideoCapture'
> Overload resolution failed:
> - Can't convert object to 'str' for 'filename'
> - VideoCapture() missing required argument 'apiPreference' (pos 2)
> - Argument 'index' is required to be an integer
> - VideoCapture() missing required argument 'apiPreference' (pos 2)
)
Can be reproduced by checking the console log after clicking on a video file in the library. I see that the other instances outside of ts_cli.py
are also using this cast.
self.dimensions_label.setText( | ||
f"{extension.upper()} • {format_size(os.stat(filepath).st_size)}\n{image.width} x {image.height} px" | ||
f"{filepath.suffix.upper()} • {format_size(os.stat(filepath).st_size)}\n{image.width} x {image.height} px" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"{filepath.suffix.upper()} • {format_size(os.stat(filepath).st_size)}\n{image.width} x {image.height} px" | |
f"{filepath.suffix.upper()[1:]} • {format_size(os.stat(filepath).st_size)}\n{image.width} x {image.height} px" |
Removes leading "." from filetype display
) | ||
else: | ||
self.dimensions_label.setText(f"{extension.upper()}") | ||
self.dimensions_label.setText(f"{filepath.suffix.upper()}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.dimensions_label.setText(f"{filepath.suffix.upper()}") | |
self.dimensions_label.setText(f"{filepath.suffix.upper()[1:]}") |
Removes leading "." from filetype display
@@ -535,7 +534,7 @@ def update_widgets(self): | |||
DecompressionBombError, | |||
) as e: | |||
self.dimensions_label.setText( | |||
f"{extension.upper()} • {format_size(os.stat(filepath).st_size)}" | |||
f"{filepath.suffix.upper()} • {format_size(os.stat(filepath).st_size)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f"{filepath.suffix.upper()} • {format_size(os.stat(filepath).st_size)}" | |
f"{filepath.suffix.upper()[1:]} • {format_size(os.stat(filepath).st_size)}" |
Removes leading "." from filetype display (wish I could comment on all these different lines at once)
@@ -289,8 +286,8 @@ def render( | |||
math.ceil(adj_size / pixel_ratio), | |||
math.ceil(final.size[1] / pixel_ratio), | |||
), | |||
extension, | |||
_filepath.suffix, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_filepath.suffix, | |
_filepath.suffix[1:], |
Removes leading "." from filetype display on thumbnails
) | ||
|
||
else: | ||
self.updated.emit(timestamp, QPixmap(), QSize(*base_size), extension) | ||
self.updated.emit(timestamp, QPixmap(), QSize(*base_size), _filepath.suffix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.updated.emit(timestamp, QPixmap(), QSize(*base_size), _filepath.suffix) | |
self.updated.emit(timestamp, QPixmap(), QSize(*base_size), _filepath.suffix[1:]) |
Removes leading "." from filetype display on thumbnails
No description provided.