def handle(self, *args, **options): # Optimize index if options['optimize']: self.optimize_index() return # Optionally rebuild indices from scratch if options['clean']: clean_indexes() # Open writer source_writer = get_source_index().writer() target_writers = {} try: # Process all units for unit in self.iterate_units(**options): lang = unit.translation.language.code # Lazy open writer if lang not in target_writers: target_writers[lang] = get_target_index(lang).writer() # Update target index if unit.translation: update_target_unit_index(target_writers[lang], unit) # Update source index update_source_unit_index(source_writer, unit) finally: # Close all writers source_writer.commit() for code in target_writers: target_writers[code].commit()
def handle(self, *args, **options): # Optionally rebuild indices from scratch if options["clean"]: clean_indexes() # Open writer source_writer = get_source_index().writer() target_writers = {} try: # Process all units for unit in self.iterate_units(*args, **options): lang = unit.translation.language.code # Lazy open writer if lang not in target_writers: target_writers[lang] = get_target_index(lang).writer() # Update target index if unit.translation: update_target_unit_index(target_writers[lang], unit) # Update source index update_source_unit_index(source_writer, unit) finally: # Close all writers source_writer.commit() for lang in target_writers: target_writers[lang].commit()
def clone_test_repos(self): # Path where to clone remote repo for tests self.git_base_repo_path = os.path.join(settings.DATA_DIR, 'test-base-repo.git') # Repository on which tests will be performed self.git_repo_path = os.path.join(settings.DATA_DIR, 'test-repo.git') # Path where to clone remote repo for tests self.hg_base_repo_path = os.path.join(settings.DATA_DIR, 'test-base-repo.hg') # Repository on which tests will be performed self.hg_repo_path = os.path.join(settings.DATA_DIR, 'test-repo.hg') # Path where to clone remote repo for tests self.svn_base_repo_path = os.path.join(settings.DATA_DIR, 'test-base-repo.svn') # Repository on which tests will be performed self.svn_repo_path = os.path.join(settings.DATA_DIR, 'test-repo.svn') # Extract repo for testing self.optional_extract(self.git_base_repo_path, 'test-base-repo.git.tar') # Remove possibly existing directory if os.path.exists(self.git_repo_path): shutil.rmtree(self.git_repo_path, onerror=remove_readonly) # Create repository copy for the test shutil.copytree(self.git_base_repo_path, self.git_repo_path) # Extract repo for testing self.optional_extract(self.hg_base_repo_path, 'test-base-repo.hg.tar') # Remove possibly existing directory if os.path.exists(self.hg_repo_path): shutil.rmtree(self.hg_repo_path, onerror=remove_readonly) # Create repository copy for the test shutil.copytree(self.hg_base_repo_path, self.hg_repo_path) # Extract repo for testing self.optional_extract(self.svn_base_repo_path, 'test-base-repo.svn.tar') # Remove possibly existing directory if os.path.exists(self.svn_repo_path): shutil.rmtree(self.svn_repo_path, onerror=remove_readonly) # Create repository copy for the test shutil.copytree(self.svn_base_repo_path, self.svn_repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.DATA_DIR, 'vcs', 'test') if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path, onerror=remove_readonly) # Remove indexes clean_indexes()
def clone_test_repos(self): # Path where to clone remote repo for tests self.git_base_repo_path = os.path.join( settings.DATA_DIR, 'test-base-repo.git' ) # Repository on which tests will be performed self.git_repo_path = os.path.join( settings.DATA_DIR, 'test-repo.git' ) # Path where to clone remote repo for tests self.hg_base_repo_path = os.path.join( settings.DATA_DIR, 'test-base-repo.hg' ) # Repository on which tests will be performed self.hg_repo_path = os.path.join( settings.DATA_DIR, 'test-repo.hg' ) # Extract repo for testing self.optional_extract( self.git_base_repo_path, 'test-base-repo.git.tar' ) # Remove possibly existing directory if os.path.exists(self.git_repo_path): shutil.rmtree(self.git_repo_path) # Create repository copy for the test shutil.copytree(self.git_base_repo_path, self.git_repo_path) # Extract repo for testing self.optional_extract( self.hg_base_repo_path, 'test-base-repo.hg.tar' ) # Remove possibly existing directory if os.path.exists(self.hg_repo_path): shutil.rmtree(self.hg_repo_path) # Create repository copy for the test shutil.copytree(self.hg_base_repo_path, self.hg_repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.DATA_DIR, 'vcs', 'test') if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path) # Remove indexes clean_indexes()
def setUp(self): # Path where to clone remote repo for tests self.git_base_repo_path = os.path.join(settings.DATA_DIR, 'test-base-repo.git') # Repository on which tests will be performed self.git_repo_path = os.path.join(settings.DATA_DIR, 'test-repo.git') # Path where to clone remote repo for tests self.hg_base_repo_path = os.path.join(settings.DATA_DIR, 'test-base-repo.hg') # Repository on which tests will be performed self.hg_repo_path = os.path.join(settings.DATA_DIR, 'test-repo.hg') # Clone repo for testing if not os.path.exists(self.git_base_repo_path): print('Cloning Git test repository to {0}...'.format( self.git_base_repo_path)) GitRepository.clone(GIT_URL, self.git_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.git_repo_path): shutil.rmtree(self.git_repo_path) # Create repository copy for the test shutil.copytree(self.git_base_repo_path, self.git_repo_path) if HgRepository.is_supported(): # Clone repo for testing if not os.path.exists(self.hg_base_repo_path): print('Cloning Mercurial test repository to {0}...'.format( self.hg_base_repo_path)) HgRepository.clone(HG_URL, self.hg_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.hg_repo_path): shutil.rmtree(self.hg_repo_path) # Create repository copy for the test shutil.copytree(self.hg_base_repo_path, self.hg_repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.DATA_DIR, 'vcs', 'test') if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path) # Remove indexes clean_indexes()
def setUp(self): # Path where to clone remote repo for tests self.git_base_repo_path = os.path.join(settings.DATA_DIR, "test-base-repo.git") # Repository on which tests will be performed self.git_repo_path = os.path.join(settings.DATA_DIR, "test-repo.git") # Path where to clone remote repo for tests self.hg_base_repo_path = os.path.join(settings.DATA_DIR, "test-base-repo.hg") # Repository on which tests will be performed self.hg_repo_path = os.path.join(settings.DATA_DIR, "test-repo.hg") # Clone repo for testing if not os.path.exists(self.git_base_repo_path): print("Cloning Git test repository to {0}...".format(self.git_base_repo_path)) GitRepository.clone(GIT_URL, self.git_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.git_repo_path): shutil.rmtree(self.git_repo_path) # Create repository copy for the test shutil.copytree(self.git_base_repo_path, self.git_repo_path) # Clone repo for testing if not os.path.exists(self.hg_base_repo_path): print("Cloning Mercurial test repository to {0}...".format(self.hg_base_repo_path)) HgRepository.clone(HG_URL, self.hg_base_repo_path, bare=True) # Remove possibly existing directory if os.path.exists(self.hg_repo_path): shutil.rmtree(self.hg_repo_path) # Create repository copy for the test shutil.copytree(self.hg_base_repo_path, self.hg_repo_path) # Remove possibly existing project directory test_repo_path = os.path.join(settings.DATA_DIR, "vcs", "test") if os.path.exists(test_repo_path): shutil.rmtree(test_repo_path) # Remove indexes clean_indexes()