From f176204b2cd914496133720ea7fb6cd2eeb5371b Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 27 Feb 2014 06:55:30 -0500 Subject: [PATCH 1/3] Updated requirements for lxml. #176 --- .travis.yml | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2f45864..c055dce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ before_install: # command to install dependencies install: - - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install --use-mirrors contextlib2 mock; fi - - if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then pip install --use-mirrors numpy; fi + - if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install --use-mirrors lxml contextlib2 mock; fi + - if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then pip install --use-mirrors lxml numpy; fi # command to run tests script: diff --git a/setup.py b/setup.py index b1332d8..41deb1a 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ kwargs = {'name': 'Glymur', 'license': 'MIT', 'test_suite': 'glymur.test'} -instllrqrs = ['numpy>=1.4.1'] +instllrqrs = ['lxml>=3.3', 'numpy>=1.4.1'] if sys.hexversion < 0x03030000: instllrqrs.append('contextlib2>=0.4') instllrqrs.append('mock>=1.0.1') From e8a0681a99ac9e12e19049c7cf307dad55eb9d09 Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 27 Feb 2014 11:07:02 -0500 Subject: [PATCH 2/3] Confirmed to work with lxml 3.2.3, down from 3.3. #176 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 41deb1a..7769392 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ kwargs = {'name': 'Glymur', 'license': 'MIT', 'test_suite': 'glymur.test'} -instllrqrs = ['lxml>=3.3', 'numpy>=1.4.1'] +instllrqrs = ['lxml>=3.2.3', 'numpy>=1.4.1'] if sys.hexversion < 0x03030000: instllrqrs.append('contextlib2>=0.4') instllrqrs.append('mock>=1.0.1') From 5943aa6c7a1ac63b366f965a541cac4ea5d391c5 Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 27 Feb 2014 18:48:48 -0500 Subject: [PATCH 3/3] Removed orphaned pretty print code for old element tree interface. #176 --- glymur/core.py | 42 ------------------------------------------ glymur/jp2box.py | 1 - 2 files changed, 43 deletions(-) diff --git a/glymur/core.py b/glymur/core.py index 30282f2..4e8f950 100644 --- a/glymur/core.py +++ b/glymur/core.py @@ -76,45 +76,3 @@ _CAPABILITIES_DISPLAY = { 1: '0', 2: '1', 3: '3'} - - -def _pretty_print_xml(xml, level=0): - """Pretty print XML data. - """ - #xml = copy.deepcopy(xml) - #_indent(xml.getroot(), level=level) - xmltext = ET.tostring(xml, encoding='utf-8').decode('utf-8') - - # Indent it a bit. - lst = [(' ' + x) for x in xmltext.split('\n')] - try: - xml = '\n'.join(lst) - return '\n{0}'.format(xml) - except UnicodeEncodeError: - # This can happen on python 2.x if the character set contains certain - # non-ascii characters. Just print out the corresponding xml char - # entities instead. - xml = u'\n'.join(lst) - text = u'\n{0}'.format(xml) - text = text.encode('ascii', 'xmlcharrefreplace') - return text - - -def _indent(elem, level=0): - """Recipe for pretty printing XML. Please see - - http://effbot.org/zone/element-lib.htm#prettyprint - """ - i = "\n" + level * " " - if len(elem): - if not elem.text or not elem.text.strip(): - elem.text = i + " " - if not elem.tail or not elem.tail.strip(): - elem.tail = i - for elem in elem: - _indent(elem, level + 1) - if not elem.tail or not elem.tail.strip(): - elem.tail = i - else: - if level and (not elem.tail or not elem.tail.strip()): - elem.tail = i diff --git a/glymur/jp2box.py b/glymur/jp2box.py index 192763f..b4cc803 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -32,7 +32,6 @@ from .core import _COLOR_TYPE_MAP_DISPLAY from .core import SRGB, GREYSCALE, YCC from .core import ENUMERATED_COLORSPACE, RESTRICTED_ICC_PROFILE from .core import ANY_ICC_PROFILE, VENDOR_COLOR_METHOD -from .core import _pretty_print_xml from . import _uuid_io