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


Python xml_helpers.getXMLspace函数代码示例

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


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

示例1: getalttrans

    def getalttrans(self, origin=None):
        """Returns <alt-trans> for the given origin as a list of units. No
        origin means all alternatives.
        """
        translist = []
        for node in self.xmlelement.iterdescendants(self.namespaced("alt-trans")):
            if self.correctorigin(node, origin):
                # We build some mini units that keep the xmlelement. This
                # makes it easier to delete it if it is passed back to us.
                newunit = base.TranslationUnit(self.source)

                # the source tag is optional
                sourcenode = node.iterdescendants(self.namespaced("source"))
                try:
                    newunit.source = lisa.getText(next(sourcenode),
                                                  getXMLspace(node, self._default_xml_space))
                except StopIteration:
                    pass

                # must have one or more targets
                targetnode = node.iterdescendants(self.namespaced("target"))
                newunit.target = lisa.getText(next(targetnode),
                                              getXMLspace(node, self._default_xml_space))
                # TODO: support multiple targets better
                # TODO: support notes in alt-trans
                newunit.xmlelement = node

                translist.append(newunit)
        return translist
开发者ID:dwaynebailey,项目名称:translate,代码行数:29,代码来源:xliff.py

示例2: __eq__

 def __eq__(self, other):
     """Compares two units"""
     if not isinstance(other, LISAunit):
         return super(LISAunit, self).__eq__(other)
     languageNodes = self.getlanguageNodes()
     otherlanguageNodes = other.getlanguageNodes()
     if len(languageNodes) != len(otherlanguageNodes):
         return False
     for i in range(len(languageNodes)):
         mytext = self.getNodeText(languageNodes[i], getXMLspace(self.xmlelement, self._default_xml_space))
         othertext = other.getNodeText(otherlanguageNodes[i], getXMLspace(self.xmlelement, self._default_xml_space))
         if mytext != othertext:
             #TODO:^ maybe we want to take children and notes into account
             return False
     return True
开发者ID:lehmannro,项目名称:translate,代码行数:15,代码来源:lisa.py

示例3: _getnotelist

    def _getnotelist(self, origin=None):
        """Returns the text from notes matching ``origin`` or all notes.

        :param origin: The origin of the note (or note type)
        :type origin: String
        :return: The text from notes matching ``origin``
        :rtype: List
        """
        note_nodes = []
        if origin == 'pos':
            note_nodes = self.xmlelement.iterdescendants(self.namespaced("termNote"))
        elif origin == 'definition':
            note_nodes = self.xmlelement.iterdescendants(self.namespaced("descrip"))
        else:
            note_nodes = self.xmlelement.iterdescendants(self.namespaced("note"))
        # TODO: consider using xpath to construct initial_list directly
        # or to simply get the correct text from the outset (just remember to
        # check for duplication.
        initial_list = [lisa.getText(note,
                                     getXMLspace(self.xmlelement,
                                                 self._default_xml_space))
                        for note in note_nodes]

        # Remove duplicate entries from list:
        dictset = {}
        note_list = [dictset.setdefault(note, note) for note in initial_list if note not in dictset]

        return note_list
开发者ID:XLeonardo,项目名称:translate-1,代码行数:28,代码来源:tbx.py

示例4: gettarget

 def gettarget(self, lang=None):
     """retrieves the "target" text (second entry), or the entry in the
     specified language, if it exists
     """
     return self.getNodeText(self.get_target_dom(lang),
                             getXMLspace(self.xmlelement,
                                         self._default_xml_space))
开发者ID:diorcety,项目名称:translate,代码行数:7,代码来源:lisa.py

示例5: get_node_data

def get_node_data(unit, node):
    """Generic implementation of LISAUnit.gettarget."""
    # The language should be present as xml:lang, but in some
    # cases it's there only as lang
    return (
        getXMLlang(node) or node.get('lang'),
        unit.getNodeText(node, getXMLspace(unit.xmlelement, 'preserve'))
    )
开发者ID:dekoza,项目名称:weblate,代码行数:8,代码来源:storage.py

示例6: get_rich_target

 def get_rich_target(self, lang=None):
     """retrieves the "target" text (second entry), or the entry in the
     specified language, if it exists"""
     if self._rich_target is None:
         self._rich_target = [
             xml_to_strelem(self.get_target_dom(lang),
             getXMLspace(self.xmlelement, self._default_xml_space))
         ]
     return self._rich_target
开发者ID:anukat2015,项目名称:translate,代码行数:9,代码来源:xliff.py

示例7: get_rich_source

 def get_rich_source(self):
     #rsrc = xml_to_strelem(self.source_dom)
     #logging.debug('rich source: %s' % (repr(rsrc)))
     #from dubulib.debug.misc import print_stack_funcs
     #print_stack_funcs()
     return [
         xml_to_strelem(self.source_dom,
                        getXMLspace(self.xmlelement,
                                    self._default_xml_space))
     ]
开发者ID:dwaynebailey,项目名称:translate,代码行数:10,代码来源:xliff.py

示例8: getcontextgroups

 def getcontextgroups(self, name):
     """Returns the contexts in the context groups with the specified name"""
     groups = []
     grouptags = self.xmlelement.iterdescendants(self.namespaced("context-group"))
     # TODO: conbine name in query
     for group in grouptags:
         if group.get("name") == name:
             contexts = group.iterdescendants(self.namespaced("context"))
             pairs = []
             for context in contexts:
                 pairs.append((context.get("context-type"), lisa.getText(context, getXMLspace(self.xmlelement, self._default_xml_space))))
             groups.append(pairs)  # not extend
     return groups
开发者ID:dwaynebailey,项目名称:translate,代码行数:13,代码来源:xliff.py

示例9: getsource

 def getsource(self):
     return self.getNodeText(self.source_dom,
                             getXMLspace(self.xmlelement,
                                         self._default_xml_space))
开发者ID:cc-archive,项目名称:pootle,代码行数:4,代码来源:lisa.py

示例10: get_node_data

def get_node_data(unit, node):
    """Generic implementation of LISAUnit.gettarget."""
    return (
        getXMLlang(node),
        unit.getNodeText(node, getXMLspace(unit.xmlelement, 'preserve'))
    )
开发者ID:daleathan,项目名称:weblate,代码行数:6,代码来源:storage.py


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