PEP8 cleanups

This commit is contained in:
Roberto Rosario
2012-01-18 14:37:15 -04:00
parent ad59734460
commit 970cb74d35
62 changed files with 365 additions and 379 deletions

View File

@@ -19,7 +19,7 @@ from .exceptions import OfficeConversionError
HASH_FUNCTION = lambda x: hashlib.sha256(x).hexdigest()
def cache_cleanup(input_filepath, *args, **kwargs):
try:
os.remove(create_image_cache_filename(input_filepath, *args, **kwargs))
@@ -42,13 +42,13 @@ def convert(input_filepath, output_filepath=None, cleanup_files=False, mimetype=
rotation = kwargs.get('rotation', DEFAULT_ROTATION)
page = kwargs.get('page', DEFAULT_PAGE_NUMBER)
transformations = kwargs.get('transformations', [])
if transformations is None:
transformations = []
if output_filepath is None:
output_filepath = create_image_cache_filename(input_filepath, *args, **kwargs)
if os.path.exists(output_filepath):
return output_filepath
@@ -79,7 +79,7 @@ def convert(input_filepath, output_filepath=None, cleanup_files=False, mimetype=
'transformation': TRANSFORMATION_ZOOM,
'arguments': {'percent': zoom}
}
)
)
if rotation != 0 and rotation != 360:
transformations.append(
@@ -87,7 +87,7 @@ def convert(input_filepath, output_filepath=None, cleanup_files=False, mimetype=
'transformation': TRANSFORMATION_ROTATE,
'arguments': {'degrees': rotation}
}
)
)
try:
backend.convert_file(input_filepath=input_filepath, output_filepath=output_filepath, transformations=transformations, page=page, file_format=file_format, mimetype=mimetype)
@@ -107,7 +107,7 @@ def get_page_count(input_filepath):
except OfficeConversionError:
raise UnknownFileFormat('office converter exception')
return backend.get_page_count(input_filepath)
'''
@@ -127,8 +127,7 @@ def get_available_transformations_choices():
result.append([transformation, transformation_template])
return result
def get_format_list():
return [(format, FILE_FORMATS.get(format, u'')) for format in backend.get_format_list()]

View File

@@ -1,29 +1,29 @@
class ConvertError(Exception):
'''
"""
Base exception for all coverter app exceptions
'''
"""
pass
class UnknownFileFormat(ConvertError):
'''
"""
Raised when the converter backend can't understand a file
'''
"""
pass
class IdentifyError(ConvertError):
'''
"""
Raised by the graphcismagick and imagemagics identify program
'''
"""
pass
class UnkownConvertError(ConvertError):
'''
"""
Raised when an error is found but there is no disernible way to
identify the kind of error
'''
"""
pass

View File

@@ -53,7 +53,7 @@ FILE_FORMATS = {
'8BIN': _(u'Photoshop resource format'),
'8BIMTEXT': _(u'Photoshop resource text format'),
'8BIMWTEXT': _(u'Photoshop resource wide text format'),
'A': _(u'Raw alpha samples'),
'AI': _(u'Adobe Illustrator CS2'),
'APP1': _(u'Raw application information'),
@@ -62,7 +62,7 @@ FILE_FORMATS = {
'ARW': _(u'Sony Alpha DSLR Raw Image Format'),
'AVI': _(u'Microsoft Audio/Visual Interleaved'),
'AVS': _(u'AVS X image'),
'B': _(u'Raw blue samples'),
'BGR': _(u'Raw blue, green, and red samples'),
'BGRA': _(u'Raw blue, green, red and alpha samples'),
@@ -95,7 +95,7 @@ FILE_FORMATS = {
'DJVU': _(u'Déjà vu'),
'DNG': _(u'Adobe Digital Negative'),
'DOT': _(u'Graphviz'),
'DPX': _(u'SMPTE 268M-2003 (DPX 2.0)'),
'DPX': _(u'SMPTE 268M-2003 (DPX 2.0)'),
'EPDF': _(u'Encapsulated Portable Document Format'),
'EPI': _(u'Adobe Encapsulated PostScript Interchange format'),
@@ -110,7 +110,7 @@ FILE_FORMATS = {
'ERF': _(u'Epson RAW Format'),
'EXIF': _(u'Exif digital camera binary data'),
'EXR': _(u'High Dynamic-range (HDR)'),
'FAX': _(u'Group 3 FAX (Not TIFF Group3 FAX)'),
'FLI': _(u'Autodesk FLI animations file'),
'FLC': _(u'Autodesk FLC animations file'),

View File

@@ -13,14 +13,14 @@ from .exceptions import (OfficeConversionError,
OfficeBackendError, UnknownFileFormat)
CACHED_FILE_SUFFIX = u'_office_converter'
CONVERTER_OFFICE_FILE_MIMETYPES = [
u'application/msword',
u'application/mswrite',
u'application/mspowerpoint',
u'application/msexcel',
u'application/vnd.ms-excel',
u'application/vnd.ms-powerpoint',
u'application/vnd.ms-powerpoint',
u'application/vnd.oasis.opendocument.presentation',
u'application/vnd.oasis.opendocument.text',
u'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
@@ -43,7 +43,7 @@ class OfficeConverter(object):
self.exists = False
self.mimetype = None
self.encoding = None
def mimetypes(self):
return CONVERTER_OFFICE_FILE_MIMETYPES
@@ -51,7 +51,7 @@ class OfficeConverter(object):
self.exists = False
self.mimetype = None
self.encoding = None
self.input_filepath = input_filepath
# Make sure file is of a known office format
@@ -71,13 +71,13 @@ class OfficeConverter(object):
except OfficeBackendError, msg:
# convert exception so that at least the mime type icon is displayed
raise UnknownFileFormat(msg)
def __unicode__(self):
return getattr(self, 'output_filepath', None)
def __str__(self):
return str(self.__unicode__())
class OfficeConverterBackendUnoconv(object):
def __init__(self):
@@ -91,7 +91,7 @@ class OfficeConverterBackendUnoconv(object):
'''
self.input_filepath = input_filepath
self.output_filepath = output_filepath
command = []
command.append(self.unoconv_path)

View File

@@ -20,4 +20,3 @@ Another way to test that 1 + 1 is equal to 2.
>>> 1 + 1 == 2
True
"""}