当前位置: 首页>>代码示例>>Python>>正文


Python utils.node函数代码示例

本文整理汇总了Python中utils.node函数的典型用法代码示例。如果您正苦于以下问题:Python node函数的具体用法?Python node怎么用?Python node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: xml_hint

 def xml_hint(self):
     if type(self.get_hint()) == dict:
         d = self.get_translation_keys()
         return node(u"hint", ref="jr:itext('%s')" % d[u"hint"])
     else:
         hint, outputInserted = self.get_root().insert_output_values(self.get_hint())
         return node(u"hint", hint, toParseString=outputInserted)
开发者ID:ChandniD,项目名称:pyxform,代码行数:7,代码来源:survey_element.py

示例2: xml_control

    def xml_control(self):
        """
        <group>
        <label>Fav Color</label>
        <repeat nodeset="fav-color">
          <select1 ref=".">
            <label ref="jr:itext('fav')" />
            <item><label ref="jr:itext('red')" /><value>red</value></item>
            <item><label ref="jr:itext('green')" /><value>green</value></item>
            <item><label ref="jr:itext('yellow')" /><value>yellow</value></item>
          </select1>
        </repeat>
        </group>
        """
        control_dict = self.control
        kwargs = {}
        if u"jr:count" in self and self[u"jr:count"] != "":
            kwargs = {u"jr:count": self[u"jr:count"]}
        if u"appearance" in control_dict:
            repeat_node = node(u"repeat", nodeset=self.get_xpath(), appearance=control_dict[u"appearance"], **kwargs)
        else:
            repeat_node = node(u"repeat", nodeset=self.get_xpath(), **kwargs)
        for n in Section.xml_control(self):
            repeat_node.appendChild(n)

        label = self.xml_label()
        if label:
            return node(u"group", self.xml_label(), repeat_node, ref=self.get_xpath())
        return node(u"group", repeat_node, ref=self.get_xpath())
开发者ID:Topol,项目名称:pyxform,代码行数:29,代码来源:section.py

示例3: xml_hint

 def xml_hint(self):
     if type(self.hint) == dict:
         path = self._translation_path("hint")
         return node(u"hint", ref="jr:itext('%s')" % path)
     else:
         hint, outputInserted = self.get_root().insert_output_values(self.hint)
         return node(u"hint", hint, toParseString=outputInserted)
开发者ID:bderenzi,项目名称:pyxform,代码行数:7,代码来源:survey_element.py

示例4: xml_control

    def xml_control(self):
        assert self.bind[u"type"] in [u"select", u"select1"]
        survey = self.get_root()
        control_dict = self.control.copy()
        # Resolve field references in attributes
        for key, value in control_dict.items():
            control_dict[key] = survey.insert_xpaths(value)
        control_dict['ref'] = self.get_xpath()

        result = node(**control_dict)
        for element in self.xml_label_and_hint():
            result.appendChild(element)
        # itemset are only supposed to be strings,
        # check to prevent the rare dicts that show up
        if self['itemset'] and isinstance(self['itemset'], basestring):
            choice_filter = self.get('choice_filter')
            nodeset = "instance('" + self['itemset'] + "')/root/item"
            choice_filter = survey.insert_xpaths(choice_filter)
            if choice_filter:
                nodeset += '[' + choice_filter + ']'
            itemset_label_ref = "jr:itext(itextId)"
            itemset_children = [node('value', ref='name'),
                                node('label', ref=itemset_label_ref)]
            result.appendChild(node('itemset', *itemset_children,
                                    nodeset=nodeset))
        else:
            for n in [o.xml() for o in self.children]:
                result.appendChild(n)
        return result
开发者ID:alxndrsn,项目名称:pyxform,代码行数:29,代码来源:question.py

