Commit ebd52da9 authored by Michal Čihař's avatar Michal Čihař

Simplify dictionary loaded

We can now completely rely on our automatic loader.

Issue #644
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 0010a54a
......@@ -23,9 +23,8 @@ from django.db import models
from django.db.models import Q
from django.utils.encoding import force_unicode
from weblate.lang.models import Language
from weblate.trans.formats import AutoFormat, StringIOMode
from weblate.trans.formats import AutoFormat
from weblate.trans.models.project import Project
from translate.storage.csvl10n import csvfile
from weblate.trans.util import report_error
from django.core.urlresolvers import reverse
from whoosh.analysis import (
......@@ -41,23 +40,10 @@ class DictionaryManager(models.Manager):
'''
Handles dictionary update.
'''
filecopy = fileobj.read()
fileobj.close()
# Load file using translate-toolkit
store = AutoFormat.load(StringIOMode(fileobj.name, filecopy))
store = AutoFormat.parse(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
store = csvfile(
StringIOMode(fileobj.name, filecopy),
('source', 'target')
)
ret, skipped = self.import_store(
request, project, language, store, method
request, project, language, store.store, method
)
return ret
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment