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

Python oo.oofile函数代码示例

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

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



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

示例1: convertoo

def convertoo(inputfile, outputfile, templates, pot=False, sourcelanguage=None, targetlanguage=None, duplicatestyle="msgctxt", multifilestyle="single"):
    """reads in stdin using inputstore class, converts using convertorclass, writes to stdout"""
    inputstore = oo.oofile()
    if hasattr(inputfile, "filename"):
        inputfilename = inputfile.filename
    else:
        inputfilename = "(input file name not known)"
    inputstore.filename = inputfilename
    inputstore.parse(inputfile.read())
    if not sourcelanguage:
        testlangtype = targetlanguage or (inputstore and inputstore.languages[0]) or ""
        if testlangtype.isdigit():
            sourcelanguage = "01"
        else:
            sourcelanguage = "en-US"
    if not sourcelanguage in inputstore.languages:
        logger.warning("sourcelanguage '%s' not found in inputfile '%s' "
                       "(contains %s)",
                       sourcelanguage, inputfilename,
                       ", ".join(inputstore.languages))
    if not pot and (targetlanguage and
                    targetlanguage not in inputstore.languages):
        logger.warning("targetlanguage '%s' not found in inputfile '%s' "
                       "(contains %s)",
                       targetlanguage, inputfilename,
                       ", ".join(inputstore.languages))
    convertor = oo2xliff(sourcelanguage, targetlanguage, blankmsgstr=pot,
                         long_keys=(multifilestyle != "single"))
    outputstore = convertor.convertstore(inputstore, duplicatestyle)
    if outputstore.isempty():
        return 0
    outputfile.write(str(outputstore))
    return 1
开发者ID:flyeven,项目名称:translate,代码行数:33,代码来源:oo2xliff.py


示例2: test_preserve_filename

 def test_preserve_filename(self):
     """Ensures that the filename is preserved."""
     oosource = r'svx	source\dialog\numpages.src	0	string	RID_SVXPAGE_NUM_OPTIONS	STR_BULLET			0	en-US	Character				20050924 09:13:58'
     self.create_testfile("snippet.sdf", oosource)
     oofile = oo.oofile(self.open_testfile("snippet.sdf"))
     assert oofile.filename.endswith("snippet.sdf")
     oofile.parse(oosource)
     assert oofile.filename.endswith("snippet.sdf")
开发者ID:Alexinger,项目名称:translate,代码行数:8,代码来源:test_oo2po.py


示例3: convert

 def convert(self, oosource, sourcelanguage='en-US', targetlanguage='af-ZA'):
     """helper that converts oo source to po source without requiring files"""
     if isinstance(oosource, six.text_type):
         oosource = oosource.encode('utf-8')
     inputoo = oo.oofile(oosource)
     convertor = self.conversion_class(sourcelanguage, targetlanguage)
     outputpo = convertor.convertstore(inputoo)
     return outputpo
开发者ID:Veterini,项目名称:translate,代码行数:8,代码来源:test_oo2po.py


示例4: convertoo

def convertoo(
    inputfile,
    outputfile,
    templates,
    pot=False,
    sourcelanguage=None,
    targetlanguage=None,
    duplicatestyle="msgid_comment",
    multifilestyle="single",
):
    """reads in stdin using inputstore class, converts using convertorclass, writes to stdout"""
    inputstore = oo.oofile()
    if hasattr(inputfile, "filename"):
        inputfilename = inputfile.filename
    else:
        inputfilename = "(input file name not known)"
    inputstore.filename = inputfilename
    inputstore.parse(inputfile.read())
    if not sourcelanguage:
        testlangtype = targetlanguage or (inputstore and inputstore.languages[0]) or ""
        if testlangtype.isdigit():
            sourcelanguage = "01"
        else:
            sourcelanguage = "en-US"
    if not sourcelanguage in inputstore.languages:
        print >>sys.stderr, "Warning: sourcelanguage '%s' not found in inputfile '%s' (contains %s)" % (
            sourcelanguage,
            inputfilename,
            ", ".join(inputstore.languages),
        )
    if targetlanguage and targetlanguage not in inputstore.languages:
        print >>sys.stderr, "Warning: targetlanguage '%s' not found in inputfile '%s' (contains %s)" % (
            targetlanguage,
            inputfilename,
            ", ".join(inputstore.languages),
        )
    convertor = oo2po(sourcelanguage, targetlanguage, blankmsgstr=pot, long_keys=multifilestyle != "single")
    outputstore = convertor.convertstore(inputstore, duplicatestyle)
    if outputstore.isempty():
        return 0
    outputfile.write(str(outputstore))
    return 1
开发者ID:rdio,项目名称:translate-toolkit,代码行数:42,代码来源:oo2po.py


示例5: convert

 def convert(self, oosource, sourcelanguage='en-US', targetlanguage='af-ZA'):
     """helper that converts oo source to po source without requiring files"""
     inputoo = oo.oofile(oosource)
     convertor = self.conversion_class(sourcelanguage, targetlanguage)
     outputpo = convertor.convertstore(inputoo)
     return outputpo
开发者ID:Alexinger,项目名称:translate,代码行数:6,代码来源:test_oo2po.py


示例6: ooparse

 def ooparse(self, oosource):
     """helper that parses oo source without requiring files"""
     dummyfile = wStringIO.StringIO(oosource)
     oofile = oo.oofile(dummyfile)
     return oofile
开发者ID:onia,项目名称:translate,代码行数:5,代码来源:test_oo.py


示例7: readoo

 def readoo(self, of):
     """read in the oo from the file"""
     oosrc = of.read()
     self.o = oo.oofile()
     self.o.parse(oosrc)
     self.makeindex()
开发者ID:anderson916,项目名称:translate,代码行数:6,代码来源:po2oo.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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