Lint fixes

This commit is contained in:
Andrew Murray 2019-08-12 19:42:32 +10:00
parent 1b626f4d22
commit 524933aa1d

View File

@ -569,12 +569,24 @@ class ImageFileDirectory_v2(MutableMapping):
else: else:
self.tagtype[tag] = TiffTags.UNDEFINED self.tagtype[tag] = TiffTags.UNDEFINED
if all(isinstance(v, IFDRational) for v in values): if all(isinstance(v, IFDRational) for v in values):
self.tagtype[tag] = TiffTags.RATIONAL if all(v >= 0 for v in values) else TiffTags.SIGNED_RATIONAL self.tagtype[tag] = (
TiffTags.RATIONAL
if all(v >= 0 for v in values)
else TiffTags.SIGNED_RATIONAL
)
elif all(isinstance(v, int) for v in values): elif all(isinstance(v, int) for v in values):
if all(v < 2 ** 16 for v in values): if all(v < 2 ** 16 for v in values):
self.tagtype[tag] = TiffTags.SHORT if all(v >= 0 for v in values) else TiffTags.SIGNED_SHORT self.tagtype[tag] = (
TiffTags.SHORT
if all(v >= 0 for v in values)
else TiffTags.SIGNED_SHORT
)
else: else:
self.tagtype[tag] = TiffTags.LONG if all(v >= 0 for v in values) else TiffTags.SIGNED_LONG self.tagtype[tag] = (
TiffTags.LONG
if all(v >= 0 for v in values)
else TiffTags.SIGNED_LONG
)
elif all(isinstance(v, float) for v in values): elif all(isinstance(v, float) for v in values):
self.tagtype[tag] = TiffTags.DOUBLE self.tagtype[tag] = TiffTags.DOUBLE
else: else:
@ -744,7 +756,8 @@ class ImageFileDirectory_v2(MutableMapping):
@_register_writer(10) @_register_writer(10)
def write_signed_rational(self, *values): def write_signed_rational(self, *values):
return b"".join( return b"".join(
self._pack("2l", *_limit_signed_rational(frac, 2 ** 31 - 1, -2 ** 31)) for frac in values self._pack("2l", *_limit_signed_rational(frac, 2 ** 31 - 1, -2 ** 31))
for frac in values
) )
def _ensure_read(self, fp, size): def _ensure_read(self, fp, size):