diff --git a/distribusi/cli.py b/distribusi/cli.py index 7e0d51a..93d33d1 100644 --- a/distribusi/cli.py +++ b/distribusi/cli.py @@ -1,16 +1,17 @@ -import argparse, os +import argparse +import os from distribusi.distribusi import distribusify + def build_argparser(): parser = argparse.ArgumentParser(""" distbusi is a content management system for the web that produces static - index pages based on folders in the files system. It is inspired by the - automatic index functions featured in several popular web servers. It works by - traversing the file system and directory hierarchy to automatically list - all the files in the directory, detect the file types and providing them with - relevant html classes and tags for easy styling.""" - ) + index pages based on folders in the files system. + It is inspired by the automatic index functions featured in several popular web + servers. distribusi works by traversing the file system and directory hierarchy + to automatically list all the files in the directory, detect the file types and + providing them with relevant html classes and tags for easy styling.""") parser.add_argument( '-d', '--directory', help="Select which directory to distribute", default="." @@ -63,5 +64,5 @@ def build_argparser(): def cli_entrypoint(): parser = build_argparser() - args = parser.parse_args() + args = parser.parse_args() distribusify(args, args.directory) diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 28b88d0..db00db8 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -14,15 +14,17 @@ MIME_TYPE = magic.Magic(mime=True) def caption(image): try: - process = subprocess.Popen(['exiftool', '-Comment', image], stdout=subprocess.PIPE) + process = subprocess.Popen( + ['exiftool', '-Comment', image], stdout=subprocess.PIPE) out, err = process.communicate() except Exception as e: print(e) print('Do you have exiftool installed?') try: caption = out.decode("utf-8").split(": ", 1)[1] - except: + except Exception as e: caption = '' + print(e) return caption @@ -43,9 +45,8 @@ def thumbnail(image, name, args): "" ).format(name, data_url, cap) except Exception as e: - print('Thumbnailer:',e) - return "".format(name, name,name) - + print('Thumbnailer:', e) + return "".format(name, name, name) def div(args, type_, subtype, tag, name): @@ -62,7 +63,7 @@ def div(args, type_, subtype, tag, name): elif 'dir' in type_ or 'html' in subtype or 'unkown-file' in subtype: html = '