Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

603: Always generate secondary instance for selects #614

Merged
merged 20 commits into from
Jul 31, 2023
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
faaf52a
wip: initial impl changes and test fixes - 27 tests still broken
lindsay-stevens Jun 10, 2022
ae54917
fix: error created but not raised
lindsay-stevens Jul 20, 2022
4fa1f7d
fix: avoid output of duplicate translations, json dump, tests
lindsay-stevens Jul 20, 2022
ff31a6f
fix: lint
lindsay-stevens Jul 20, 2022
66f8838
fix: remove unused xpath expressions
lindsay-stevens Jul 20, 2022
df4e01e
fix: upgrade fixture-based test for instance_xmlns setting
lindsay-stevens Jul 21, 2022
0683836
fix: formatting
lindsay-stevens Jul 21, 2022
7807e88
fix: import error due to local name vs. package namespaced name
lindsay-stevens Jul 21, 2022
f6df5b2
fix: translation test using incorrect test name param
lindsay-stevens Apr 20, 2023
1238bd6
fix: xform2json choice filters support, minor codestyle improvements
lindsay-stevens May 1, 2023
c7caf44
add: type annotations
lindsay-stevens May 3, 2023
e5e21f5
fix: import path, add base method for non-question SurveyElement
lindsay-stevens May 3, 2023
c93d0a1
fix: remove debug output in some tests
lindsay-stevens May 4, 2023
48c6f8e
fix: update comments in _setup_choice_translations for current behaviour
lindsay-stevens May 5, 2023
42d7fd1
fix: exclude select with appearance=search() from itemset, test updates
lindsay-stevens May 5, 2023
acd7640
fix: minor correctness / off-by-one error in excel data processing
lindsay-stevens May 5, 2023
2adb257
fix: tests for new itemset output for selects, add xls2json type hints
lindsay-stevens May 5, 2023
b23d704
fix: translation tests failing due to itemset changes
lindsay-stevens May 11, 2023
c2dd549
fix: test failure on Windows due to file encoding not specified in test
lindsay-stevens May 11, 2023
751e4ea
fix: support of or_other with selects in itemsets
lindsay-stevens May 12, 2023
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
15 changes: 7 additions & 8 deletions pyxform/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import copy
import os
import re
from typing import Any, Dict, Optional

from pyxform import file_utils, utils
from pyxform.entities.entity_declaration import EntityDeclaration
Expand Down Expand Up @@ -338,12 +339,11 @@ def create_survey_from_xls(path_or_file, default_name=None):


def create_survey(
name_of_main_section=None,
sections=None,
main_section=None,
id_string=None,
title=None,
default_language=None,
name_of_main_section: str = None,
sections: Dict[str, Dict] = None,
main_section: Dict[str, Any] = None,
id_string: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id_string seems like it shouldn't be optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sprinkled on this type annotation to help understand data flow. The id_string (and perhaps other params) could be mandatory, but then it seemed to make sense to refactor the body of the function to remove is None checks, etc., which could easily snowball into more refactoring.

title: Optional[str] = None,
) -> Survey:
"""
name_of_main_section -- a string key used to find the main section in the
Expand Down Expand Up @@ -380,11 +380,10 @@ def create_survey(

if title is not None:
survey.title = title
survey.def_lang = default_language
return survey


def create_survey_from_path(path, include_directory=False) -> Survey:
def create_survey_from_path(path: str, include_directory: bool = False) -> Survey:
"""
include_directory -- Switch to indicate that all the survey forms in the
same directory as the specified file should be read
Expand Down