markubiak / wallpaper-reddit

Downloads and sets wallpapers pulled from reddit.com
GNU General Public License v3.0
113 stars 42 forks source link

Rewrote save-wallpaper for readability + fixed broken titling scheme #13

Closed clotifoth closed 8 years ago

clotifoth commented 8 years ago

Introduction

Rewrote save-wallpaper in wallpaper.py, at first to fix a bug that would save over the same "wallpaper0.jpg" repeatedly rather than have a proper titling scheme, then for clearer logic.

Purpose

Without this fix, saving wallpapers would repeatedly save to "wallpaper0", and titles.txt would fill up with the correct titles attached to "wallpaper0". Additionally code readability improvement is generally a good idea. This also fixes a minor bug where Windows users would see their output call the saved wallpaper path a JPG image and has a minor grammar fix.

Summary of code changes

save_wallpaper() now assembles the paths of the old and new wallpaper images once and reuses this instead of having it be re-assembled at each function call requiring it. This is slightly more efficient. Additionally, the counter for figuring out the wallpaper file name suffix is now properly utilized when saving the file, and is renamed for clarity.

markubiak commented 8 years ago

I didn't even notice the bug with wallpaper saving. Thanks for fixing it. The small readability rewrite wasn't necessary in my opinion but I guess it is slightly more readable now. Approved.

And thanks for the writeups, they're very nice to read.

clotifoth commented 8 years ago

Of course, and of course. :+1: