Skip to content

Commit

Permalink
better workaround for jpylyzer output parsing problem under Python 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsgalore committed Oct 19, 2017
1 parent e5b3511 commit 261810f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions jprofile/jprofile.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,26 @@ def extractJpylyzer(resultJpylyzer):

outString=""
validationOutcome = resultJpylyzer.find("isValidJP2").text

if validationOutcome == "False":
testsElt = resultJpylyzer.find("tests")

# Locate test elements
# testsElt = resultJpylyzer.find("tests")

# For some strange reason above statement returns 'None' under
# Python 3! Workaround: find it by iterating over resultJpylyzer

for element in resultJpylyzer.iter():
if element.tag == "tests":
testsElt = element

outString += "*** Jpylyzer JP2 validation errors:" \
+ config.lineSep

# Iterate over tests element and report names of all
# tags thatcorrespond to tests that failed

# TODO: for some strange reason 'testsElt' is None under Python 3!
# iterating over root element behaves as expected, so we'll just
# do this as a workaround
# tests = list(testsElt.iter())
tests = list(resultJpylyzer.iter())
tests = list(testsElt.iter())

for j in tests:
if j.text == "False":
Expand Down

0 comments on commit 261810f

Please sign in to comment.