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

Python convert.should_output_store函数代码示例

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

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



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

示例1: convertoo

def convertoo(inputfile, outputfile, templatefile, sourcelanguage=None,
              targetlanguage=None, timestamp=None, includefuzzy=False,
              multifilestyle="single", skip_source=False, filteraction=None,
              outputthreshold=None):
    inputstore = factory.getobject(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    inputstore.filename = getattr(inputfile, 'name', '')
    if not targetlanguage:
        raise ValueError("You must specify the target language")
    if not sourcelanguage:
        if targetlanguage.isdigit():
            sourcelanguage = "01"
        else:
            sourcelanguage = "en-US"
    languages = (sourcelanguage, targetlanguage)
    if templatefile is None:
        raise ValueError("must have template file for oo files")
    else:
        convertor = reoo(templatefile, languages=languages,
                         timestamp=timestamp, includefuzzy=includefuzzy,
                         long_keys=multifilestyle != "single",
                         filteraction=filteraction)
    outputstore = convertor.convertstore(inputstore)
    # TODO: check if we need to manually delete missing items
    outputfile.write(outputstore.__str__(skip_source, targetlanguage))
    return True
开发者ID:anderson916,项目名称:translate,代码行数:29,代码来源:po2oo.py


示例2: convertdtd

def convertdtd(inputfile, outputfile, templatefile, includefuzzy=False,
               remove_untranslated=False, outputthreshold=None):
    inputstore = po.pofile(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    # Some of the DTD files used for Firefox Mobile are actually completely
    # different with different escaping and quoting rules. The best way to
    # identify them seems to be on their file path in the tree (based on code
    # in compare-locales).
    android_dtd = False
    header_comment = ""
    input_header = inputstore.header()
    if input_header:
        header_comment = input_header.getnotes("developer")
        if "embedding/android" in header_comment or "mobile/android/base" in header_comment:
            android_dtd = True

    if templatefile is None:
        convertor = po2dtd(android=android_dtd,
                           remove_untranslated=remove_untranslated)
    else:
        templatestore = dtd.dtdfile(templatefile, android=android_dtd)
        convertor = redtd(templatestore, android=android_dtd,
                          remove_untranslated=remove_untranslated)
    outputstore = convertor.convertstore(inputstore, includefuzzy)
    outputfile.write(str(outputstore))
    return 1
开发者ID:onia,项目名称:translate,代码行数:29,代码来源:po2dtd.py


示例3: convertpy

def convertpy(inputfile, outputfile, templatefile=None, includefuzzy=False,
              outputthreshold=None):
    inputstore = factory.getobject(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    convertor = po2pydict()
    outputstring = convertor.convertstore(inputstore, includefuzzy)
    outputfile.write(outputstring.read())
    return 1
开发者ID:nursix,项目名称:translate,代码行数:11,代码来源:po2web2py.py


示例4: convertical

def convertical(inputfile, outputfile, templatefile, includefuzzy=False, outputthreshold=None):
    inputstore = factory.getobject(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    if templatefile is None:
        raise ValueError("must have template file for iCal files")
    else:
        convertor = reical(templatefile, inputstore)
    outputstring = convertor.convertstore(includefuzzy)
    outputfile.write(outputstring)
    return 1
开发者ID:asyschikov,项目名称:translate,代码行数:13,代码来源:po2ical.py


示例5: convertsub

def convertsub(inputfile, outputfile, templatefile, includefuzzy=False,
               outputthreshold=None):
    if templatefile is None:
        raise ValueError("must have template file for subtitle files")

    inputstore = po.pofile(inputfile)
    if not convert.should_output_store(inputstore, outputthreshold):
        return 0

    convertor = po2sub(templatefile, inputstore, includefuzzy)
    outputstring = convertor.convert_store()
    outputfile.write(outputstring)
    return 1
开发者ID:diorcety,项目名称:translate,代码行数:13,代码来源:po2sub.py


示例6: convertjson

def convertjson(inputfile, outputfile, templatefile, includefuzzy=False,
                outputthreshold=None, remove_untranslated=False):
    inputstore = factory.getobject(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    if templatefile is None:
        raise ValueError("Must have template file for JSON files")

    convertor = rejson(templatefile, inputstore)
    outputstring = convertor.convertstore(includefuzzy, remove_untranslated)
    outputfile.write(outputstring)
    return True
开发者ID:diorcety,项目名称:translate,代码行数:14,代码来源:po2json.py


示例7: convertphp

def convertphp(inputfile, outputfile, templatefile, includefuzzy=False,
               outputthreshold=None):
    inputstore = po.pofile(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    if templatefile is None:
        raise ValueError("must have template file for php files")

    convertor = rephp(templatefile, inputstore)
    outputphplines = convertor.convertstore(includefuzzy)
    outputfile.writelines(outputphplines)
    return 1
开发者ID:Veterini,项目名称:translate,代码行数:14,代码来源:po2php.py


示例8: convertlang

def convertlang(inputfile, outputfile, templates, includefuzzy=False, mark_active=True,
                outputthreshold=None):
    """reads in stdin using fromfileclass, converts using convertorclass,
    writes to stdout"""
    inputstore = po.pofile(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    if inputstore.isempty():
        return 0
    convertor = po2lang(mark_active=mark_active)
    outputstore = convertor.convertstore(inputstore, includefuzzy)
    outputfile.write(str(outputstore))
    return 1
开发者ID:denji,项目名称:translate,代码行数:15,代码来源:po2mozlang.py


示例9: convertpy

def convertpy(inputfile, outputfile, templatefile=None, includefuzzy=False,
              outputthreshold=None):
    inputstore = factory.getobject(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return 0

    convertor = po2pydict()
    outputstring = convertor.convertstore(inputstore, includefuzzy)

    if six.PY2:
        outputfile.write(outputstring.read().decode('utf-8'))
    else:
        outputfile.write(bytes(outputstring.read(), 'utf-8'))
    return 1
开发者ID:translate,项目名称:translate,代码行数:15,代码来源:po2web2py.py


示例10: __init__

    def __init__(self, input_file, output_file, template_file=None,
                 include_fuzzy=False, output_threshold=None, encoding='utf-8',
                 wrap=None):
        """Initialize the converter."""
        self.source_store = factory.getobject(input_file)

        self.should_output_store = convert.should_output_store(
            self.source_store, output_threshold
        )
        if self.should_output_store:
            self.include_fuzzy = include_fuzzy
            self.encoding = encoding
            self.wrap = wrap

            self.output_file = output_file
            self.template_file = template_file
开发者ID:diorcety,项目名称:translate,代码行数:16,代码来源:po2txt.py


示例11: converttxt

def converttxt(inputfile, outputfile, templatefile, wrap=None, includefuzzy=False, encoding='utf-8',
               outputthreshold=None):
    """reads in stdin using fromfileclass, converts using convertorclass, writes to stdout"""
    inputstore = factory.getobject(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    convertor = po2txt(wrap=wrap)
    if templatefile is None:
        outputstring = convertor.convertstore(inputstore, includefuzzy)
    else:
        templatestring = templatefile.read().decode(encoding)
        outputstring = convertor.mergestore(inputstore, templatestring, includefuzzy)
    outputfile.write(outputstring.encode('utf-8'))
    return 1
开发者ID:Alexinger,项目名称:translate,代码行数:16,代码来源:po2txt.py


示例12: convertprop

def convertprop(inputfile, outputfile, templatefile, personality="java",
                includefuzzy=False, encoding=None, remove_untranslated=False,
                outputthreshold=None):
    inputstore = po.pofile(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    if templatefile is None:
        raise ValueError("must have template file for properties files")
        # convertor = po2prop()
    else:
        convertor = reprop(templatefile, inputstore, personality, encoding,
                           remove_untranslated)
    outputprop = convertor.convertstore(includefuzzy)
    outputfile.write(outputprop)
    return 1
开发者ID:Repentinus,项目名称:translate,代码行数:17,代码来源:po2prop.py


示例13: convertrc

def convertrc(inputfile, outputfile, templatefile, includefuzzy=False,
              charset=None, lang=None, sublang=None, outputthreshold=None):
    inputstore = po.pofile(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    if not lang:
        raise ValueError("must specify a target language")
    if templatefile is None:
        raise ValueError("must have template file for rc files")
        # convertor = po2rc()
    else:
        convertor = rerc(templatefile, charset, lang, sublang)
    outputrclines = convertor.convertstore(inputstore, includefuzzy)
    outputfile.writelines(outputrclines)
    return 1
开发者ID:XLeonardo,项目名称:translate-1,代码行数:17,代码来源:po2rc.py


示例14: converthtml

def converthtml(inputfile, outputfile, templatefile, includefuzzy=False,
                outputthreshold=None):
    """reads in stdin using fromfileclass, converts using convertorclass,
    writes to stdout"""
    inputstore = po.pofile(inputfile)

    if not convert.should_output_store(inputstore, outputthreshold):
        return False

    convertor = po2html()
    if templatefile is None:
        raise ValueError("must have template file for HTML files")
    else:
        outputstring = convertor.mergestore(inputstore, templatefile,
                                            includefuzzy)
    outputfile.write(outputstring.encode('utf-8'))
    return 1
开发者ID:asyschikov,项目名称:translate,代码行数:17,代码来源:po2html.py


示例15: __init__

    def __init__(self, input_file, output_file, template_file=None,
                 include_fuzzy=False, output_threshold=None):
        """Initialize the converter."""
        if template_file is None:
            raise ValueError(self.MissingTemplateMessage)

        self.source_store = self.SourceStoreClass(input_file)
        self.target_store = self.TargetStoreClass()

        self.should_output_store = convert.should_output_store(
            self.source_store, output_threshold
        )
        if self.should_output_store:
            self.include_fuzzy = include_fuzzy

            self.output_file = output_file
            self.template_store = self.TargetStoreClass(template_file)
开发者ID:diorcety,项目名称:translate,代码行数:17,代码来源:po2yaml.py


示例16: __init__

    def __init__(self, input_file, output_file, template_file=None,
                 include_fuzzy=False, output_threshold=None,
                 dialect="default"):
        """Initialize the converter."""
        if ini.INIConfig is None:
            print("Missing iniparse library!")
            sys.exit()

        if template_file is None:
            raise ValueError(self.MissingTemplateMessage)

        self.source_store = self.SourceStoreClass(input_file)

        self.should_output_store = convert.should_output_store(
            self.source_store, output_threshold
        )
        if self.should_output_store:
            self.include_fuzzy = include_fuzzy

            self.output_file = output_file
            self.template_store = self.TargetStoreClass(template_file,
                                                        dialect=dialect)
            self.target_store = self.TargetStoreClass(dialect=dialect)
开发者ID:diorcety,项目名称:translate,代码行数:23,代码来源:po2ini.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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