pep8 work.
This commit is contained in:
parent
517faeb1e4
commit
62e7afa118
5 changed files with 25 additions and 18 deletions
|
|
@ -119,7 +119,6 @@ and add it after the JP2 header box, but before the codestream box ::
|
|||
. (truncated)
|
||||
.
|
||||
|
||||
|
||||
Work with XMP UUIDs?
|
||||
====================
|
||||
The example JP2 file shipped with glymur has an XMP UUID. ::
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ def nemo():
|
|||
file = pkg_resources.resource_filename(__name__, "nemo.jp2")
|
||||
return file
|
||||
|
||||
|
||||
def goodstuff():
|
||||
"""Shortcut for specifying path to goodstuff.j2k.
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ class ColourSpecificationBox(Jp2kBox):
|
|||
msg += "colorspaces is not supported at this time."
|
||||
raise NotImplementedError(msg)
|
||||
length = 15 if self.icc_profile is None else 11 + len(self.icc_profile)
|
||||
f.write(struct.pack('>I', length))
|
||||
f.write(struct.pack('>I', length))
|
||||
f.write('colr'.encode())
|
||||
|
||||
buffer = struct.pack('>BBBI',
|
||||
|
|
@ -806,12 +806,12 @@ class ImageHeaderBox(Jp2kBox):
|
|||
def _write(self, f):
|
||||
"""Write an Image Header box to file.
|
||||
"""
|
||||
f.write(struct.pack('>I', 22))
|
||||
f.write(struct.pack('>I', 22))
|
||||
f.write('ihdr'.encode())
|
||||
|
||||
# signedness and bps are stored together in a single byte
|
||||
bit_depth_signedness = 0x80 if self.signed else 0x00
|
||||
bit_depth_signedness |= self.bits_per_component - 1
|
||||
bit_depth_signedness |= self.bits_per_component - 1
|
||||
buffer = struct.pack('>IIHBBBB',
|
||||
self.height,
|
||||
self.width,
|
||||
|
|
@ -960,7 +960,7 @@ class JP2HeaderBox(Jp2kBox):
|
|||
"""
|
||||
# Write the contained boxes, then come back and write the length.
|
||||
orig_pos = f.tell()
|
||||
f.write(struct.pack('>I', 0))
|
||||
f.write(struct.pack('>I', 0))
|
||||
f.write('jp2h'.encode())
|
||||
for box in self.box:
|
||||
box._write(f)
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ class TestChannelDefinition(unittest.TestCase):
|
|||
# Write the first component back out to file.
|
||||
with tempfile.NamedTemporaryFile(suffix=".j2k", delete=False) as tfile:
|
||||
grey_j2k = Jp2k(tfile.name, 'wb')
|
||||
grey_j2k.write(data[:,:,0])
|
||||
grey_j2k.write(data[:, :, 0])
|
||||
cls.one_plane = tfile.name
|
||||
# Write the first two components back out to file.
|
||||
with tempfile.NamedTemporaryFile(suffix=".j2k", delete=False) as tfile:
|
||||
grey_j2k = Jp2k(tfile.name, 'wb')
|
||||
grey_j2k.write(data[:,:,0:1])
|
||||
grey_j2k.write(data[:, :, 0:1])
|
||||
cls.two_planes = tfile.name
|
||||
# Write four components back out to file.
|
||||
with tempfile.NamedTemporaryFile(suffix=".j2k", delete=False) as tfile:
|
||||
|
|
@ -58,13 +58,13 @@ class TestChannelDefinition(unittest.TestCase):
|
|||
height = c.segment[1].Ysiz
|
||||
width = c.segment[1].Xsiz
|
||||
num_components = len(c.segment[1].XRsiz)
|
||||
|
||||
|
||||
self.jP = JPEG2000SignatureBox()
|
||||
self.ftyp = FileTypeBox()
|
||||
self.jp2h = JP2HeaderBox()
|
||||
self.jp2c = ContiguousCodestreamBox()
|
||||
self.ihdr = ImageHeaderBox(height=height, width=width,
|
||||
num_components=num_components)
|
||||
num_components=num_components)
|
||||
self.colr_rgb = ColourSpecificationBox(colorspace=glymur.core.SRGB)
|
||||
self.colr_gr = ColourSpecificationBox(colorspace=glymur.core.GREYSCALE)
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ class TestChannelDefinition(unittest.TestCase):
|
|||
"""A greyscale image with alpha layer must specify Y"""
|
||||
j2k = Jp2k(self.two_planes)
|
||||
|
||||
# This cdef box
|
||||
# This cdef box
|
||||
cdef = glymur.jp2box.ChannelDefinitionBox(index=[0, 1],
|
||||
channel_type=[1, 1],
|
||||
association=[0, 1])
|
||||
|
|
@ -228,6 +228,7 @@ class TestChannelDefinition(unittest.TestCase):
|
|||
channel_type=[0, 0],
|
||||
association=[1, 2, 3])
|
||||
|
||||
|
||||
class TestXML(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
|
@ -258,7 +259,7 @@ class TestXML(unittest.TestCase):
|
|||
</country>
|
||||
</data>"""
|
||||
with tempfile.NamedTemporaryFile(suffix=".xml", delete=False) as tfile:
|
||||
tfile.write(raw_xml)
|
||||
tfile.write(raw_xml)
|
||||
tfile.flush()
|
||||
self.xmlfile = tfile.name
|
||||
|
||||
|
|
@ -267,13 +268,13 @@ class TestXML(unittest.TestCase):
|
|||
height = c.segment[1].Ysiz
|
||||
width = c.segment[1].Xsiz
|
||||
num_components = len(c.segment[1].XRsiz)
|
||||
|
||||
|
||||
self.jP = JPEG2000SignatureBox()
|
||||
self.ftyp = FileTypeBox()
|
||||
self.jp2h = JP2HeaderBox()
|
||||
self.jp2c = ContiguousCodestreamBox()
|
||||
self.ihdr = ImageHeaderBox(height=height, width=width,
|
||||
num_components=num_components)
|
||||
num_components=num_components)
|
||||
self.colr = ColourSpecificationBox(colorspace=glymur.core.SRGB)
|
||||
|
||||
def tearDown(self):
|
||||
|
|
@ -340,13 +341,13 @@ class TestColourSpecificationBox(unittest.TestCase):
|
|||
height = c.segment[1].Ysiz
|
||||
width = c.segment[1].Xsiz
|
||||
num_components = len(c.segment[1].XRsiz)
|
||||
|
||||
|
||||
self.jP = JPEG2000SignatureBox()
|
||||
self.ftyp = FileTypeBox()
|
||||
self.jp2h = JP2HeaderBox()
|
||||
self.jp2c = ContiguousCodestreamBox()
|
||||
self.ihdr = ImageHeaderBox(height=height, width=width,
|
||||
num_components=num_components)
|
||||
num_components=num_components)
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
|
@ -444,7 +445,7 @@ class TestJp2Boxes(unittest.TestCase):
|
|||
|
||||
def verify_wrapped_raw(self, jp2file):
|
||||
# Shared method by at least two tests.
|
||||
jp2 = Jp2k(jp2file)
|
||||
jp2 = Jp2k(jp2file)
|
||||
self.assertEqual(len(jp2.box), 4)
|
||||
|
||||
self.assertEqual(jp2.box[0].id, 'jP ')
|
||||
|
|
@ -497,6 +498,13 @@ class TestJp2Boxes(unittest.TestCase):
|
|||
j2k.wrap(tfile.name)
|
||||
self.verify_wrapped_raw(tfile.name)
|
||||
|
||||
def test_wrap_jp2(self):
|
||||
j2k = Jp2k(self.j2kfile)
|
||||
with tempfile.NamedTemporaryFile(suffix=".jp2") as tfile:
|
||||
jp2 = j2k.wrap(tfile.name)
|
||||
boxes = [box.id for box in jp2.box]
|
||||
self.assertEqual(boxes, ['jP ', 'ftyp', 'jp2h', 'jp2c'])
|
||||
|
||||
def test_default_layout_but_with_specified_boxes(self):
|
||||
j2k = Jp2k(self.j2kfile)
|
||||
boxes = [JPEG2000SignatureBox(),
|
||||
|
|
@ -534,7 +542,6 @@ class TestJp2Boxes(unittest.TestCase):
|
|||
with self.assertRaises(IOError):
|
||||
j2k.wrap(tfile.name, boxes=boxes)
|
||||
|
||||
|
||||
def test_first_2_boxes_not_jP_and_ftyp(self):
|
||||
j2k = Jp2k(self.j2kfile)
|
||||
c = j2k.get_codestream()
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class TestJp2k(unittest.TestCase):
|
|||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
||||
ofile = Jp2k(tfile.name, 'wb')
|
||||
with self.assertRaises(IOError):
|
||||
ofile.write(expdata[:,:,0], mct=True)
|
||||
ofile.write(expdata[:, :, 0], mct=True)
|
||||
|
||||
def test_write_cprl(self):
|
||||
# Issue 17
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue