Skip to content

Commit

Permalink
Cope with breaking changes in pyxform 3.0.0
Browse files Browse the repository at this point in the history
Beginning with XLSForm/pyxform#740, `SurveyElement` inherits from
`Mapping` instead of `dict`, and therefore has no `update()` method.

See XLSForm/pyxform@6918b40
  • Loading branch information
jnm committed Jan 22, 2025
1 parent 894d285 commit af724a2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/formpack/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,14 @@ def to_xml(self, warnings=None):
if title is None:
raise ValueError('cannot create xml on a survey with no title.')

survey.update(
{
'name': self.lookup('root_node_name', 'data'),
'id_string': self.lookup('id_string'),
'title': self.lookup('title'),
'version': self.lookup('id'),
}
)
# pyxform 3.0.0 has removed the ability to call `survey.update()`
# https://github.com/XLSForm/pyxform/commit/6918b400d3cf6c9151db2104137afe2c52dd68e4
for k, v in {
'name': self.lookup('root_node_name', 'data'),
'id_string': self.lookup('id_string'),
'title': self.lookup('title'),
'version': self.lookup('id'),
}.items():
survey[k] = v

return survey._to_pretty_xml() # .encode('utf-8')

0 comments on commit af724a2

Please sign in to comment.