pep8 work

This commit is contained in:
John Evans 2013-07-25 15:55:15 -04:00
commit 4d00cca777
5 changed files with 10 additions and 12 deletions

View file

@ -140,7 +140,6 @@ class Codestream(object):
fptr.seek(self._tile_offset[-1] + self._tile_length[-1]) fptr.seek(self._tile_offset[-1] + self._tile_length[-1])
def _process_marker_segment(self, fptr, marker_id): def _process_marker_segment(self, fptr, marker_id):
"""Process and return a segment from the codestream. """Process and return a segment from the codestream.
""" """
@ -207,7 +206,8 @@ class Codestream(object):
segment = _parse_sot_segment(fptr) segment = _parse_sot_segment(fptr)
self._tile_offset.append(segment.offset) self._tile_offset.append(segment.offset)
if segment.psot == 0: if segment.psot == 0:
tile_part_length = self.offset + self.length - segment.offset - 2 tile_part_length = (self.offset + self.length -
segment.offset - 2)
else: else:
tile_part_length = segment.psot tile_part_length = segment.psot
self._tile_length.append(tile_part_length) self._tile_length.append(tile_part_length)

View file

@ -571,7 +571,7 @@ class CodestreamHeaderBox(Jp2kBox):
""" """
box = CodestreamHeaderBox(length=length, offset=offset) box = CodestreamHeaderBox(length=length, offset=offset)
# The codestream header box is a superbox, so go ahead and parse its # The codestream header box is a superbox, so go ahead and parse its
# child boxes. # child boxes.
box.box = box.parse_superbox(fptr) box.box = box.parse_superbox(fptr)

View file

@ -170,7 +170,7 @@ class Jp2k(Jp2kBox):
if ftyp.brand == 'jp2 ': if ftyp.brand == 'jp2 ':
jp2h = [box for box in self.box if box.box_id == 'jp2h'][0] jp2h = [box for box in self.box if box.box_id == 'jp2h'][0]
colrs = [box for box in jp2h.box if box.box_id == 'colr'] colrs = [box for box in jp2h.box if box.box_id == 'colr']
for colr in colrs: for colr in colrs:
if colr.method not in (ENUMERATED_COLORSPACE, if colr.method not in (ENUMERATED_COLORSPACE,
RESTRICTED_ICC_PROFILE): RESTRICTED_ICC_PROFILE):
msg = "Color Specification box method must specify either " msg = "Color Specification box method must specify either "
@ -178,7 +178,6 @@ class Jp2k(Jp2kBox):
msg += "profile if the file type box brand is 'jp2 '." msg += "profile if the file type box brand is 'jp2 '."
warnings.warn(msg) warnings.warn(msg)
# pylint: disable-msg=W0221 # pylint: disable-msg=W0221
def write(self, img_array, cratios=None, eph=False, psnr=None, numres=None, def write(self, img_array, cratios=None, eph=False, psnr=None, numres=None,
cbsize=None, psizes=None, grid_offset=None, sop=False, cbsize=None, psizes=None, grid_offset=None, sop=False,

View file

@ -46,7 +46,7 @@ class TestSuiteFormatCorpus(unittest.TestCase):
j2k = Jp2k(jfile) j2k = Jp2k(jfile)
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
c = j2k.get_codestream(header_only=False) c = j2k.get_codestream(header_only=False)
# The last segment is truncated, so there should not be an EOC marker. # The last segment is truncated, so there should not be an EOC marker.
self.assertNotEqual(c.segment[-1].marker_id, 'EOC') self.assertNotEqual(c.segment[-1].marker_id, 'EOC')
@ -61,7 +61,7 @@ class TestSuiteFormatCorpus(unittest.TestCase):
j2k = Jp2k(jfile) j2k = Jp2k(jfile)
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
c = j2k.get_codestream(header_only=False) c = j2k.get_codestream(header_only=False)
# The last segment is truncated, so there should not be an EOC marker. # The last segment is truncated, so there should not be an EOC marker.
self.assertNotEqual(c.segment[-1].marker_id, 'EOC') self.assertNotEqual(c.segment[-1].marker_id, 'EOC')
@ -76,7 +76,7 @@ class TestSuiteFormatCorpus(unittest.TestCase):
j2k = Jp2k(jfile) j2k = Jp2k(jfile)
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
c = j2k.get_codestream(header_only=False) c = j2k.get_codestream(header_only=False)
# The last segment is truncated, so there should not be an EOC marker. # The last segment is truncated, so there should not be an EOC marker.
self.assertNotEqual(c.segment[-1].marker_id, 'EOC') self.assertNotEqual(c.segment[-1].marker_id, 'EOC')
@ -91,7 +91,7 @@ class TestSuiteFormatCorpus(unittest.TestCase):
'balloon_eciRGBv2_ps_adobeplugin.jpf') 'balloon_eciRGBv2_ps_adobeplugin.jpf')
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
j2k = Jp2k(jfile) j2k = Jp2k(jfile)
def test_jp2_brand_vs_any_icc_profile_multiple_colr(self): def test_jp2_brand_vs_any_icc_profile_multiple_colr(self):
# Has colr box, one that conforms, one that does not. # Has colr box, one that conforms, one that does not.
@ -104,7 +104,7 @@ class TestSuiteFormatCorpus(unittest.TestCase):
jfile = os.path.join(*lst) jfile = os.path.join(*lst)
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
j2k = Jp2k(jfile) j2k = Jp2k(jfile)
@unittest.skipIf(opj_data_root is None, @unittest.skipIf(opj_data_root is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
@ -124,6 +124,6 @@ class TestSuiteOpj(unittest.TestCase):
'input/nonregression/text_GBR.jp2') 'input/nonregression/text_GBR.jp2')
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
j2k = Jp2k(filename) j2k = Jp2k(filename)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View file

@ -832,7 +832,6 @@ class TestSuite(unittest.TestCase):
data = Jp2k(jfile).read() data = Jp2k(jfile).read()
self.assertTrue(True) self.assertTrue(True)
@unittest.skipIf(sys.hexversion < 0x03020000, @unittest.skipIf(sys.hexversion < 0x03020000,
"Uses features introduced in 3.2.") "Uses features introduced in 3.2.")
def test_NR_DEC_broken3_jp2_6_decode(self): def test_NR_DEC_broken3_jp2_6_decode(self):