pylint work regarding rstrip arguments. closes #98
This commit is contained in:
parent
c6686e212a
commit
19f5ae6a46
3 changed files with 6 additions and 3 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue