Merge branch 'issue98' into devel

This commit is contained in:
jevans 2013-08-05 20:42:35 -04:00
commit f33ea6dedb
5 changed files with 11 additions and 8 deletions

View file

@ -1792,14 +1792,14 @@ class XMLBox(Jp2kBox):
text = read_buffer.decode('utf-8') text = read_buffer.decode('utf-8')
# Strip out any trailing nulls, as they can foul up XML parsing. # Strip out any trailing nulls, as they can foul up XML parsing.
text = text.rstrip('\0') text = text.rstrip(chr(0))
try: try:
elt = ET.fromstring(text) elt = ET.fromstring(text)
xml = ET.ElementTree(elt) xml = ET.ElementTree(elt)
except ParseError as parse_error: except ParseError as parse_error:
msg = 'A problem was encountered while parsing an XML box:' msg = 'A problem was encountered while parsing an XML box:'
msg += '\n\n\t"{0}"\n\nNo XML was retrieved.' msg += '\n\n\t"{0}"\n\nNo XML was retrieved.'
msg = msg.format(str(parse_error)) msg = msg.format(str(parse_error))
warnings.warn(msg, UserWarning) warnings.warn(msg, UserWarning)
xml = None xml = None

View file

@ -57,7 +57,7 @@ def read_pgx(pgx_file):
header += chr(char[0]) header += chr(char[0])
header = header.rstrip() header = header.rstrip()
tokens = re.split('\s', header) tokens = re.split(r'\s', header)
if (tokens[1][0] == 'M') and (sys.byteorder == 'little'): if (tokens[1][0] == 'M') and (sys.byteorder == 'little'):
swapbytes = True swapbytes = True

View file

@ -88,7 +88,7 @@ class TestCallbacks15(unittest.TestCase):
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
d = j.read(rlevel=1, verbose=True) d = j.read(rlevel=1, verbose=True)
actual = fake_out.getvalue().strip() actual = fake_out.getvalue().strip()
regex = re.compile(r"""\[INFO\]\stile\s1\sof\s1\s+ regex = re.compile(r"""\[INFO\]\stile\s1\sof\s1\s+
\[INFO\]\s-\stiers-1\stook\s \[INFO\]\s-\stiers-1\stook\s
[0-9]+\.[0-9]+\ss\s+ [0-9]+\.[0-9]+\ss\s+

View file

@ -7,6 +7,7 @@ import struct
import sys import sys
import tempfile import tempfile
import uuid import uuid
from xml.etree import cElementTree as ET
if sys.hexversion < 0x02070000: if sys.hexversion < 0x02070000:
import unittest2 as unittest import unittest2 as unittest
@ -623,6 +624,8 @@ class TestJp2k(unittest.TestCase):
self.assertEqual(jp2k.box[3].box_id, 'xml ') self.assertEqual(jp2k.box[3].box_id, 'xml ')
self.assertEqual(jp2k.box[3].offset, 77) self.assertEqual(jp2k.box[3].offset, 77)
self.assertEqual(jp2k.box[3].length, 36) self.assertEqual(jp2k.box[3].length, 36)
self.assertEqual(ET.tostring(jp2k.box[3].xml.getroot()),
b'<test>this is a test</test>')
@unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows") @unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows")
def test_asoc_label_box(self): def test_asoc_label_box(self):

View file

@ -3809,7 +3809,7 @@ class TestSuiteDump(unittest.TestCase):
32, 32, 131, 2002, 2002, 1888]) 32, 32, 131, 2002, 2002, 1888])
self.assertEqual(c.segment[3]._exponent, self.assertEqual(c.segment[3]._exponent,
[17, 17, 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, [17, 17, 17, 17, 16, 16, 16, 15, 15, 15, 14, 14,
14, 13, 13, 13, 11, 11, 11, 11, 11, 11]) 14, 13, 13, 13, 11, 11, 11, 11, 11, 11])
# COM: comment # COM: comment
# Registration # Registration
@ -4596,10 +4596,10 @@ class TestSuiteDump(unittest.TestCase):
self.assertEqual(c.segment[7].sqcc & 0x1f, 2) # none self.assertEqual(c.segment[7].sqcc & 0x1f, 2) # none
self.assertEqual(c.segment[7]._mantissa, self.assertEqual(c.segment[7]._mantissa,
[1824, 1776, 1776, 1728, 1792, 1792, 1760, 1872, [1824, 1776, 1776, 1728, 1792, 1792, 1760, 1872,
1872, 1896, 5, 5, 71, 2003, 2003, 1890]) 1872, 1896, 5, 5, 71, 2003, 2003, 1890])
self.assertEqual(c.segment[7]._exponent, self.assertEqual(c.segment[7]._exponent,
[18, 18, 18, 18, 17, 17, 17, 16, 16, 16, 14, 14, [18, 18, 18, 18, 17, 17, 17, 16, 16, 16, 14, 14,
14, 14, 14, 14]) 14, 14, 14, 14])
# COM: comment # COM: comment
# Registration # Registration
@ -5634,7 +5634,7 @@ class TestSuiteDump(unittest.TestCase):
self.assertEqual(c.segment[3]._mantissa, [0] * 16) self.assertEqual(c.segment[3]._mantissa, [0] * 16)
self.assertEqual(c.segment[3]._exponent, self.assertEqual(c.segment[3]._exponent,
[18, 19, 19, 20, 19, 19, 20, 19, 19, 20, 19, 19, 20, [18, 19, 19, 20, 19, 19, 20, 19, 19, 20, 19, 19, 20,
19, 19, 20]) 19, 19, 20])
# COM: comment # COM: comment
# Registration # Registration