Skip to content

Commit 28c341d

Browse files
committed
[#198][#200] Require lxml
Note that lxml is now "required" - it's listed as a requirement in setup.py and is needed for the tests to pass. However, stdlib etree still exists as an unsupported feature.
1 parent c0c73b6 commit 28c341d

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ python:
55
- "3.3"
66
- "3.4"
77
- "3.5"
8-
env:
9-
- INSTALL_LXML=true
10-
- INSTALL_LXML=false
118
# Apparently six must be installed first, otherwise setup.py will be unhappy
129
install:
1310
- pip install six
1411
- pip install --upgrade -r requirements_dev.txt
15-
- if [ \"$INSTALL_LXML\" == \"true\" ]; then pip install lxml; fi
1612
script: py.test --cov .
1713
after_success: coveralls

examples/iati/expected.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<iati-activities><!--XML generated by flatten-tool--><iati-activity><iati-identifier>AA-AAA-123456789-ABC123</iati-identifier><reporting-org ref="AA-AAA-123456789" type="40"><narrative>Organisation name</narrative></reporting-org><participating-org ref="AA-AAA-123456789" role="1"></participating-org><activity-status code="2"></activity-status><activity-date iso-date="2011-10-01" type="1"></activity-date><recipient-country code="AF" percentage="40"></recipient-country><recipient-country code="XK" percentage="60"></recipient-country><title><narrative>A title</narrative></title><description><narrative>A description</narrative></description><transaction><transaction-type code="2"></transaction-type><transaction-date iso-date="2012-01-01"></transaction-date><value value-date="2012-01-01">10</value></transaction><transaction><transaction-type code="3"></transaction-type><transaction-date iso-date="2012-03-03"></transaction-date><value value-date="2012-03-03">20</value></transaction></iati-activity><iati-activity><iati-identifier>AA-AAA-123456789-ABC124</iati-identifier><reporting-org ref="AA-AAA-123456789" type="40"><narrative>Organisation name</narrative></reporting-org><participating-org ref="AA-AAA-123456789" role="1"></participating-org><activity-status code="3"></activity-status><activity-date iso-date="2016-01-01" type="2"></activity-date><recipient-country code="AG" percentage="30"></recipient-country><recipient-country code="XK" percentage="70"></recipient-country><title><narrative>Another title</narrative></title><description><narrative>Another description</narrative></description><transaction><transaction-type code="2"></transaction-type><transaction-date iso-date="2013-04-04"></transaction-date><value value-date="2013-04-04">30</value></transaction><transaction><transaction-type code="3"></transaction-type><transaction-date iso-date="2013-05-05"></transaction-date><value value-date="2013-05-05">40</value></transaction></iati-activity></iati-activities>
1+
<iati-activities><!--XML generated by flatten-tool--><iati-activity><iati-identifier>AA-AAA-123456789-ABC123</iati-identifier><reporting-org ref="AA-AAA-123456789" type="40"><narrative>Organisation name</narrative></reporting-org><participating-org ref="AA-AAA-123456789" role="1"/><activity-status code="2"/><activity-date iso-date="2011-10-01" type="1"/><recipient-country code="AF" percentage="40"/><recipient-country code="XK" percentage="60"/><title><narrative>A title</narrative></title><description><narrative>A description</narrative></description><transaction><transaction-type code="2"/><transaction-date iso-date="2012-01-01"/><value value-date="2012-01-01">10</value></transaction><transaction><transaction-type code="3"/><transaction-date iso-date="2012-03-03"/><value value-date="2012-03-03">20</value></transaction></iati-activity><iati-activity><iati-identifier>AA-AAA-123456789-ABC124</iati-identifier><reporting-org ref="AA-AAA-123456789" type="40"><narrative>Organisation name</narrative></reporting-org><participating-org ref="AA-AAA-123456789" role="1"/><activity-status code="3"/><activity-date iso-date="2016-01-01" type="2"/><recipient-country code="AG" percentage="30"/><recipient-country code="XK" percentage="70"/><title><narrative>Another title</narrative></title><description><narrative>Another description</narrative></description><transaction><transaction-type code="2"/><transaction-date iso-date="2013-04-04"/><value value-date="2013-04-04">30</value></transaction><transaction><transaction-type code="3"/><transaction-date iso-date="2013-05-05"/><value value-date="2013-05-05">40</value></transaction></iati-activity></iati-activities>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<iati-organisations><!--XML generated by flatten-tool--><iati-organisation><organisation-identifier>AA-AAA-123456789</organisation-identifier><reporting-org ref="AA-AAA-123456789" secondary-reporter="0" type="40"></reporting-org></iati-organisation></iati-organisations>
1+
<iati-organisations><!--XML generated by flatten-tool--><iati-organisation><organisation-identifier>AA-AAA-123456789</organisation-identifier><reporting-org ref="AA-AAA-123456789" secondary-reporter="0" type="40"/></iati-organisation></iati-organisations>

flattentool/xml_output.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from collections import OrderedDict
2+
from warnings import warn
23
try:
34
import lxml.etree as ET
45
# If we're using lxml we have to do some extra work to support namespaces,
56
# so we have a variable to check whether we're using lxml:
67
USING_LXML = True
8+
# Note that lxml is now "required" - it's listed as a requirement in
9+
# setup.py and is needed for the tests to pass.
10+
# However, stdlib etree still exists as an unsupported feature.
711
except ImportError:
812
import xml.etree.ElementTree as ET
913
USING_LXML = False
10-
from warnings import warn
14+
warn('Using stdlib etree may work, but is not supported. Please install lxml.')
1115
from flattentool.exceptions import DataErrorWarning
1216

1317

@@ -74,4 +78,4 @@ def toxml(data, xml_root_tag):
7478
root = dict_to_xml(data, xml_root_tag, nsmap=nsmap)
7579
comment = ET.Comment('XML generated by flatten-tool')
7680
root.insert(0, comment)
77-
return ET.tostring(root, method='html')
81+
return ET.tostring(root)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup
22
import sys
33

4-
install_requires = ['jsonref', 'schema', 'openpyxl>=2.5', 'six', 'pytz', 'xmltodict']
4+
install_requires = ['jsonref', 'schema', 'openpyxl>=2.5', 'six', 'pytz', 'xmltodict', 'lxml']
55

66
if sys.version < '3':
77
install_requires.append('unicodecsv')

0 commit comments

Comments
 (0)