Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions Extras/HouseOfDust/HouseOfDust.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ def exithandler(signum, frame):
'PEOPLE WHO LOVE TO READ',
]

ruleCount = 8

tab = ' '
lineSpacing = 2

Comment on lines +103 to +107
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 113-144 refactored with the following changes:

while 1:
color = (55, 65, 65)

Expand All @@ -110,14 +115,9 @@ def exithandler(signum, frame):
# font = ImageFont.truetype("dotmatrix.TTF", 24)

font = ImageFont.truetype('daisywhl.otf', 28)
ruleCount = 8

tab = ' '
tabSize = font.getsize(tab)[0] # six spaces for a tab
lineHeight = font.getsize('M')[1]
charWidth = font.getsize('M')[0]
lineSpacing = 2

ruleHeight = lineHeight * lineSpacing / ruleCount
rules = int(size[1] / ruleHeight)
for x in range(rules):
Expand All @@ -137,11 +137,12 @@ def exithandler(signum, frame):

for x in range(4):
x_text = 20
text = ['A HOUSE OF ' + material[x]]
text.append(location[x])
text.append('USING ' + light_source[x])
text.append('INHABITED BY ' + inhabitants[x])

text = [
f'A HOUSE OF {material[x]}',
location[x],
f'USING {light_source[x]}',
f'INHABITED BY {inhabitants[x]}',
]
for line in text:
columns = int((size[0] - x_text) / charWidth)
lines = textwrap.wrap(line, width=columns, replace_whitespace=False)
Expand Down
2 changes: 1 addition & 1 deletion Extras/Nees/nees.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function clip refactored with the following changes:


if type == 0:
for x in range(0, gridX):
Expand Down
31 changes: 12 additions & 19 deletions slowmovie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_next_video refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

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))):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_random_video refactored with the following changes:

return os.path.join(viddir, random.choice(videos))


Expand All @@ -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
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function estimate_runtime refactored with the following changes:



# 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
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function find_subtitles refactored with the following changes:

_, ext = os.path.splitext(i)
if ext.lower() in subtitle_fileTypes:
logger.debug(f"Found subtitle file '{i}'")
Expand Down Expand Up @@ -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
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 280-283 refactored with the following changes:

progressdir = "progress"

# Create progress and Videos directories if missing
Expand Down