Skip to content

Commit 38542a7

Browse files
Merge pull request #854 from lindsay-stevens/pyxform-711
711: remove support for enketo-validate
2 parents 8cee912 + 70cfdf7 commit 38542a7

14 files changed

Lines changed: 197 additions & 425 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pyxform
22

3-
`pyxform` is a Python library that simplifies writing forms for ODK Collect and Enketo by converting spreadsheets that follow the [XLSForm standard](http://xlsform.org/) into [ODK XForms](https://github.com/opendatakit/xforms-spec). The XLSForms format is used in a [number of tools](http://xlsform.org/en/#tools-that-support-xlsforms).
3+
`pyxform` is a Python library that simplifies writing forms for ODK Collect, ODK Web Forms, and Enketo by converting spreadsheets that follow the [XLSForm standard](http://xlsform.org/) into [ODK XForms](https://github.com/opendatakit/xforms-spec). The XLSForms format is used in a [number of tools](http://xlsform.org/en/#tools-that-support-xlsforms).
44

55
## Project status
66

pyxform/survey.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
escape_text_for_xml,
2828
node,
2929
)
30-
from pyxform.validators import enketo_validate, odk_validate
30+
from pyxform.validators import odk_validate
3131
from pyxform.validators.pyxform import unique_names
3232
from pyxform.validators.pyxform.iana_subtags.validation import get_languages_with_bad_tags
3333
from pyxform.validators.pyxform.pyxform_reference import (
@@ -1206,7 +1206,7 @@ def _var_repl_output_function(matchobj):
12061206
return text, False
12071207

12081208
def print_xform_to_file(
1209-
self, path=None, validate=True, pretty_print=True, warnings=None, enketo=False
1209+
self, path=None, validate=True, pretty_print=True, warnings=None
12101210
) -> str:
12111211
"""
12121212
Print the xForm to a file and optionally validate it as well by
@@ -1229,8 +1229,6 @@ def print_xform_to_file(
12291229
raise
12301230
if validate:
12311231
warnings.extend(odk_validate.check_xform(path))
1232-
if enketo:
1233-
warnings.extend(enketo_validate.check_xform(path))
12341232

12351233
# Warn if one or more translation is missing a valid IANA subtag
12361234
translations = self._translations
@@ -1246,15 +1244,15 @@ def print_xform_to_file(
12461244
)
12471245
return xml
12481246

1249-
def to_xml(self, validate=True, pretty_print=True, warnings=None, enketo=False):
1247+
def to_xml(self, validate=True, pretty_print=True, warnings=None):
12501248
"""
1251-
Generates the XForm XML.
1252-
validate is True by default - pass the XForm XML through ODK Validator.
1253-
pretty_print is True by default - formats the XML for readability.
1254-
warnings - if a list is passed it stores all warnings generated
1255-
enketo - pass the XForm XML though Enketo Validator.
1249+
Generate the XForm XML.
12561250
1257-
Return XForm XML string.
1251+
:param validate: True by default - pass the XForm XML through ODK Validator.
1252+
:param pretty_print: True by default - formats the XML for readability.
1253+
:param warnings: if a list is passed it stores all warnings generated
1254+
1255+
:returns: XForm XML string.
12581256
"""
12591257
# On Windows, NamedTemporaryFile must be opened exclusively.
12601258
# So it must be explicitly created, opened, closed, and removed.
@@ -1268,7 +1266,6 @@ def to_xml(self, validate=True, pretty_print=True, warnings=None, enketo=False):
12681266
validate=validate,
12691267
pretty_print=pretty_print,
12701268
warnings=warnings,
1271-
enketo=enketo,
12721269
)
12731270
finally:
12741271
tmp_path.unlink(missing_ok=True)

pyxform/validators/enketo_validate/__init__.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

pyxform/validators/error_cleaner.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,3 @@ def odk_validate(error_message):
6666
java_clean = [ErrorCleaner._remove_java_content(i) for i in common]
6767
final_message = ErrorCleaner._join_final(java_clean)
6868
return final_message
69-
70-
@staticmethod
71-
def enketo_validate(error_message):
72-
common = ErrorCleaner._cleanup_errors(error_message)
73-
final_message = ErrorCleaner._join_final(common)
74-
return final_message

pyxform/validators/updater.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from zipfile import ZipFile, is_zipfile
1313

1414
from pyxform.errors import PyXFormError
15-
from pyxform.validators import enketo_validate, odk_validate
15+
from pyxform.validators import odk_validate
1616
from pyxform.validators.util import HERE, CapturingHandler, request_get
1717

1818
UTC_FMT = "%Y-%m-%dT%H:%M:%SZ"
@@ -483,25 +483,6 @@ def _install_check(bin_file_path=None):
483483
raise NotImplementedError()
484484

485485

486-
class EnketoValidateUpdater(_UpdateService):
487-
def __init__(self):
488-
self.update_info = _UpdateInfo(
489-
api_url="https://api.github.com/repos/enketo/enketo-validate/releases/latest",
490-
repo_url="https://github.com/enketo/enketo-validate",
491-
validate_subfolder="enketo_validate",
492-
install_check=self._install_check,
493-
validator_basename=os.path.basename(enketo_validate.ENKETO_VALIDATE_PATH),
494-
)
495-
496-
@staticmethod
497-
def _install_check(bin_file_path=None):
498-
if bin_file_path is None:
499-
return enketo_validate.install_ok()
500-
else:
501-
extracted = os.path.join(os.path.dirname(bin_file_path), "validate")
502-
return enketo_validate.install_ok(bin_file_path=extracted)
503-
504-
505486
class ODKValidateUpdater(_UpdateService):
506487
def __init__(self):
507488
self.update_info = _UpdateInfo(
@@ -561,8 +542,8 @@ def _create_parser():
561542
"------------------------------------------------------\n"
562543
"Use this tool to update external validators.\n\n"
563544
"Example usage:\n\n"
564-
"updater.py enketo list\n"
565-
"updater.py enketo update linux.zip\n\n"
545+
"updater.py ODK list\n"
546+
"updater.py ODK update linux.zip\n\n"
566547
"First, use the 'list' sub-command for the validator\n"
567548
"to check for a new release and to show what (if any) \n"
568549
"files are attached to it.\n\n"
@@ -576,11 +557,6 @@ def _create_parser():
576557
formatter_class=argparse.RawDescriptionHelpFormatter,
577558
)
578559
sub_parsers = main_parser.add_subparsers(metavar="<sub_menu>")
579-
_build_validator_menu(
580-
main_subparser=sub_parsers,
581-
validator_name="Enketo",
582-
updater_instance=EnketoValidateUpdater(),
583-
)
584560
_build_validator_menu(
585561
main_subparser=sub_parsers,
586562
validator_name="ODK",

pyxform/xls2xform.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def convert(
6565
warnings: list[str] | None = None,
6666
validate: bool = False,
6767
pretty_print: bool = False,
68-
enketo: bool = False,
6968
form_name: str | None = None,
7069
default_language: str | None = None,
7170
file_type: str | None = None,
@@ -75,10 +74,9 @@ def convert(
7574
7675
This function avoids result file IO so it is more suited to library usage of pyxform.
7776
78-
If validate=True or Enketo=True, then the XForm will be written to a temporary file
79-
to be checked by ODK Validate and/or Enketo Validate. These validators are run as
80-
external processes. A recent version of ODK Validate is distributed with pyxform,
81-
while Enketo Validate is not. A script to download or update these validators is
77+
If validate=True, then the XForm will be written to a temporary file to be checked by
78+
ODK Validate. This validator is run as an external process. A recent version of ODK
79+
Validate is distributed with pyxform. A script to download or update ODK Validate is
8280
provided in `validators/updater.py`.
8381
8482
:param xlsform: The input XLSForm file path or content. If the content is bytes or
@@ -87,7 +85,6 @@ def convert(
8785
:param warnings: The conversions warnings list.
8886
:param validate: If True, check the XForm with ODK Validate
8987
:param pretty_print: If True, format the XForm with spaces, line breaks, etc.
90-
:param enketo: If True, check the XForm with Enketo Validate.
9188
:param form_name: Used for the main instance root node name.
9289
:param default_language: The name of the default language for the form.
9390
:param file_type: If provided, attempt parsing the data only as this type. Otherwise,
@@ -113,7 +110,6 @@ def convert(
113110
validate=validate,
114111
pretty_print=pretty_print,
115112
warnings=warnings,
116-
enketo=enketo,
117113
)
118114
return ConvertResult(
119115
xform=xform,
@@ -129,14 +125,12 @@ def xls2xform_convert(
129125
xform_path: str | PathLike[str],
130126
validate: bool = True,
131127
pretty_print: bool = True,
132-
enketo: bool = False,
133128
) -> list[str]:
134129
warnings = []
135130
result = convert(
136131
xlsform=xlsform_path,
137132
validate=validate,
138133
pretty_print=pretty_print,
139-
enketo=enketo,
140134
warnings=warnings,
141135
)
142136
with open(xform_path, mode="w", encoding="utf-8") as f:
@@ -176,12 +170,6 @@ def _create_parser():
176170
default=False,
177171
help="Run the ODK Validate XForm external validator.",
178172
)
179-
parser.add_argument(
180-
"--enketo_validate",
181-
action="store_true",
182-
default=False,
183-
help="Run the Enketo Validate XForm external validator.",
184-
)
185173
parser.add_argument(
186174
"--pretty_print",
187175
action="store_true",
@@ -202,17 +190,13 @@ def _validator_args_logic(args):
202190
`xls2xform.py myform`: ODK only
203191
204192
**new**
205-
`xls2xform.py myform --enketo_validate`: Enketo only
206193
`xls2xform.py myform --odk_validate`: ODK only
207-
`xls2xform.py myform --enketo_validate --odk_validate`: both
208-
`xls2xform.py myform --enketo_validate --odk_validate --skip_validate`: no validators
194+
`xls2xform.py myform --odk_validate --skip_validate`: no validators
209195
"""
210196
if not args.skip_validate:
211197
args.odk_validate = False
212-
args.enketo_validate = False
213-
elif args.skip_validate and not (args.odk_validate or args.enketo_validate):
198+
elif args.skip_validate and not args.odk_validate:
214199
args.odk_validate = True
215-
args.enketo_validate = False
216200
return args
217201

218202

@@ -236,7 +220,6 @@ def main_cli():
236220
xform_path=args.output_path,
237221
validate=args.odk_validate,
238222
pretty_print=args.pretty_print,
239-
enketo=args.enketo_validate,
240223
)
241224

242225
response["code"] = 100
@@ -259,7 +242,6 @@ def main_cli():
259242
xform_path=args.output_path,
260243
validate=args.odk_validate,
261244
pretty_print=args.pretty_print,
262-
enketo=args.enketo_validate,
263245
)
264246
except OSError:
265247
# Do not crash if 'java' not installed

0 commit comments

Comments
 (0)