def update_from_templates(self, pootle_path=None): """update translation project from templates""" if self.is_template_project: return template_translation_project = self.project.get_template_translationproject( ) if template_translation_project is None or template_translation_project == self: return monolingual = self.project.is_monolingual() if not monolingual: self.sync() if pootle_path is None: oldstats = self.getquickstats() for store in template_translation_project.stores.iterator(): if self.file_style == 'gnu': new_pootle_path, new_path = get_translated_name_gnu( self, store) else: new_pootle_path, new_path = get_translated_name(self, store) if pootle_path is not None and new_pootle_path != pootle_path: continue convert_template(self, store, new_pootle_path, new_path, monolingual) self.scan_files() #self.update(conservative=False) if pootle_path is None: newstats = self.getquickstats() post_template_update.send(sender=self, oldstats=oldstats, newstats=newstats)
def update_from_templates(self, pootle_path=None): """update translation project from templates""" if self.is_template_project: return template_translation_project = self.project.get_template_translationproject() if template_translation_project is None or template_translation_project == self: return monolingual = self.project.is_monolingual() if not monolingual: self.sync() if pootle_path is None: oldstats = self.getquickstats() for store in template_translation_project.stores.iterator(): if self.file_style == "gnu": new_pootle_path, new_path = get_translated_name_gnu(self, store) else: new_pootle_path, new_path = get_translated_name(self, store) if pootle_path is not None and new_pootle_path != pootle_path: continue convert_template(self, store, new_pootle_path, new_path, monolingual) self.scan_files() self.update(conservative=False) if pootle_path is None: newstats = self.getquickstats() post_template_update.send(sender=self, oldstats=oldstats, newstats=newstats)
def update_from_templates(self, pootle_path=None): """Update translation project from templates.""" if self.is_template_project: return template_translation_project = self.project \ .get_template_translationproject() if template_translation_project is None or \ template_translation_project == self: return monolingual = self.project.is_monolingual() if not monolingual: self.sync() if pootle_path is None: oldstats = self.getquickstats() from pootle_app.project_tree import convert_template, \ get_translated_name, get_translated_name_gnu for store in template_translation_project.stores.iterator(): if self.file_style == 'gnu': new_pootle_path, new_path = get_translated_name_gnu( self, store) else: new_pootle_path, new_path = get_translated_name(self, store) if pootle_path is not None and new_pootle_path != pootle_path: continue convert_template(self, store, new_pootle_path, new_path, monolingual) all_files, new_files = self.scan_files() #self.update(conservative=False) from pootle_misc.versioncontrol import hasversioning project_path = self.project.get_real_path() if new_files and hasversioning(project_path): from translate.storage import versioncontrol vcs = versioncontrol.get_versioned_object(project_path) output = vcs.add([s.abs_real_path for s in new_files], "New files added from %s based on templates" % (settings.TITLE)) if pootle_path is None: newstats = self.getquickstats() from pootle_app.models.signals import post_template_update post_template_update.send(sender=self, oldstats=oldstats, newstats=newstats)
def update_against_templates(self, pootle_path=None): """Update translation project from templates.""" if self.is_template_project: return template_translation_project = self.project \ .get_template_translationproject() if (template_translation_project is None or template_translation_project == self): return monolingual = self.project.is_monolingual() if not monolingual: self.sync() if pootle_path is None: oldstats = self.getquickstats() from pootle_app.project_tree import (convert_template, get_translated_name, get_translated_name_gnu) for store in template_translation_project.stores.iterator(): if self.file_style == 'gnu': new_pootle_path, new_path = get_translated_name_gnu(self, store) else: new_pootle_path, new_path = get_translated_name(self, store) if pootle_path is not None and new_pootle_path != pootle_path: continue convert_template(self, store, new_pootle_path, new_path, monolingual) all_files, new_files = self.scan_files(vcs_sync=False) #self.update(conservative=False) from pootle_misc import versioncontrol project_path = self.project.get_real_path() if new_files and versioncontrol.hasversioning(project_path): output = versioncontrol.add_files(project_path, [s.file.name for s in new_files], "New files added from %s based on templates" % (settings.TITLE)) if pootle_path is None: newstats = self.getquickstats() from pootle_app.models.signals import post_template_update post_template_update.send(sender=self, oldstats=oldstats, newstats=newstats)
def update_against_templates(self, pootle_path=None): """Update translation project from templates.""" if self.is_template_project: return template_translation_project = self.project \ .get_template_translationproject() if (template_translation_project is None or template_translation_project == self): return monolingual = self.project.is_monolingual if not monolingual: self.sync() from pootle_app.project_tree import (convert_template, get_translated_name, get_translated_name_gnu) for store in template_translation_project.stores.iterator(): if self.file_style == 'gnu': new_pootle_path, new_path = get_translated_name_gnu(self, store) else: new_pootle_path, new_path = get_translated_name(self, store) if pootle_path is not None and new_pootle_path != pootle_path: continue convert_template(self, store, new_pootle_path, new_path, monolingual) all_files, new_files = self.scan_files(vcs_sync=False) project_path = self.project.get_real_path() if new_files and versioncontrol.hasversioning(project_path): message = ("New files added from %s based on templates" % get_site_title()) filestocommit = [f.file.name for f in new_files] success = True try: output = versioncontrol.add_files(project_path, filestocommit, message) except Exception: logging.exception(u"Failed to add files") success = False if pootle_path is None: from pootle_app.signals import post_template_update post_template_update.send(sender=self)
def update_from_templates(self, pootle_path=None): """Update translation project from templates.""" if self.is_template_project: return template_translation_project = self.project.get_template_translationproject() if template_translation_project is None or template_translation_project == self: return monolingual = self.project.is_monolingual() if not monolingual: self.sync() if pootle_path is None: oldstats = self.getquickstats() from pootle_app.project_tree import convert_template, get_translated_name, get_translated_name_gnu for store in template_translation_project.stores.iterator(): if self.file_style == "gnu": new_pootle_path, new_path = get_translated_name_gnu(self, store) else: new_pootle_path, new_path = get_translated_name(self, store) if pootle_path is not None and new_pootle_path != pootle_path: continue convert_template(self, store, new_pootle_path, new_path, monolingual) all_files, new_files = self.scan_files() # self.update(conservative=False) from pootle_misc.versioncontrol import hasversioning project_path = self.project.get_real_path() if new_files and hasversioning(project_path): from translate.storage import versioncontrol vcs = versioncontrol.get_versioned_object(project_path) output = vcs.add( [s.abs_real_path for s in new_files], "New files added from %s based on templates" % (settings.TITLE) ) if pootle_path is None: newstats = self.getquickstats() from pootle_app.models.signals import post_template_update post_template_update.send(sender=self, oldstats=oldstats, newstats=newstats)
def update_against_templates(self, pootle_path=None): """Update translation project from templates.""" if self.is_template_project: return template_translation_project = self.project \ .get_template_translationproject() if (template_translation_project is None or template_translation_project == self): return monolingual = self.project.is_monolingual if not monolingual: self.sync() from pootle_app.project_tree import (convert_template, get_translated_name, get_translated_name_gnu) for store in template_translation_project.stores.iterator(): if self.file_style == 'gnu': new_pootle_path, new_path = get_translated_name_gnu(self, store) else: new_pootle_path, new_path = get_translated_name(self, store) if pootle_path is not None and new_pootle_path != pootle_path: continue try: from pootle.scripts import hooks relative_po_path = os.path.relpath(new_path, settings.PODIRECTORY) if not hooks.hook(self.project.code, "pretemplateupdate", relative_po_path): continue except: # Assume hook is not present. pass convert_template(self, store, new_pootle_path, new_path, monolingual) all_files, new_files = self.scan_files(vcs_sync=False) from pootle_misc import versioncontrol project_path = self.project.get_real_path() if new_files and versioncontrol.hasversioning(project_path): from pootle.scripts import hooks siteconfig = load_site_config() message = ("New files added from %s based on templates" % siteconfig.get('TITLE')) filestocommit = [] for new_file in new_files: try: hook_files = hooks.hook(self.project.code, "precommit", new_file.file.name, author=None, message=message) filestocommit.extend(hook_files) except ImportError: # Failed to import the hook - we're going to assume there # just isn't a hook to import. That means we'll commit the # original file. filestocommit.append(new_file.file.name) success = True try: output = versioncontrol.add_files(project_path, filestocommit, message) except Exception: logging.exception(u"Failed to add files") success = False for new_file in new_files: try: hooks.hook(self.project.code, "postcommit", new_file.file.name, success=success) except: #FIXME: We should not hide the exception - makes # development impossible pass if pootle_path is None: from pootle_app.models.signals import post_template_update post_template_update.send(sender=self)
def update_against_templates(self, pootle_path=None): """Update translation project from templates.""" if self.is_template_project: return template_translation_project = self.project \ .get_template_translationproject() if (template_translation_project is None or template_translation_project == self): return monolingual = self.project.is_monolingual() if not monolingual: self.sync() if pootle_path is None: oldstats = self.getquickstats() from pootle_app.project_tree import (convert_template, get_translated_name, get_translated_name_gnu) for store in template_translation_project.stores.iterator(): if self.file_style == 'gnu': new_pootle_path, new_path = get_translated_name_gnu( self, store) else: new_pootle_path, new_path = get_translated_name(self, store) if pootle_path is not None and new_pootle_path != pootle_path: continue relative_po_path = os.path.relpath(new_path, settings.PODIRECTORY) try: from pootle.scripts import hooks if not hooks.hook(self.project.code, "pretemplateupdate", relative_po_path): continue except: # Assume hook is not present. pass convert_template(self, store, new_pootle_path, new_path, monolingual) all_files, new_files = self.scan_files(vcs_sync=False) from pootle_misc import versioncontrol project_path = self.project.get_real_path() if new_files and versioncontrol.hasversioning(project_path): from pootle.scripts import hooks message = "New files added from %s based on templates" % \ (settings.TITLE) filestocommit = [] for new_file in new_files: try: filestocommit.extend( hooks.hook(self.project.code, "precommit", new_file.file.name, author=None, message=message)) except ImportError: # Failed to import the hook - we're going to assume there # just isn't a hook to import. That means we'll commit the # original file. filestocommit.append(new_file.file.name) success = True try: output = versioncontrol.add_files(project_path, filestocommit, message) except Exception, e: logging.error(u"Failed to add files: %s", e) success = False for new_file in new_files: try: hooks.hook(self.project.code, "postcommit", new_file.file.name, success=success) except: #FIXME: We should not hide the exception - makes # development impossible pass