Skip to content

Commit

Permalink
fix(backend): use latest pyxform syntax for xlsform conversion (fix x…
Browse files Browse the repository at this point in the history
…ls ext usage) (#1789)

* build: upgrade pyxform to latest 2.1.0

* fix(backend): use latest pyxform syntax for xlsform conversion (fix xls ext usage)
  • Loading branch information
spwoodcock authored Sep 17, 2024
1 parent 01e9fd6 commit 5c117d6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
18 changes: 3 additions & 15 deletions src/backend/app/central/central_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
from fastapi import HTTPException
from loguru import logger as log
from osm_fieldwork.OdkCentral import OdkAppUser, OdkForm, OdkProject
from pyxform.builder import create_survey_element_from_dict
from pyxform.xls2json import parse_file_to_json
from pyxform.xls2xform import convert as xform_convert
from sqlalchemy import text
from sqlalchemy.orm import Session

Expand Down Expand Up @@ -387,19 +386,8 @@ async def read_and_test_xform(
) from e
else:
try:
log.debug("Converting xlsform -> xform")
json_data = parse_file_to_json(
path=f"/dummy/path/with/file{file_ext}",
file_object=input_data,
)
generated_xform = create_survey_element_from_dict(json_data)
# NOTE do not enable validate=True, as this requires Java to be installed
xform_bytesio = BytesIO(
generated_xform.to_xml(
validate=False,
pretty_print=False,
).encode("utf-8")
)
log.debug("Parsing XLSForm --> XML data")
xform_bytesio = BytesIO(xform_convert(input_data).xform.encode("utf-8"))
except Exception as e:
log.error(e)
msg = f"XLSForm is invalid: {str(e)}"
Expand Down
18 changes: 9 additions & 9 deletions src/backend/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies = [
"geoalchemy2==0.15.2",
"geojson==3.1.0",
"shapely==2.0.5",
"pyxform==2.0.3",
"pyxform==2.1.0",
"loguru==0.7.2",
"minio==7.2.7",
"pyproj==3.6.1",
Expand Down

0 comments on commit 5c117d6

Please sign in to comment.