Fix line wrapping in helpers.py

pull/21/head
Dan Puttick 2017-08-07 12:09:22 -04:00
parent 7db95c3889
commit d86f1f78f9
1 changed files with 8 additions and 4 deletions

View File

@ -250,7 +250,7 @@ class FileBase(object):
else: else:
try: try:
mt = magic.from_file(file_path, mime=True) mt = magic.from_file(file_path, mime=True)
# libmagic will always return something, even if it's just 'data' # libmagic always returns something, even if it's just 'data'
except UnicodeEncodeError as e: except UnicodeEncodeError as e:
raise UnicodeEncodeError raise UnicodeEncodeError
self.add_error(e, '') self.add_error(e, '')
@ -258,7 +258,7 @@ class FileBase(object):
try: try:
mimetype = mt.decode("utf-8") mimetype = mt.decode("utf-8")
except: except:
# FIXME: what should the exception be here if mimetype isn't utf-8? # FIXME: what should the exception be if mimetype isn't utf-8?
mimetype = mt mimetype = mt
return mimetype return mimetype
@ -328,7 +328,6 @@ class KittenGroomerBase(object):
def list_all_files(self, directory_path): def list_all_files(self, directory_path):
"""Generator yielding path to all of the files in a directory tree.""" """Generator yielding path to all of the files in a directory tree."""
for root, dirs, files in os.walk(directory_path): for root, dirs, files in os.walk(directory_path):
# files is a list anyway so we don't get much from using a generator here
for filename in files: for filename in files:
filepath = os.path.join(root, filename) filepath = os.path.join(root, filename)
yield filepath yield filepath
@ -353,7 +352,12 @@ class ImplementationRequired(KittenGroomerError):
pass pass
def main(kg_implementation, description='Call a KittenGroomer implementation to process files present in the source directory and copy them to the destination directory.'): def main(
kg_implementation,
description=("Call a KittenGroomer implementation to process files "
"present in the source directory and copy them to the "
"destination directory.")):
print(description)
parser = argparse.ArgumentParser(prog='KittenGroomer', description=description) parser = argparse.ArgumentParser(prog='KittenGroomer', description=description)
parser.add_argument('-s', '--source', type=str, help='Source directory') parser.add_argument('-s', '--source', type=str, help='Source directory')
parser.add_argument('-d', '--destination', type=str, help='Destination directory') parser.add_argument('-d', '--destination', type=str, help='Destination directory')