-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored main branch #1
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ def exithandler(signum, frame): | |
| d = ImageDraw.Draw(img) | ||
|
|
||
| def clip(val, min_, max_): | ||
| return (min_ if val < min_ else (max_ if val > max_ else val)) | ||
| return min_ if val < min_ else min(val, max_) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| if type == 0: | ||
| for x in range(0, gridX): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,16 +164,15 @@ def get_next_video(viddir, currentVideo=None): | |
| if currentVideo: | ||
| nextIndex = videos.index(currentVideo) + 1 | ||
| # If we're not wrapping around | ||
| if not nextIndex >= len(videos): | ||
| if nextIndex < len(videos): | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return os.path.join(viddir, videos[nextIndex]) | ||
| # Wrapping around or no current video: return first video | ||
| return os.path.join(viddir, videos[0]) | ||
|
|
||
|
|
||
| # Returns a random video from the videos directory | ||
| def get_random_video(viddir): | ||
| videos = list(filter(supported_filetype, os.listdir(viddir))) | ||
| if videos: | ||
| if videos := list(filter(supported_filetype, os.listdir(viddir))): | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return os.path.join(viddir, random.choice(videos)) | ||
|
|
||
|
|
||
|
|
@@ -186,25 +185,22 @@ def estimate_runtime(delay, increment, frames, all=False): | |
| days = hours / 24 | ||
|
|
||
| if all: | ||
| output = f"{seconds:.1f} second(s) / {minutes:.1f} minute(s) / {hours:.1f} hour(s) / {days:.2f} day(s)" | ||
| return f"{seconds:.1f} second(s) / {minutes:.1f} minute(s) / {hours:.1f} hour(s) / {days:.2f} day(s)" | ||
| elif minutes < 1: | ||
| return f"{seconds:.1f} second(s)" | ||
| elif hours < 1: | ||
| return f"{minutes:.1f} minute(s)" | ||
| elif days < 1: | ||
| return f"{hours:.1f} hour(s)" | ||
| else: | ||
| if minutes < 1: | ||
| output = f"{seconds:.1f} second(s)" | ||
| elif hours < 1: | ||
| output = f"{minutes:.1f} minute(s)" | ||
| elif days < 1: | ||
| output = f"{hours:.1f} hour(s)" | ||
| else: | ||
| output = f"{days:.2f} day(s)" | ||
|
|
||
| return output | ||
| return f"{days:.2f} day(s)" | ||
|
Comment on lines
-189
to
+196
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
|
|
||
| # Check for a matching subtitle file | ||
| def find_subtitles(file): | ||
| if args.subtitles: | ||
| name, _ = os.path.splitext(file) | ||
| for i in glob.glob(name + ".*"): | ||
| for i in glob.glob(f"{name}.*"): | ||
|
Comment on lines
-207
to
+203
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| _, ext = os.path.splitext(i) | ||
| if ext.lower() in subtitle_fileTypes: | ||
| logger.debug(f"Found subtitle file '{i}'") | ||
|
|
@@ -277,10 +273,7 @@ def error(self, message): | |
| height = epd.height | ||
|
|
||
| # Set path of Videos directory and logs directory. Videos directory can be specified by CLI --directory | ||
| if args.directory: | ||
| viddir = args.directory | ||
| else: | ||
| viddir = "Videos" | ||
| viddir = args.directory if args.directory else "Videos" | ||
|
Comment on lines
-280
to
+276
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
| progressdir = "progress" | ||
|
|
||
| # Create progress and Videos directories if missing | ||
|
|
||
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.
Lines
113-144refactored with the following changes:hoist-statement-from-loop)merge-list-append)use-fstring-for-concatenation)