本文整理匯總了Python中weblate.trans.formats.AutoFormat.load方法的典型用法代碼示例。如果您正苦於以下問題:Python AutoFormat.load方法的具體用法?Python AutoFormat.load怎麽用?Python AutoFormat.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weblate.trans.formats.AutoFormat
的用法示例。
在下文中一共展示了AutoFormat.load方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: upload
# 需要導入模塊: from weblate.trans.formats import AutoFormat [as 別名]
# 或者: from weblate.trans.formats.AutoFormat import load [as 別名]
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
示例2: upload
# 需要導入模塊: from weblate.trans.formats import AutoFormat [as 別名]
# 或者: from weblate.trans.formats.AutoFormat import load [as 別名]
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