示例5: xml_control

    def xml_control(self):
        """
        <group>
        <label>Fav Color</label>
        <repeat nodeset="fav-color">
          <select1 ref=".">
            <label ref="jr:itext('fav')" />
            <item><label ref="jr:itext('red')" /><value>red</value></item>
            <item><label ref="jr:itext('green')" /><value>green</value></item>
            <item><label ref="jr:itext('yellow')" /><value>yellow</value></item>
          </select1>
        </repeat>
        </group>
        """
        control_dict = self.control.copy()
        jrcount = control_dict.get('jr:count')
        if jrcount:
            survey = self.get_root()
            control_dict['jr:count'] = survey.insert_xpaths(jrcount)
        repeat_node = node(u"repeat", nodeset=self.get_xpath(), **control_dict)

        for n in Section.xml_control(self):
            repeat_node.appendChild(n)

        label = self.xml_label()
        if label:
            return node(
                u"group", self.xml_label(), repeat_node,
                ref=self.get_xpath()
                )
        return node(u"group", repeat_node, ref=self.get_xpath())
开发者ID:andreasmitrou,项目名称:pyxform,代码行数:31,代码来源:section.py

示例6: xml_control

    def xml_control(self):
        """
        <group>
        <label>Fav Color</label>
        <repeat nodeset="fav-color">
          <select1 ref=".">
            <label ref="jr:itext('fav')" />
            <item><label ref="jr:itext('red')" /><value>red</value></item>
            <item><label ref="jr:itext('green')" /><value>green</value></item>
            <item><label ref="jr:itext('yellow')" /><value>yellow</value></item>
          </select1>
        </repeat>
        </group>
        """
        control_dict = self.control.copy()
        survey = self.get_root()
        # Resolve field references in attributes
        for key, value in control_dict.items():
            control_dict[key] = survey.insert_xpaths(value)
        repeat_node = node(u"repeat", nodeset=self.get_xpath(), **control_dict)

        for n in Section.xml_control(self):
            repeat_node.appendChild(n)

        label = self.xml_label()
        if label:
            return node(
                u"group", self.xml_label(), repeat_node,
                ref=self.get_xpath()
                )
        return node(u"group", repeat_node, ref=self.get_xpath(), **self.control)
开发者ID:Cadasta,项目名称:cadasta-provider-ona,代码行数:31,代码来源:section.py

示例7: xml_model

    def xml_model(self):
        """
        Generate the xform <model> element
        """
        self._setup_translations()
        self._setup_media()
        self._add_empty_translations()

        model_children = []
        if self._translations:
            model_children.append(self.itext())
        model_children += [node("instance", self.xml_instance())]
        model_children += list(self._generate_static_instances())
        model_children += list(self._generate_pulldata_instances())
        model_children += self.xml_bindings()

        if self.submission_url or self.public_key:
            submission_attrs = dict()
            if self.submission_url:
                submission_attrs["action"] = self.submission_url
            if self.public_key:
                submission_attrs["base64RsaPublicKey"] = self.public_key
            submission_node = node("submission", method="form-data-post",
                                   **submission_attrs)
            model_children.insert(0, submission_node)

        return node("model",  *model_children)
开发者ID:henriquechehad,项目名称:pyxform,代码行数:27,代码来源:survey.py

示例8: _generate_static_instances

    def _generate_static_instances(self):
        """
        Generates <instance> elements for static data
        (e.g. choices for select type questions)
        """
        for list_name, choice_list in self.choices.items():
            instance_element_list = []
            for idx, choice in zip(range(len(choice_list)), choice_list):
                choice_element_list = []
                # Add a unique id to the choice element incase there is itext
                # it refrences
                itextId = '-'.join(['static_instance', list_name, str(idx)])
                choice_element_list.append(node("itextId", itextId))

                for choicePropertyName, choicePropertyValue in choice.items():
                    if isinstance(choicePropertyValue, basestring) \
                            and choicePropertyName != 'label':
                        choice_element_list.append(
                            node(choicePropertyName,
                                 unicode(choicePropertyValue))
                        )
                instance_element_list.append(node("item",
                                                  *choice_element_list))
            yield node("instance", node("root", *instance_element_list),
                       id=list_name)
