本文整理汇总了Python中translate.convert.convert.should_output_store函数的典型用法代码示例。如果您正苦于以下问题:Python should_output_store函数的具体用法?Python should_output_store怎么用?Python should_output_store使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了should_output_store函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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)