本文整理汇总了Python中translate.storage.csvl10n.csvfile函数的典型用法代码示例。如果您正苦于以下问题:Python csvfile函数的具体用法?Python csvfile怎么用?Python csvfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了csvfile函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: convertcsv
def convertcsv(inputfile, outputfile, templatefile, charset=None, columnorder=None):
"""reads in inputfile using csvl10n, converts using csv2tbx, writes to outputfile"""
inputstore = csvl10n.csvfile(inputfile, fieldnames=columnorder)
convertor = csv2tbx(charset=charset)
outputstore = convertor.convertfile(inputstore)
if len(outputstore.units) == 0:
return 0
outputfile.write(str(outputstore))
return 1
开发者ID:AndryulE,项目名称:kitsune,代码行数:9,代码来源:csv2tbx.py
示例2: buildcsv
def buildcsv(self, sources, targets=None):
"""Build a csvfile store with the given source and target strings"""
if targets is None:
targets = sources
else:
assert len(sources) == len(targets)
csvfile = csvl10n.csvfile()
for source, target in zip(sources, targets):
unit = csvfile.addsourceunit(source)
unit.target = target
return csvfile
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:11,代码来源:test_match.py
示例3: convertstore
def convertstore(self, inputstore, columnorder=None):
outputstore = csvl10n.csvfile(fieldnames=columnorder)
for inputunit in inputstore.units:
outputunit = self.convertunit(inputunit)
if outputunit is not None:
outputstore.addunit(outputunit)
if inputunit.hasplural():
outputunit = self.convertplurals(inputunit)
if outputunit is not None:
outputstore.addunit(outputunit)
return outputstore
开发者ID:AlexArgus,项目名称:affiliates-lib,代码行数:11,代码来源:po2csv.py
示例4: csv2po
def csv2po(self, csvsource, template=None):
"""helper that converts csv source to po source without requiring files"""
inputfile = wStringIO.StringIO(csvsource)
inputcsv = csvl10n.csvfile(inputfile)
if template:
templatefile = wStringIO.StringIO(template)
inputpot = po.pofile(templatefile)
else:
inputpot = None
convertor = csv2po.csv2po(templatepo=inputpot)
outputpo = convertor.convertstore(inputcsv)
return outputpo
开发者ID:Jobava,项目名称:translate-toolkit,代码行数:12,代码来源:test_po2csv.py
示例5: convertcsv
def convertcsv(inputfile, outputfile, templatefile, charset=None, columnorder=None, duplicatestyle="msgctxt"):
"""reads in inputfile using csvl10n, converts using csv2po, writes to outputfile"""
inputstore = csvl10n.csvfile(inputfile, fieldnames=columnorder)
if templatefile is None:
convertor = csv2po(charset=charset, duplicatestyle=duplicatestyle)
else:
templatestore = po.pofile(templatefile)
convertor = csv2po(templatestore, charset=charset, duplicatestyle=duplicatestyle)
outputstore = convertor.convertstore(inputstore)
if outputstore.isempty():
return 0
outputfile.write(str(outputstore))
return 1
开发者ID:cc-archive,项目名称:pootle,代码行数:13,代码来源:csv2po.py
示例6: convertstore
def convertstore(self, inputstore, columnorder=None):
if columnorder is None:
columnorder = ['location', 'source', 'target']
outputstore = csvl10n.csvfile(fieldnames=columnorder)
for inputunit in inputstore.units:
outputunit = self.convertunit(inputunit)
if outputunit is not None:
outputstore.addunit(outputunit)
if inputunit.hasplural():
outputunit = self.convertplurals(inputunit)
if outputunit is not None:
outputstore.addunit(outputunit)
return outputstore
开发者ID:Esya,项目名称:translate,代码行数:13,代码来源:po2csv.py
示例7: test_quotes
def test_quotes(self):
"""Test the escaping of quotes (and slash)"""
minicsv = r''',"Hello ""Everyone""","Good day ""All"""
,"Use \"".","Gebruik \""."'''
print(minicsv)
csvfile = csvl10n.csvfile(wStringIO.StringIO(minicsv))
print(bytes(csvfile))
pofile = self.csv2po(minicsv)
unit = first_translatable(pofile)
assert unit.source == 'Hello "Everyone"'
assert pofile.findunit('Hello "Everyone"').target == 'Good day "All"'
print(bytes(pofile))
for unit in pofile.units:
print(unit.source)
print(unit.target)
print()
开发者ID:Veterini,项目名称:translate,代码行数:16,代码来源:test_csv2po.py
示例8: upload
def upload(self, request, project, language, fileobj, method):
"""
Handles dictionary update.
"""
# Load file using translate-toolkit
store = AutoFormat.load(fileobj)
ret, skipped = self.import_store(request, project, language, store, method)
if ret == 0 and skipped > 0 and isinstance(store, csvfile):
# Retry with different CSV scheme
fileobj.seek(0)
store = csvfile(fileobj, ("source", "target"))
ret, skipped = self.import_store(request, project, language, store, method)
return ret
开发者ID:barmi,项目名称:weblate,代码行数:16,代码来源:dictionary.py
示例9: upload
def upload(self, request, project, language, fileobj, method):
'''
Handles dictionary update.
'''
filecopy = fileobj.read()
fileobj.close()
# Load file using translate-toolkit
store = AutoFormat.load(StringIOMode(fileobj.name, filecopy))
ret, skipped = self.import_store(
request, project, language, store, method
)
if ret == 0 and skipped > 0 and isinstance(store, csvfile):
# Retry with different CSV scheme
store = csvfile(
StringIOMode(fileobj.name, filecopy),
('source', 'target')
)
ret, skipped = self.import_store(
request, project, language, store, method
)
return ret
开发者ID:beck,项目名称:weblate,代码行数:24,代码来源:dictionary.py
示例10: get_storage
def get_storage(self):
return csvfile(fieldnames=self.fieldnames)
开发者ID:nijel,项目名称:weblate,代码行数:2,代码来源:exporters.py
示例11: initcsv
def initcsv(inputfile, columnorder=None):
return csvl10n.csvfile(inputfile, columnorder)
开发者ID:AndryulE,项目名称:kitsune,代码行数:2,代码来源:lookupservice.py
注:本文中的translate.storage.csvl10n.csvfile函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论