Skip to content
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

Refactor code base #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
249 changes: 0 additions & 249 deletions freshpaper.py

This file was deleted.

10 changes: 10 additions & 0 deletions src/common/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import logging


def get_common_logger() -> logging:
"""
get the common logger and return
:return:
"""
logging.basicConfig(level=logging.INFO, format="%(message)s")
return logging.getLogger(__name__)
33 changes: 33 additions & 0 deletions src/freshpaper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from common.logger import get_common_logger
from imagegetter.image_getter import ImageGetter
import click

log = get_common_logger()
image_getter = ImageGetter(logger=log)
freshpaperSources = image_getter.get_freshpaper_sources()


@click.group(invoke_without_command=True)
@click.pass_context
@click.option(
"--source",
default="bing",
type=click.Choice(freshpaperSources.keys()),
help="Source for setting the wallpaper.",
)
def main(ctx, source) -> None:
if ctx.invoked_subcommand is None:
dir_name = image_getter.get_wallpaper_directory() # Wallpaper directory name
try:
download_image = freshpaperSources.get(source)["download"]
image_path = download_image(dir_name)
image_getter.set_wallpaper(image_path)
except ConnectionError:
image_path = image_getter.get_saved_wallpaper(dir_name)
image_getter.set_wallpaper(image_path)
except Exception as e:
log.error(e)


if __name__ == "__main__":
main()
Loading