From eba58ebe92ca73c2c9f494a05c5c5a1a011abfbf Mon Sep 17 00:00:00 2001 From: RRA Date: Sun, 26 Mar 2017 17:42:28 +0200 Subject: [PATCH] added verbose flag for debug output --- .gitignore | 2 ++ distribusi.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) mode change 100644 => 100755 distribusi.py diff --git a/.gitignore b/.gitignore index 0d20b64..ccf38ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.pyc +index.html +__pycache__/ diff --git a/distribusi.py b/distribusi.py old mode 100644 new mode 100755 index bde443e..f3b0446 --- a/distribusi.py +++ b/distribusi.py @@ -12,6 +12,7 @@ parser = argparse.ArgumentParser(""" """) parser.add_argument('-d', '--directory', help="Select which directory to distribute") +parser.add_argument('-v', '--verbose', help="Print verbose debug output", action="store_true") args = parser.parse_args() if args.directory: @@ -37,7 +38,11 @@ def div(mime, tag, *values): for root, dirs, files in os.walk(directory): html = [] + if args.verbose: + print ('Listing', root) for name in files: + if args.verbose: + print ('Adding', name) if 'index.html' not in name: full_path = os.path.join(root,name) mime = mime_type.from_file(full_path) @@ -54,7 +59,8 @@ for root, dirs, files in os.walk(directory): if mime not in file_types and format not in file_types: #to catch exceptions we haven't defined in file_types before a = "{}" - # print (mime,format, name) + if args.verbose: + print ('Unrecognized mime-type: \n', mime,format, name) a = a.replace('{}',name) html.append(div(mime,a,name)) @@ -65,7 +71,6 @@ for root, dirs, files in os.walk(directory): for name in dirs: i = os.path.join(root,name) a = "{}/".replace('{}',name) - # print(a) html.append(div('dir',a,'folder'))