pylint work regarding rstrip arguments. closes #98

This commit is contained in:
jevans 2013-08-05 20:39:39 -04:00
commit 19f5ae6a46
3 changed files with 6 additions and 3 deletions

View file

@ -1792,14 +1792,14 @@ class XMLBox(Jp2kBox):
text = read_buffer.decode('utf-8')
# Strip out any trailing nulls, as they can foul up XML parsing.
text = text.rstrip('\0')
text = text.rstrip(chr(0))
try:
elt = ET.fromstring(text)
xml = ET.ElementTree(elt)
except ParseError as parse_error:
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))
warnings.warn(msg, UserWarning)
xml = None

View file

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

View file

@ -7,6 +7,7 @@ import struct
import sys
import tempfile
import uuid
from xml.etree import cElementTree as ET
if sys.hexversion < 0x02070000:
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].offset, 77)
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")
def test_asoc_label_box(self):