Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyxform/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"requiredmsg": ("bind", "jr:requiredMsg"),
"required_message": ("bind", "jr:requiredMsg"),
"body": "control",
constants.ENTITIES_SAVETO: ("bind", "entities:saveto"),
constants.ENTITIES_SAVETO: ("bind", constants.ENTITIES_SAVETO_NS),
}

entities_header = {constants.LIST_NAME_U: "dataset"}
Expand Down
11 changes: 6 additions & 5 deletions pyxform/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
from collections import defaultdict
from collections.abc import Mapping
from typing import Any

from pyxform import constants as const
Expand Down Expand Up @@ -65,7 +66,7 @@ def set_sections(self, sections):
the name of the section and the value is a dict that can be
used to create a whole survey.
"""
if not isinstance(sections, dict):
if not isinstance(sections, Mapping):
raise PyXFormError("""Invalid value for `sections`.""")
self._sections = sections

Expand All @@ -79,7 +80,7 @@ def create_survey_element_from_dict(

:param d: data to use for constructing SurveyElements.
"""
if "add_none_option" in d:
if d.get("add_none_option", None) is not None:
self._add_none_option = d["add_none_option"]

if d[const.TYPE] in SECTION_CLASSES:
Expand Down Expand Up @@ -266,7 +267,7 @@ def _name_and_label_substitutions(question_template, column_headers):
# if the label in column_headers has multiple languages setup a
# dictionary by language to do substitutions.
info_by_lang = None
if isinstance(column_headers[const.LABEL], dict):
if isinstance(column_headers[const.LABEL], Mapping):
info_by_lang = {
lang: {
const.NAME: column_headers[const.NAME],
Expand All @@ -279,10 +280,10 @@ def _name_and_label_substitutions(question_template, column_headers):
for key in result:
if isinstance(result[key], str):
result[key] %= column_headers
elif isinstance(result[key], dict):
elif isinstance(result[key], Mapping):
result[key] = result[key].copy()
for key2 in result[key]:
if info_by_lang and isinstance(column_headers[const.LABEL], dict):
if info_by_lang and isinstance(column_headers[const.LABEL], Mapping):
result[key][key2] %= info_by_lang.get(key2, column_headers)
else:
result[key][key2] %= column_headers
Expand Down
1 change: 1 addition & 0 deletions pyxform/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
TITLE = "title"
NAME = "name"
ENTITIES_SAVETO = "save_to"
ENTITIES_SAVETO_NS = "entities:saveto"
ID_STRING = "id_string"
SMS_KEYWORD = "sms_keyword"
SMS_FIELD = "sms_field"
Expand Down
Loading