示例#1
0
    def handle(self, *args, **options):
        fulltext = Fulltext()
        # Optimize index
        if options['optimize']:
            self.optimize_index(fulltext)
            return
        # Optionally rebuild indices from scratch
        if options['clean']:
            fulltext.cleanup()

        # Open writer
        source_writer = fulltext.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] = fulltext.get_target_index(
                        lang).writer()
                # Update target index
                if unit.translation:
                    fulltext.update_target_unit_index(target_writers[lang],
                                                      unit)
                # Update source index
                fulltext.update_source_unit_index(source_writer, unit)

        finally:
            # Close all writers
            source_writer.commit()
            for code in target_writers:
                target_writers[code].commit()
示例#2
0
    def handle(self, *args, **options):
        # Optimize index
        if options['optimize']:
            optimize_fulltext()
            return
        fulltext = Fulltext()
        # Optionally rebuild indices from scratch
        if options['clean'] or options['all']:
            fulltext.cleanup()

        if options['all']:
            self.process_all(fulltext)
        else:
            self.process_filtered(fulltext, **options)
示例#3
0
    def handle(self, *args, **options):
        # Optimize index
        if options['optimize']:
            optimize_fulltext()
            return
        fulltext = Fulltext()
        # Optionally rebuild indices from scratch
        if options['clean'] or options['all']:
            fulltext.cleanup()

        if options['all']:
            self.process_all(fulltext)
        else:
            self.process_filtered(fulltext, **options)
示例#4
0
    def clone_test_repos(self):
        dirs = ['test-repo.git', 'test-repo.hg', 'test-repo.svn']
        # Remove possibly existing directories
        for name in dirs:
            path = self.get_repo_path(name)
            if os.path.exists(path):
                shutil.rmtree(path, onerror=remove_readonly)

        # Remove cached paths
        keys = ['git_repo_path', 'mercurial_repo_path', 'subversion_repo_path']
        for key in keys:
            if key in self.__dict__:
                del self.__dict__[key]

        # 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
        Fulltext.cleanup()
示例#5
0
文件: utils.py 项目: dekoza/weblate
    def clone_test_repos(self):
        dirs = ['test-repo.git', 'test-repo.hg', 'test-repo.svn']
        # Remove possibly existing directories
        for name in dirs:
            path = self.get_repo_path(name)
            if os.path.exists(path):
                shutil.rmtree(path, onerror=remove_readonly)

        # Remove cached paths
        keys = ['git_repo_path', 'mercurial_repo_path', 'subversion_repo_path']
        for key in keys:
            if key in self.__dict__:
                del self.__dict__[key]

        # 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
        Fulltext.cleanup()
示例#6
0
    def handle(self, *args, **options):
        fulltext = Fulltext()
        # Optimize index
        if options['optimize']:
            self.optimize_index(fulltext)
            return
        # Optionally rebuild indices from scratch
        if options['clean']:
            fulltext.cleanup()

        # Open writer
        source_writer = fulltext.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] = fulltext.get_target_index(
                        lang
                    ).writer()
                # Update target index
                if unit.translation:
                    fulltext.update_target_unit_index(
                        target_writers[lang], unit
                    )
                # Update source index
                fulltext.update_source_unit_index(source_writer, unit)

        finally:
            # Close all writers
            source_writer.commit()
            for code in target_writers:
                target_writers[code].commit()
示例#7
0
    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.mercurial_base_repo_path = os.path.join(settings.DATA_DIR,
                                                     'test-base-repo.hg')
        # Repository on which tests will be performed
        self.mercurial_repo_path = os.path.join(settings.DATA_DIR,
                                                'test-repo.hg')

        # Path where to clone remote repo for tests
        self.subversion_base_repo_path = os.path.join(settings.DATA_DIR,
                                                      'test-base-repo.svn')
        # Repository on which tests will be performed
        self.subversion_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.mercurial_base_repo_path,
                              'test-base-repo.hg.tar')

        # Remove possibly existing directory
        if os.path.exists(self.mercurial_repo_path):
            shutil.rmtree(self.mercurial_repo_path, onerror=remove_readonly)

        # Create repository copy for the test
        shutil.copytree(self.mercurial_base_repo_path,
                        self.mercurial_repo_path)

        # Extract repo for testing
        self.optional_extract(self.subversion_base_repo_path,
                              'test-base-repo.svn.tar')

        # Remove possibly existing directory
        if os.path.exists(self.subversion_repo_path):
            shutil.rmtree(self.subversion_repo_path, onerror=remove_readonly)

        # Create repository copy for the test
        shutil.copytree(self.subversion_base_repo_path,
                        self.subversion_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
        Fulltext.cleanup()
示例#8
0
    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.mercurial_base_repo_path = os.path.join(
            settings.DATA_DIR,
            'test-base-repo.hg'
        )
        # Repository on which tests will be performed
        self.mercurial_repo_path = os.path.join(
            settings.DATA_DIR,
            'test-repo.hg'
        )

        # Path where to clone remote repo for tests
        self.subversion_base_repo_path = os.path.join(
            settings.DATA_DIR,
            'test-base-repo.svn'
        )
        # Repository on which tests will be performed
        self.subversion_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.mercurial_base_repo_path,
            'test-base-repo.hg.tar'
        )

        # Remove possibly existing directory
        if os.path.exists(self.mercurial_repo_path):
            shutil.rmtree(self.mercurial_repo_path, onerror=remove_readonly)

        # Create repository copy for the test
        shutil.copytree(
            self.mercurial_base_repo_path, self.mercurial_repo_path
        )

        # Extract repo for testing
        self.optional_extract(
            self.subversion_base_repo_path,
            'test-base-repo.svn.tar'
        )

        # Remove possibly existing directory
        if os.path.exists(self.subversion_repo_path):
            shutil.rmtree(self.subversion_repo_path, onerror=remove_readonly)

        # Create repository copy for the test
        shutil.copytree(
            self.subversion_base_repo_path,
            self.subversion_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
        Fulltext.cleanup()