开发者ID:henriquechehad,项目名称:pyxform,代码行数:25,代码来源:survey.py

示例9: xml_label

 def xml_label(self):
     if self.needs_itext_ref():
         #If there is a dictionary label, or non-empty media dict, then we need to make a label with an itext ref
         ref = "jr:itext('%s')" % self._translation_path(u"label")
         return node(u"label", ref=ref)
     else:
         survey = self.get_root()
         label, outputInserted = survey.insert_output_values(self.label)
         return node(u"label", label, toParseString=outputInserted)
开发者ID:bderenzi,项目名称:pyxform,代码行数:9,代码来源:survey_element.py

示例10: xml_instance

 def xml_instance(self):
     result = Section.xml_instance(self)
     result.setAttribute(u"id", self.id_string)
     
     #We need to add a unique form instance id if the form is to be submitted.
     if self.submission_url:
         result.appendChild(node("orx:meta", node("orx:instanceID")))
         
     return result
开发者ID:Topol,项目名称:pyxform,代码行数:9,代码来源:survey.py

示例11: xml_label

    def xml_label(self):
        if not self.get_label() and not self.get(self.TYPE) == "group"and len(self.get('media')) == 0:
            return None

        if type(self.get_label()) == dict or not len(self.get('media')) == 0:
            if len(self.get_label()) == 0 and self.get(self.TYPE) == "group":
                return None
            return node(u"label", ref="jr:itext('%s')" % self._translation_path(u"label"))
        else:
            label, outputInserted = self.get_root().insert_output_values(self.get_label())
            return node(u"label", label, toParseString=outputInserted)
开发者ID:ChandniD,项目名称:pyxform,代码行数:11,代码来源:survey_element.py

示例12: xml_instance

 def xml_instance(self):
     survey = self.get_root()
     attributes = {}
     attributes.update(self.get(u'instance', {}))
     for key, value in attributes.items():
         attributes[key] = survey.insert_xpaths(value)
     if self.get(u"default"):
         return node(
             self.name, unicode(self.get(u"default")), **attributes
         )
     return node(self.name, **attributes)
开发者ID:alxndrsn,项目名称:pyxform,代码行数:11,代码来源:question.py

示例13: xml_translations

 def xml_translations(self):
     result = []
     for lang in self._translations.keys():
         result.append( node("translation", lang=lang) )
         for name in self._translations[lang].keys():
             result[-1].appendChild(
                 node("text",
                     node("value", self._translations[lang][name]),
                     id=name
                     )
                 )
     return node("itext", *result)
开发者ID:aptivate,项目名称:pyxform,代码行数:12,代码来源:survey.py

示例14: xml_model

 def xml_model(self):
     self._setup_translations()
     if self._translations:
         return node("model",
                     self.xml_translations(),
                     node("instance", self.xml_instance()),
                     *self.xml_bindings()
                     )
     return node("model",
                 node("instance", self.xml_instance()),
                 *self.xml_bindings()
                 )
开发者ID:aptivate,项目名称:pyxform,代码行数:12,代码来源:survey.py

示例15: _generate_from_file_instances

 def _generate_from_file_instances(self):
     for i in self.iter_descendants():
         itemset = i.get('itemset')
         if itemset and \
                 (itemset.endswith('.csv') or itemset.endswith('.xml')):
             file_id, file_extension = os.path.splitext(itemset)
             yield node(
                 "instance",
                 node("root", node("item", node("name"), node("label"))),
                 id=file_id,
                 src="jr://file-%s/%s" % (file_extension[1:], itemset)
             )
开发者ID:onaio,项目名称:pyxform,代码行数:12,代码来源:survey.py


注:本文中的utils.node函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。