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

Python lisa.xml_to_strelem函数代码示例

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

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



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

示例1: test_xml_to_strelem

def test_xml_to_strelem():
    source = etree.fromstring(u'<source>a<x id="foo[1]/bar[1]/baz[1]"/></source>')
    elem = lisa.xml_to_strelem(source)
    assert elem.sub == [ StringElem(u'a'), X(id=u'foo[1]/bar[1]/baz[1]') ]

    source = etree.fromstring(u'<source>a<x id="foo[1]/bar[1]/baz[1]"/>é</source>')
    elem = lisa.xml_to_strelem(source)
    assert elem.sub == [ StringElem(u'a'), X(id=u'foo[1]/bar[1]/baz[1]'), StringElem(u'é') ]

    source = etree.fromstring(u'<source>a<g id="foo[2]/bar[2]/baz[2]">b<x id="foo[1]/bar[1]/baz[1]"/>c</g>é</source>')
    elem = lisa.xml_to_strelem(source)
    assert elem.sub == [ StringElem(u'a'), G(id=u'foo[2]/bar[2]/baz[2]', sub=[StringElem(u'b'), X(id=u'foo[1]/bar[1]/baz[1]'), StringElem(u'c')]), StringElem(u'é') ]
开发者ID:AndreasEisele,项目名称:wikitrans-pootle,代码行数:12,代码来源:test_lisa.py


示例2: 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:Repentinus,项目名称:translate,代码行数:8,代码来源:xliff.py


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


示例4: multistring_to_rich

    def multistring_to_rich(cls, mstr):
        """Override L{TranslationUnit.multistring_to_rich} which is used by the
            C{rich_source} and C{rich_target} properties."""
        strings = mstr
        if isinstance(mstr, multistring):
            strings = mstr.strings
        elif isinstance(mstr, basestring):
            strings = [mstr]

        return [xml_to_strelem(s) for s in strings]
开发者ID:cc-archive,项目名称:pootle,代码行数:10,代码来源:xliff.py


示例5: multistring_to_rich

    def multistring_to_rich(cls, mstr):
        """Override :meth:`TranslationUnit.multistring_to_rich` which is used
        by the ``rich_source`` and ``rich_target`` properties."""
        strings = mstr
        if isinstance(mstr, multistring):
            strings = mstr.strings
        elif isinstance(mstr, basestring):
            strings = [mstr]

        return [xml_to_strelem(s) for s in strings]
开发者ID:KINFOO,项目名称:translate,代码行数:10,代码来源:xliff.py


示例6: test_xml_to_strelem

def test_xml_to_strelem():
    source = etree.fromstring(u"<source>a</source>")
    elem = lisa.xml_to_strelem(source)
    assert elem == StringElem(u"a")

    source = etree.fromstring(u'<source>a<x id="foo[1]/bar[1]/baz[1]"/></source>')
    elem = lisa.xml_to_strelem(source)
    assert elem.sub == [StringElem(u"a"), X(id=u"foo[1]/bar[1]/baz[1]")]

    source = etree.fromstring(u'<source>a<x id="foo[1]/bar[1]/baz[1]"/>é</source>')
    elem = lisa.xml_to_strelem(source)
    assert elem.sub == [StringElem(u"a"), X(id=u"foo[1]/bar[1]/baz[1]"), StringElem(u"é")]

    source = etree.fromstring(u'<source>a<g id="foo[2]/bar[2]/baz[2]">b<x id="foo[1]/bar[1]/baz[1]"/>c</g>é</source>')
    elem = lisa.xml_to_strelem(source)
    assert elem.sub == [
        StringElem(u"a"),
        G(id=u"foo[2]/bar[2]/baz[2]", sub=[StringElem(u"b"), X(id=u"foo[1]/bar[1]/baz[1]"), StringElem(u"c")]),
        StringElem(u"é"),
    ]
开发者ID:rdio,项目名称:translate-toolkit,代码行数:20,代码来源:test_lisa.py


示例7: test_unknown_xml_placeable

def test_unknown_xml_placeable():
    # The XML below is (modified) from the official XLIFF example file Sample_AlmostEverything_1.2_strict.xlf
    source = etree.fromstring(
        u"""<source xml:lang="en-us">Text <g id="_1_ski_040">g</g>TEXT<bpt id="_1_ski_139">bpt<sub>sub</sub>
               </bpt>TEXT<ept id="_1_ski_238">ept</ept>TEXT<ph id="_1_ski_337"/>TEXT<it id="_1_ski_436" pos="open">it</it>TEXT<mrk mtype="x-test">mrk</mrk>
               <x id="_1_ski_535"/>TEXT<bx id="_1_ski_634"/>TEXT<ex id="_1_ski_733"/>TEXT.</source>"""
    )
    elem = lisa.xml_to_strelem(source)

    from copy import copy

    custom = StringElem(
        [
            StringElem(u"Text "),
            G(u"g", id="_1_ski_040"),
            StringElem(u"TEXT"),
            UnknownXML(
                [StringElem(u"bpt"), UnknownXML(u"sub", xml_node=copy(source[1][0])), StringElem(u"\n               ")],
                id="_1_ski_139",
                xml_node=copy(source[3]),
            ),
            StringElem(u"TEXT"),
            UnknownXML(u"ept", id=u"_1_ski_238", xml_node=copy(source[2])),
            StringElem(u"TEXT"),
            UnknownXML(id="_1_ski_337", xml_node=copy(source[3])),  # ph-tag
            StringElem(u"TEXT"),
            UnknownXML(u"it", id="_1_ski_436", xml_node=copy(source[4])),
            StringElem(u"TEXT"),
            UnknownXML(u"mrk", xml_node=copy(source[5])),
            StringElem(u"\n               "),
            X(id="_1_ski_535"),
            StringElem(u"TEXT"),
            Bx(id="_1_ski_634"),
            StringElem(u"TEXT"),
            Ex(id="_1_ski_733"),
            StringElem(u"TEXT."),
        ]
    )
    assert elem == custom

    xml = copy(source)
    for i in range(len(xml)):
        del xml[0]
    xml.text = None
    xml.tail = None
    lisa.strelem_to_xml(xml, elem)
    assert etree.tostring(xml) == etree.tostring(source)
开发者ID:rdio,项目名称:translate-toolkit,代码行数:47,代码来源:test_lisa.py


示例8: test_xml_space

def test_xml_space():
    source = etree.fromstring(u'<source xml:space="default"> a <x id="foo[1]/bar[1]/baz[1]"/> </source>')
    elem = lisa.xml_to_strelem(source)
    print elem.sub
    assert elem.sub == [StringElem(u'a '), X(id=u'foo[1]/bar[1]/baz[1]'), StringElem(u' ')]
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:5,代码来源:test_lisa.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python po.pofile函数代码示例发布时间:2022-05-27
下一篇:
Python placeables.StringElem类代码示例发布时间: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