pylint work. #104

This commit is contained in:
John Evans 2014-01-24 15:56:50 -05:00
commit c8f6aff4d8
9 changed files with 111 additions and 108 deletions

View file

@ -18,7 +18,8 @@ else:
# if the version is at least 2.0.0. # if the version is at least 2.0.0.
try: try:
import libxmp import libxmp
if hasattr(libxmp, 'version') and re.match('[2-9].\d*.\d*', libxmp.version.VERSION): if hasattr(libxmp, 'version') and re.match(r"""[2-9].\d*.\d*""",
libxmp.version.VERSION):
from libxmp import XMPMeta from libxmp import XMPMeta
_HAS_PYTHON_XMP_TOOLKIT = True _HAS_PYTHON_XMP_TOOLKIT = True
else: else:

View file

@ -19,7 +19,6 @@ import os
import pprint import pprint
import struct import struct
import sys import sys
import traceback
import uuid import uuid
import warnings import warnings
import xml.etree.cElementTree as ET import xml.etree.cElementTree as ET
@ -563,11 +562,11 @@ class CodestreamHeaderBox(Jp2kBox):
box : list box : list
List of boxes contained in this superbox. List of boxes contained in this superbox.
""" """
def __init__(self, box=[], length=0, offset=-1): def __init__(self, box=None, length=0, offset=-1):
Jp2kBox.__init__(self, box_id='jpch', longname='Codestream Header') Jp2kBox.__init__(self, box_id='jpch', longname='Codestream Header')
self.length = length self.length = length
self.offset = offset self.offset = offset
self.box = box self.box = box if box is not None else []
def __repr__(self): def __repr__(self):
msg = "glymur.jp2box.CodestreamHeaderBox(box={0})".format(self.box) msg = "glymur.jp2box.CodestreamHeaderBox(box={0})".format(self.box)
@ -625,12 +624,12 @@ class CompositingLayerHeaderBox(Jp2kBox):
box : list box : list
List of boxes contained in this superbox. List of boxes contained in this superbox.
""" """
def __init__(self, box=[], length=0, offset=-1): def __init__(self, box=None, length=0, offset=-1):
Jp2kBox.__init__(self, box_id='jplh', Jp2kBox.__init__(self, box_id='jplh',
longname='Compositing Layer Header') longname='Compositing Layer Header')
self.length = length self.length = length
self.offset = offset self.offset = offset
self.box = [] self.box = box if box is not None else []
def __repr__(self): def __repr__(self):
msg = "glymur.jp2box.CompositingLayerHeaderBox(box={0})" msg = "glymur.jp2box.CompositingLayerHeaderBox(box={0})"
@ -1073,11 +1072,11 @@ class AssociationBox(Jp2kBox):
box : list box : list
List of boxes contained in this superbox. List of boxes contained in this superbox.
""" """
def __init__(self, box=[], length=0, offset=-1): def __init__(self, box=None, length=0, offset=-1):
Jp2kBox.__init__(self, box_id='asoc', longname='Association') Jp2kBox.__init__(self, box_id='asoc', longname='Association')
self.length = length self.length = length
self.offset = offset self.offset = offset
self.box = box self.box = box if box is not None else []
def __repr__(self): def __repr__(self):
msg = "glymur.jp2box.AssociationBox(box={0})".format(self.box) msg = "glymur.jp2box.AssociationBox(box={0})".format(self.box)
@ -1135,11 +1134,11 @@ class JP2HeaderBox(Jp2kBox):
box : list box : list
List of boxes contained in this superbox. List of boxes contained in this superbox.
""" """
def __init__(self, box=[], length=0, offset=-1): def __init__(self, box=None, length=0, offset=-1):
Jp2kBox.__init__(self, box_id='jp2h', longname='JP2 Header') Jp2kBox.__init__(self, box_id='jp2h', longname='JP2 Header')
self.length = length self.length = length
self.offset = offset self.offset = offset
self.box = box self.box = box if box is not None else []
def __repr__(self): def __repr__(self):
msg = "glymur.jp2box.JP2HeaderBox(box={0})".format(self.box) msg = "glymur.jp2box.JP2HeaderBox(box={0})".format(self.box)
@ -1621,11 +1620,11 @@ class ResolutionBox(Jp2kBox):
box : list box : list
List of boxes contained in this superbox. List of boxes contained in this superbox.
""" """
def __init__(self, box=[], length=0, offset=-1): def __init__(self, box=None, length=0, offset=-1):
Jp2kBox.__init__(self, box_id='res ', longname='Resolution') Jp2kBox.__init__(self, box_id='res ', longname='Resolution')
self.length = length self.length = length
self.offset = offset self.offset = offset
self.box = box self.box = box if box is not None else []
def __repr__(self): def __repr__(self):
msg = "glymur.jp2box.ResolutionBox(box={0})" msg = "glymur.jp2box.ResolutionBox(box={0})"
@ -2040,11 +2039,11 @@ class UUIDInfoBox(Jp2kBox):
box : list box : list
List of boxes contained in this superbox. List of boxes contained in this superbox.
""" """
def __init__(self, box=[], length=0, offset=-1): def __init__(self, box=None, length=0, offset=-1):
Jp2kBox.__init__(self, box_id='uinf', longname='UUIDInfo') Jp2kBox.__init__(self, box_id='uinf', longname='UUIDInfo')
self.length = length self.length = length
self.offset = offset self.offset = offset
self.box = box self.box = box if box is not None else []
def __repr__(self): def __repr__(self):
msg = "glymur.jp2box.UUIDInfoBox(box={0})".format(self.box) msg = "glymur.jp2box.UUIDInfoBox(box={0})".format(self.box)
@ -2214,8 +2213,8 @@ class UUIDBox(Jp2kBox):
try: try:
self._parse_raw_data() self._parse_raw_data()
except Exception as e: except RuntimeError as error:
warnings.warn(str(e)) warnings.warn(str(error))
def _parse_raw_data(self): def _parse_raw_data(self):
""" """

