• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python lisa.getText函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了getText函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: _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


示例3: getnotelist

    def getnotelist(self, origin=None):
        """Private method that returns the text from notes.

        The origin parameter is ignored.."""
        note_nodes = self.xmlelement.iterdescendants(self.namespaced("note"))
        note_list = [lisa.getText(note) for note in note_nodes]

        return note_list
开发者ID:cc-archive,项目名称:pootle,代码行数:8,代码来源:tmx.py


示例4: _getnotelist

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

        :param origin: Ignored
        :return: The text from notes
        :rtype: List
        """
        note_nodes = self.xmlelement.iterdescendants(self.namespaced("note"))
        note_list = [lisa.getText(note) for note in note_nodes]

        return note_list
开发者ID:flyeven,项目名称:translate,代码行数:11,代码来源:tmx.py


示例5: 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


示例6: getnotelist

    def getnotelist(self, origin=None):
        """Private method that returns the text from notes matching 'origin' or all notes."""
        notenodes = 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 notenodes if self.correctorigin(note, origin)]

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

        return notelist
开发者ID:cc-archive,项目名称:pootle,代码行数:13,代码来源:xliff.py


示例7: getcontexttuples

 def getcontexttuples(self, node, namespace):
     """Returns all the information in the context nodes as a list of tuples
     of (type, text)"""
     contexts = node.findall(".//{%s}context" % namespace)
     return [(context.get("context-type"), lisa.getText(context)) for context in contexts]
开发者ID:AndryulE,项目名称:kitsune,代码行数:5,代码来源:test_po2xliff.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python lisa.getXMLspace函数代码示例发布时间:2022-05-27
下一篇:
Python html.htmlfile函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap