diff --git a/pyxform/aliases.py b/pyxform/aliases.py index ede93c6f..a0c41677 100644 --- a/pyxform/aliases.py +++ b/pyxform/aliases.py @@ -180,3 +180,17 @@ "username", ] osm = {"osm": constants.OSM_TYPE} +BINDING_CONVERSIONS = { + "yes": "true()", + "Yes": "true()", + "YES": "true()", + "true": "true()", + "True": "true()", + "TRUE": "true()", + "no": "false()", + "No": "false()", + "NO": "false()", + "false": "false()", + "False": "false()", + "FALSE": "false()", +} diff --git a/pyxform/builder.py b/pyxform/builder.py index a4bc8928..3bd01e1c 100644 --- a/pyxform/builder.py +++ b/pyxform/builder.py @@ -75,7 +75,6 @@ def copy_json_dict(json_dict): class SurveyElementBuilder: - # we use this CLASSES dict to create questions from dictionaries def __init__(self, **kwargs): # I don't know why we would need an explicit none option for diff --git a/pyxform/constants.py b/pyxform/constants.py index f3821e44..0730350e 100644 --- a/pyxform/constants.py +++ b/pyxform/constants.py @@ -148,20 +148,6 @@ class EntityColumns(StrEnum): "becomes '_setting'." ) -BINDING_CONVERSIONS = { - "yes": "true()", - "Yes": "true()", - "YES": "true()", - "true": "true()", - "True": "true()", - "TRUE": "true()", - "no": "false()", - "No": "false()", - "NO": "false()", - "false": "false()", - "False": "false()", - "FALSE": "false()", -} CONVERTIBLE_BIND_ATTRIBUTES = ( "readonly", "required", diff --git a/pyxform/survey_element.py b/pyxform/survey_element.py index 2076e268..73394aeb 100644 --- a/pyxform/survey_element.py +++ b/pyxform/survey_element.py @@ -7,6 +7,7 @@ from functools import lru_cache from typing import TYPE_CHECKING, Any, ClassVar, Dict, List +from pyxform import aliases as alias from pyxform import constants as const from pyxform.errors import PyXFormError from pyxform.question_type_dictionary import QUESTION_TYPE_DICT @@ -443,10 +444,10 @@ def xml_bindings(self): # the xls2json side. if ( hashable(v) - and v in const.BINDING_CONVERSIONS + and v in alias.BINDING_CONVERSIONS and k in const.CONVERTIBLE_BIND_ATTRIBUTES ): - v = const.BINDING_CONVERSIONS[v] + v = alias.BINDING_CONVERSIONS[v] if k == "jr:constraintMsg" and ( isinstance(v, dict) or re.search(BRACKETED_TAG_REGEX, v) ):