Browse Source

Fix XML attribute lookups.

The more Pythonic syntax seems to cause problems with
Python 2.
snapgene-write
Damien Goutte-Gattat 3 years ago
parent
commit
12bb37c0ac
  1. 8
      incenp/bio/seqio/SnapGeneIO.py

8
incenp/bio/seqio/SnapGeneIO.py

@ -136,11 +136,11 @@ def _parse_features_segment(length, data, record):
error="Missing qualifier name")
qvalues = []
for value in qualifier.getElementsByTagName('V'):
if 'text' in value.attributes:
if value.hasAttribute('text'):
qvalues.append(_decode(value.attributes['text'].value))
elif 'predef' in value.attributes:
elif value.hasAttribute('predef'):
qvalues.append(_decode(value.attributes['predef'].value))
elif 'int' in value.attributes:
elif value.hasAttribute('int'):
qvalues.append(int(value.attributes['int'].value))
quals[qname] = qvalues
@ -187,7 +187,7 @@ def _decode(text):
return sub('<[^>]+>', '', text).encode('ascii', 'ignore')
def _get_attribute_value(node, name, default=None, error=None):
if name in node.attributes:
if node.hasAttribute(name):
return _decode(node.attributes[name].value)
elif error:
raise ValueError(error)

Loading…
Cancel
Save