diff --git a/distribusi.py b/distribusi.py index f3b0446..eb00de7 100755 --- a/distribusi.py +++ b/distribusi.py @@ -24,16 +24,17 @@ else: mime_type = magic.Magic(mime=True) file_types = {'image':'', 'pdf':'{}', -'text':'{}', 'video':'', 'audio':'','html':'{}'} +'text':'{}', 'video':'', 'audio':'','html':'{}'} def dict_by_value(dictionary, value): return(list(dictionary.keys())[list(dictionary.values()).index(value)]) # returns the key for the given value def div(mime, tag, *values): #name, full_path + class_name = values[0].split('.')[0].replace(' ', '_') if 'image' in mime: - html ='
'.format(values[0])+tag+'
{}
'.format(values[0]) + html ='
'.format(class_name)+tag+'
{}
'.format(values[0]) else: - html = '
'.format(values[0])+tag+'
'.format(values[0]) + html = '
'.format(class_name)+tag+'
'.format(values[0]) return html for root, dirs, files in os.walk(directory): @@ -48,6 +49,9 @@ for root, dirs, files in os.walk(directory): mime = mime_type.from_file(full_path) mime, format = mime.split('/') #example: text plain + if args.verbose: + print(mime, format) + if mime in file_types: if name.endswith('.html'): a = open(full_path).read() @@ -60,7 +64,7 @@ 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 = "{}" if args.verbose: - print ('Unrecognized mime-type: \n', mime,format, name) + print ('mime-type not in list, adding as href: \n', mime,format, name) a = a.replace('{}',name) html.append(div(mime,a,name)) diff --git a/page_template.py b/page_template.py index d7dcace..da22458 100644 --- a/page_template.py +++ b/page_template.py @@ -4,10 +4,12 @@ html_head = """ +