# Path: pyxform/builder.py
# def copy_json_dict(json_dict):
#     def __init__(self, **kwargs):
#     def set_sections(self, sections):
#     def create_survey_element_from_dict(self, d):
#     def _save_trigger_as_setvalue_and_remove_calculate(self, d):
#     def _create_question_from_dict(d, question_type_dictionary, add_none_option=False):
#     def _add_other_option_to_multiple_choice_question(d):
#     def _add_none_option_to_select_all_that_apply(d_copy):
#     def _get_question_class(question_type_str, question_type_dictionary):
#     def _create_specify_other_question_from_dict(d):
#     def _create_section_from_dict(self, d):
#     def _create_loop_from_dict(self, d):
#     def _name_and_label_substitutions(self, question_template, column_headers):
#     def create_survey_element_from_json(self, str_or_path):
# def create_survey_element_from_dict(d, sections=None):
# def create_survey_element_from_json(str_or_path):
# 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,
# ):
# def create_survey_from_path(path, include_directory=False):
# class SurveyElementBuilder:
#     QUESTION_CLASSES = {
#         "": Question,
#         "action": Question,
#         "input": InputQuestion,
#         "odk:rank": MultipleChoiceQuestion,
#         "osm": OsmUploadQuestion,
#         "range": RangeQuestion,
#         "select": MultipleChoiceQuestion,
#         "select1": MultipleChoiceQuestion,
#         "trigger": TriggerQuestion,
#         "upload": UploadQuestion,
#     }
#     SECTION_CLASSES = {
#         "group": GroupedSection,
#         "repeat": RepeatingSection,
#         "survey": Survey,
#     }
# 
# Path: pyxform/utils.py
# NSMAP = {
#     "xmlns": "http://www.w3.org/2002/xforms",
#     "xmlns:h": "http://www.w3.org/1999/xhtml",
#     "xmlns:ev": "http://www.w3.org/2001/xml-events",
#     "xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
#     "xmlns:jr": "http://openrosa.org/javarosa",
#     "xmlns:orx": "http://openrosa.org/xforms",
#     "xmlns:odk": "http://www.opendatakit.org/xforms",
# }


import codecs
import copy
import json
import logging
import re
import xml.etree.ElementTree as ETree
from operator import itemgetter
from pyxform import builder
from pyxform.utils import NSMAP
                    if not updated:
                        child["children"].append(question)
            if "ref" not in question:
                new_ref = "/".join(ref.split("/")[2:])
                root_ref = "/".join(ref.split("/")[:2])
                q = self._get_item_func(root_ref, new_ref, item)
                if "type" not in q and "type" in question:
                    q.update(question)
                if q["type"] == "group" and q["name"] == "meta":
                    q["control"] = {"bodyless": True}
                    q["__order"] = self._get_question_order(ref)
                self.children.append(q)
                self._bind_list.append(item)
                break
        if self._bind_list:
            self._cleanup_bind_list()

    def _get_item_func(self, ref, name, item):
        rs = {}
        name_splits = name.split("/")
        rs["name"] = name_splits[0]
        ref = "%s/%s" % (ref, rs["name"])
        rs["ref"] = ref
        if name_splits.__len__() > 1:
            rs["type"] = "group"
            rs["children"] = [self._get_item_func(ref, "/".join(name_splits[1:]), item)]
        return rs

    def survey(self):
        new_doc = json.dumps(self.new_doc)

# Path: pyxform/builder.py
# def copy_json_dict(json_dict):
#     def __init__(self, **kwargs):
#     def set_sections(self, sections):
#     def create_survey_element_from_dict(self, d):
#     def _save_trigger_as_setvalue_and_remove_calculate(self, d):
#     def _create_question_from_dict(d, question_type_dictionary, add_none_option=False):
#     def _add_other_option_to_multiple_choice_question(d):
#     def _add_none_option_to_select_all_that_apply(d_copy):
#     def _get_question_class(question_type_str, question_type_dictionary):
#     def _create_specify_other_question_from_dict(d):
#     def _create_section_from_dict(self, d):
#     def _create_loop_from_dict(self, d):
#     def _name_and_label_substitutions(self, question_template, column_headers):
#     def create_survey_element_from_json(self, str_or_path):
# def create_survey_element_from_dict(d, sections=None):
# def create_survey_element_from_json(str_or_path):
# 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,
# ):
# def create_survey_from_path(path, include_directory=False):
# class SurveyElementBuilder:
#     QUESTION_CLASSES = {
#         "": Question,
#         "action": Question,
#         "input": InputQuestion,
#         "odk:rank": MultipleChoiceQuestion,
#         "osm": OsmUploadQuestion,
#         "range": RangeQuestion,
#         "select": MultipleChoiceQuestion,
#         "select1": MultipleChoiceQuestion,
#         "trigger": TriggerQuestion,
#         "upload": UploadQuestion,
#     }
#     SECTION_CLASSES = {
#         "group": GroupedSection,
#         "repeat": RepeatingSection,
#         "survey": Survey,
#     }
# 
# Path: pyxform/utils.py
# NSMAP = {
#     "xmlns": "http://www.w3.org/2002/xforms",
#     "xmlns:h": "http://www.w3.org/1999/xhtml",
#     "xmlns:ev": "http://www.w3.org/2001/xml-events",
#     "xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
#     "xmlns:jr": "http://openrosa.org/javarosa",
#     "xmlns:orx": "http://openrosa.org/xforms",
#     "xmlns:odk": "http://www.opendatakit.org/xforms",
# }


# Path: pyxform/xform2json.py
import codecs
import copy
import json
import logging
import re
import xml.etree.ElementTree as ETree
from operator import itemgetter
from pyxform import builder
from pyxform.utils import NSMAP

                    if not updated:
                        child["children"].append(question)
            if "ref" not in question:
                new_ref = "/".join(ref.split("/")[2:])
                root_ref = "/".join(ref.split("/")[:2])
                q = self._get_item_func(root_ref, new_ref, item)
                if "type" not in q and "type" in question:
                    q.update(question)
                if q["type"] == "group" and q["name"] == "meta":
                    q["control"] = {"bodyless": True}
                    q["__order"] = self._get_question_order(ref)
                self.children.append(q)
                self._bind_list.append(item)
                break
        if self._bind_list:
            self._cleanup_bind_list()

    def _get_item_func(self, ref, name, item):
        rs = {}
        name_splits = name.split("/")
        rs["name"] = name_splits[0]
        ref = "%s/%s" % (ref, rs["name"])
        rs["ref"] = ref
        if name_splits.__len__() > 1:
            rs["type"] = "group"
            rs["children"] = [self._get_item_func(ref, "/".join(name_splits[1:]), item)]
        return rs

    def survey(self):
        new_doc = json.dumps(self.new_doc)

        _survey = builder.create_survey_element_from_json(new_doc)