Commits

Seraphim Mellos committed 7eb95b7

Allow autofetch to handle all URLs given that the parser can handle the associated file.

Comments (0)

Files changed (2)

transifex/addons/autofetch/models.py

 
 from transifex.resources.models import Resource
 from transifex.txcommon.log import logger
+from transifex.resources.formats import get_i18n_handler_from_type
 
 import os
 import urllib2, urlparse
         sf.save()
 
         try:
-            parser = sf.find_parser()
+            parser = get_i18n_handler_from_type(self.resource.i18n_type)
             language = sf.language
             fhandler = parser(filename=sf.get_storage_path())
             fhandler.set_language(language)

transifex/resources/formats/core.py

             original_sources = list(qs)
             new_entities = []
 
-
         try:
             strings_added = 0
             strings_updated = 0
                 t, created = Template.objects.get_or_create(resource = self.resource)
                 t.content = self.template
                 t.save()
-                self.resource.i18n_type = get_i18n_type_from_file(self.filename)
-                self.resource.save()
+                if created:
+                    self.resource.i18n_type = get_i18n_type_from_file(self.filename)
+                    self.resource.save()
                 # See how many iterations we need for this
                 iterations = len(original_sources)*len(new_entities)
                 # If it's not over the limit, then do it
                     language = self.language
                 )
 
+
             self._post_save2db(is_source , user, overwrite_translations)
 
             # Invalidate cache after saving file