本文整理汇总了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;未经允许,请勿转载。 |
请发表评论