Improve a bit the formatting of the code thanks to pyflakes3
This commit is contained in:
parent
11008f8fd4
commit
893f58554a
@ -10,11 +10,7 @@ class MutagenParser(abstract.AbstractParser):
|
||||
super().__init__(filename)
|
||||
try:
|
||||
mutagen.File(self.filename)
|
||||
except mutagen.flac.MutagenError:
|
||||
raise ValueError
|
||||
except mutagen.mp3.MutagenError:
|
||||
raise ValueError
|
||||
except mutagen.ogg.MutagenError:
|
||||
except mutagen.MutagenError:
|
||||
raise ValueError
|
||||
|
||||
def get_meta(self):
|
||||
|
@ -15,7 +15,7 @@ from gi.repository import GdkPixbuf
|
||||
from . import abstract
|
||||
|
||||
|
||||
class __ImageParser(abstract.AbstractParser):
|
||||
class _ImageParser(abstract.AbstractParser):
|
||||
@staticmethod
|
||||
def __handle_problematic_filename(filename: str, callback) -> str:
|
||||
""" This method takes a filename with a problematic name,
|
||||
@ -42,7 +42,7 @@ class __ImageParser(abstract.AbstractParser):
|
||||
meta.pop(key, None)
|
||||
return meta
|
||||
|
||||
class PNGParser(__ImageParser):
|
||||
class PNGParser(_ImageParser):
|
||||
mimetypes = {'image/png', }
|
||||
meta_whitelist = {'SourceFile', 'ExifToolVersion', 'FileName',
|
||||
'Directory', 'FileSize', 'FileModifyDate',
|
||||
@ -65,7 +65,7 @@ class PNGParser(__ImageParser):
|
||||
return True
|
||||
|
||||
|
||||
class GdkPixbufAbstractParser(__ImageParser):
|
||||
class GdkPixbufAbstractParser(_ImageParser):
|
||||
""" GdkPixbuf can handle a lot of surfaces, so we're rending images on it,
|
||||
this has the side-effect of removing metadata completely.
|
||||
"""
|
||||
|
@ -222,7 +222,7 @@ class LibreOfficeParser(ArchiveBasedAbstractParser):
|
||||
'styles.xml',
|
||||
}
|
||||
files_to_omit = set(map(re.compile, { # type: ignore
|
||||
'^meta\.xml$',
|
||||
r'^meta\.xml$',
|
||||
'^Configurations2/',
|
||||
'^Thumbnails/',
|
||||
}))
|
||||
|
@ -37,10 +37,10 @@ def get_parser(filename: str) -> Tuple[Optional[T], Optional[str]]:
|
||||
if extension in unsupported_extensions:
|
||||
return None, mtype
|
||||
|
||||
for c in _get_parsers(): # type: ignore
|
||||
if mtype in c.mimetypes:
|
||||
for parser_class in _get_parsers(): # type: ignore
|
||||
if mtype in parser_class.mimetypes:
|
||||
try:
|
||||
return c(filename), mtype
|
||||
return parser_class(filename), mtype
|
||||
except ValueError:
|
||||
return None, mtype
|
||||
return None, mtype
|
||||
|
@ -83,7 +83,9 @@ class PDFParser(abstract.AbstractParser):
|
||||
page_width, page_height = page.get_size()
|
||||
logging.info("Rendering page %d/%d", pagenum + 1, pages_count)
|
||||
|
||||
img_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, int(page_width) * self.__scale, int(page_height) * self.__scale)
|
||||
width = int(page_width) * self.__scale
|
||||
height = int(page_height) * self.__scale
|
||||
img_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
|
||||
img_context = cairo.Context(img_surface)
|
||||
|
||||
img_context.scale(self.__scale, self.__scale)
|
||||
|
@ -125,7 +125,7 @@ class _BencodeHandler(object):
|
||||
try:
|
||||
r, l = self.__decode_func[s[0]](s)
|
||||
except (IndexError, KeyError, ValueError) as e:
|
||||
logging.debug("Not a valid bencoded string: %s" % e)
|
||||
logging.debug("Not a valid bencoded string: %s", e)
|
||||
return None
|
||||
if l != b'':
|
||||
logging.debug("Invalid bencoded value (data after valid prefix)")
|
||||
|
Loading…
Reference in New Issue
Block a user