Commits

Tommaso Barbugli committed 327084c

removed target resource from instance since self.resource to avoid overlaps during parallel pulls

Comments (0)

Files changed (1)

txclib/project.py

 
         if fetchall:
             new_translations = self._new_translations_to_add(
-                files, slang, lang_map, stats, force
+                files, slang, lang_map, resource, stats, force
             )
             if new_translations:
                 MSG("New translations found for the following languages: %s" %
                     ', '.join(new_translations))
 
         existing, new = self._languages_to_pull(
-            languages, files, lang_map, stats, force
+            languages, files, lang_map, resource, stats, force
         )
         pull_languages |= existing
         new_translations |= new
                 'stats': stats,
                 'local_file': local_file,
                 'force': force,
+                'resource': resource
             }
             if not self._should_update_translation(**kwargs):
                 msg = "Skipping '%s' translation (file: %s)."
         return raw
 
 
-    def _should_update_translation(self, lang, stats, local_file, force=False):
+    def _should_update_translation(self, lang, stats, local_file, resource, force=False):
         """Whether a translation should be udpated from Transifex.
 
         We use the following criteria for that:
         Returns:
             True or False.
         """
-        return self._should_download(lang, stats, local_file, force)
+        return self._should_download(lang, stats, resource, local_file, force)
 
-    def _should_add_translation(self, lang, stats, force=False):
+    def _should_add_translation(self, lang, stats, resource, force=False):
         """Whether a translation should be added from Transifex.
 
         We use the following criteria for that:
         Returns:
             True or False.
         """
-        return self._should_download(lang, stats, None, force)
+        return self._should_download(lang, stats, resource, None, force)
 
-    def _should_download(self, lang, stats, local_file=None, force=False):
+    def _should_download(self, lang, stats, resource, local_file=None, force=False):
         """Return whether a translation should be downloaded.
 
         If local_file is None, skip the timestamps check (the file does
                 logger.debug("Local is newer than remote for lang %s" % lang)
                 return False
 
-        return self._satisfies_min_translated(lang_stats)
+        return self._satisfies_min_translated(lang_stats, resource)
 
     def _should_push_translation(self, lang, stats, local_file, force=False):
         """Return whether a local translation file should be
             return None
         return time.mktime(time.gmtime(os.path.getmtime(path)))
 
-    def _satisfies_min_translated(self, stats):
+    def _satisfies_min_translated(self, stats, resource):
         """Check whether a translation fulfills the filter used for
         minimum translated percentage.
 
             )
             resource_minimum = int(
                 self.get_resource_option(
-                    self.resource, option_name
+                    resource, option_name
                 ) or global_minimum
             )
             minimum_percent = resource_minimum
         except KeyError, e:
             return None
 
-    def _new_translations_to_add(self, files, slang, lang_map,
+    def _new_translations_to_add(self, files, slang, lang_map, resource,
                                  stats, force=False):
         """Return a list of translations which are new to the
         local installation.
             )
             if lang_exists or lang_is_source or mapped_lang_exists:
                 continue
-            if self._should_add_translation(lang, stats, force):
+            if self._should_add_translation(lang, stats, resource, force):
                 new_translations.append(lang)
         return set(new_translations)
 
         logger.debug("Operating on resources: %s" % selected_resources)
         return selected_resources
 
-    def _languages_to_pull(self, languages, files, lang_map, stats, force):
+    def _languages_to_pull(self, languages, files, lang_map, resource, stats, force):
         """Get a set of langauges to pull.
 
         Args:
             f_langs = files.keys()
             for l in languages:
                 if l not in f_langs and not (l in lang_map and lang_map[l] in f_langs):
-                    if self._should_add_translation(l, stats, force):
+                    if self._should_add_translation(l, stats, resource, force):
                         new_translations.append(l)
                 else:
                     if l in lang_map.keys():