View file

@ -15,7 +15,8 @@ import glymur
# if the version is at least 2.0.0. # if the version is at least 2.0.0.
try: try:
import libxmp import libxmp
if hasattr(libxmp, 'version') and re.match('[2-9].\d*.\d*', libxmp.version.VERSION): if hasattr(libxmp, 'version') and re.match(r'''[2-9].\d*.\d*''',
libxmp.version.VERSION):
from libxmp import XMPMeta from libxmp import XMPMeta
HAS_PYTHON_XMP_TOOLKIT = True HAS_PYTHON_XMP_TOOLKIT = True
else: else:

View file

@ -894,9 +894,9 @@ class TestRepr(unittest.TestCase):
tree = ET.ElementTree(elt) tree = ET.ElementTree(elt)
box = glymur.jp2box.XMLBox(xml=tree) box = glymur.jp2box.XMLBox(xml=tree)
regexp = "glymur.jp2box.XMLBox" regexp = r"""glymur.jp2box.XMLBox"""
regexp += "\(xml=<(xml.etree.ElementTree.){0,1}ElementTree object " regexp += r"""\(xml=<(xml.etree.ElementTree.){0,1}ElementTree object """
regexp += "at 0x([a-f0-9]*)>\)" regexp += """at 0x([a-f0-9]*)>\)"""
if sys.hexversion < 0x03000000: if sys.hexversion < 0x03000000:
self.assertRegexpMatches(repr(box), regexp) self.assertRegexpMatches(repr(box), regexp)
@ -927,9 +927,9 @@ class TestRepr(unittest.TestCase):
# Since the raw_data parameter is a sequence of bytes which could be # Since the raw_data parameter is a sequence of bytes which could be
# quite long, don't bother trying to make it conform to eval(repr()). # quite long, don't bother trying to make it conform to eval(repr()).
regexp = "glymur.jp2box.UUIDBox\(" regexp = r"""glymur.jp2box.UUIDBox\("""
regexp += "the_uuid=UUID\('00000000-0000-0000-0000-000000000000'\),\s" regexp += """the_uuid=UUID\('00000000-0000-0000-0000-000000000000'\),\s"""
regexp += "raw_data=<byte\sarray\s10\selements>\)" regexp += """raw_data=<byte\sarray\s10\selements>\)"""
if sys.hexversion < 0x03000000: if sys.hexversion < 0x03000000:
self.assertRegexpMatches(repr(box), regexp) self.assertRegexpMatches(repr(box), regexp)

View file

@ -1,10 +1,12 @@
# This file is part of glymur, a Python interface for accessing JPEG 2000. """
# This file is part of glymur, a Python interface for accessing JPEG 2000.
# http://glymur.readthedocs.org
# http://glymur.readthedocs.org
# Copyright 2013 John Evans
# Copyright 2013 John Evans
# License: MIT
License: MIT
"""
import sys import sys
import numpy as np import numpy as np