Browse Source

clean up according to pep8

master
RRA 5 years ago
parent
commit
8529d952cd
  1. 15
      distribusi/cli.py
  2. 8
      distribusi/distribusi.py

15
distribusi/cli.py

@ -1,16 +1,17 @@
import argparse, os import argparse
import os
from distribusi.distribusi import distribusify from distribusi.distribusi import distribusify
def build_argparser(): def build_argparser():
parser = argparse.ArgumentParser(""" parser = argparse.ArgumentParser("""
distbusi is a content management system for the web that produces static 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 index pages based on folders in the files system.
automatic index functions featured in several popular web servers. It works by It is inspired by the automatic index functions featured in several popular web
traversing the file system and directory hierarchy to automatically list servers. distribusi works by traversing the file system and directory hierarchy
all the files in the directory, detect the file types and providing them with to automatically list all the files in the directory, detect the file types and
relevant html classes and tags for easy styling.""" providing them with relevant html classes and tags for easy styling.""")
)
parser.add_argument( parser.add_argument(
'-d', '--directory', help="Select which directory to distribute", default="." '-d', '--directory', help="Select which directory to distribute", default="."

8
distribusi/distribusi.py

@ -14,15 +14,17 @@ MIME_TYPE = magic.Magic(mime=True)
def caption(image): def caption(image):
try: try:
process = subprocess.Popen(['exiftool', '-Comment', image], stdout=subprocess.PIPE) process = subprocess.Popen(
['exiftool', '-Comment', image], stdout=subprocess.PIPE)
out, err = process.communicate() out, err = process.communicate()
except Exception as e: except Exception as e:
print(e) print(e)
print('Do you have exiftool installed?') print('Do you have exiftool installed?')
try: try:
caption = out.decode("utf-8").split(": ", 1)[1] caption = out.decode("utf-8").split(": ", 1)[1]
except: except Exception as e:
caption = '' caption = ''
print(e)
return caption return caption
@ -47,7 +49,6 @@ def thumbnail(image, name, args):
return "<figure><a href='{}'><img src='{}'></a><figcaption>{}</figcaption></figure>".format(name, name, name) return "<figure><a href='{}'><img src='{}'></a><figcaption>{}</figcaption></figure>".format(name, name, name)
def div(args, type_, subtype, tag, name): def div(args, type_, subtype, tag, name):
id_name = name.split('.')[0].replace(' ', '_') id_name = name.split('.')[0].replace(' ', '_')
if args.no_filenames: if args.no_filenames:
@ -71,7 +72,6 @@ def distribusify(args, directory): # noqa
for root, dirs, files in os.walk(directory): for root, dirs, files in os.walk(directory):
if not args.remove_index: if not args.remove_index:
html = [] html = []
if args.verbose: if args.verbose:
print('Generating directory listing for', root) print('Generating directory listing for', root)

Loading…
Cancel
Save