config: cleanup

This commit is contained in:
Dylan Araps 2018-04-01 14:23:31 +10:00
parent 82a571db3f
commit 49ca108ead
2 changed files with 7 additions and 2 deletions

View File

@ -117,10 +117,10 @@ def get(img, light=False, backend="default", cache_dir=CACHE_DIR):
# Dynamically import the backend we want to use.
# This keeps the dependencies "optional".
try:
__import__("pywal.backends.%s" % backend)
util.variable_import("pywal.backends.%s" % backend)
except ImportError:
util.variable_import("pywal.backends.wal")
backend = "wal"
__import__("pywal.backends.%s" % backend)
logging.info("Using %s backend.", backend)
backend = sys.modules["pywal.backends.%s" % backend]

View File

@ -92,6 +92,11 @@ def create_dir(directory):
os.makedirs(directory, exist_ok=True)
def variable_import(module):
"""Import a module dynamically."""
__import__(module)
def setup_logging():
"""Logging config."""
logging.basicConfig(format=("[%(levelname)s\033[0m] "