Пример #1
0
    def _setup_project_fs(self, project):
        from pootle_fs.utils import FSPlugin
        from pytest_pootle.utils import add_store_fs

        project.config["pootle_fs.fs_type"] = "localfs"
        project.config["pootle_fs.translation_mappings"] = {
            "default": "/<language_code>/<dir_path>/<filename>.<ext>"}
        project.config["pootle_fs.fs_url"] = "/tmp/path/for/setup"
        plugin = FSPlugin(project)
        for store in plugin.resources.stores:
            add_store_fs(
                store=store,
                fs_path=plugin.get_fs_path(store.pootle_path),
                synced=True)
Пример #2
0
    def setup_fs(self):
        from pytest_pootle.utils import add_store_fs

        from pootle_project.models import Project
        from pootle_fs.utils import FSPlugin

        project = Project.objects.get(code="project0")
        project.config["pootle_fs.fs_type"] = "localfs"
        project.config["pootle_fs.translation_mappings"] = {
            "default": "/<language_code>/<dir_path>/<filename>.<ext>"
        }
        project.config["pootle_fs.fs_url"] = "/tmp/path/for/setup"
        plugin = FSPlugin(project)
        for store in plugin.resources.stores:
            add_store_fs(store=store,
                         fs_path=plugin.get_fs_path(store.pootle_path),
                         synced=True)
Пример #3
0
def project0_dummy_plugin_no_stores(settings, request,
                                    no_fs_plugins, no_fs_files):
    from pytest_pootle.utils import add_store_fs

    from pootle.core.plugin import getter, provider
    from pootle_fs.delegate import fs_file, fs_plugins
    from pootle_fs.files import FSFile
    from pootle_fs.utils import FSPlugin
    from pootle_project.models import Project
    from pootle_store.models import Store

    settings.POOTLE_FS_PATH = "/tmp/foo/"
    project = Project.objects.get(code="project0")
    project.config["pootle_fs.fs_type"] = "dummyfs"
    project.config["pootle_fs.fs_url"] = "/foo/bar"
    stores = Store.objects.filter(
        translation_project__project=project)
    pootle_paths = list(stores.values_list("pootle_path", flat=True))

    class NoStoresDummyPlugin(DummyPlugin):

        def find_translations(self, fs_path=None, pootle_path=None):
            for pp in pootle_paths:
                if pootle_path and not fnmatch(pp, pootle_path):
                    continue
                fp = self.get_fs_path(pp)
                if fs_path and not fnmatch(fp, fs_path):
                    continue
                yield pp, fp

    @provider(fs_plugins, weak=False, sender=Project)
    def plugin_provider(**kwargs):
        return dict(dummyfs=NoStoresDummyPlugin)

    @getter(fs_file, weak=False, sender=NoStoresDummyPlugin)
    def fs_files_getter(**kwargs):
        return FSFile

    plugin = FSPlugin(project)
    for store in stores:
        add_store_fs(
            store=store,
            fs_path=plugin.get_fs_path(store.pootle_path),
            synced=True)
    return plugin
Пример #4
0
    def setup_fs(self):
        from pytest_pootle.utils import add_store_fs

        from django.conf import settings

        from pootle_project.models import Project
        from pootle_fs.utils import FSPlugin

        settings.POOTLE_FS_PATH = os.path.join(
            settings.POOTLE_TRANSLATION_DIRECTORY, "__fs_working_dir__")
        os.mkdir(settings.POOTLE_FS_PATH)

        project = Project.objects.get(code="project0")
        project.config["pootle_fs.fs_type"] = "localfs"
        project.config["pootle_fs.translation_paths"] = {
            "default": "/<language_code>/<dir_path>/<filename>.<ext>"}
        project.config["pootle_fs.fs_url"] = "/tmp/path/for/setup"
        plugin = FSPlugin(project)
        for store in plugin.resources.stores:
            add_store_fs(
                store=store,
                fs_path=plugin.get_fs_path(store.pootle_path),
                synced=True)
Пример #5
0
    def setup_fs(self):
        from pytest_pootle.utils import add_store_fs

        from django.conf import settings

        from pootle_project.models import Project
        from pootle_fs.utils import FSPlugin

        settings.POOTLE_FS_PATH = os.path.join(
            settings.POOTLE_TRANSLATION_DIRECTORY, "__fs_working_dir__")
        os.mkdir(settings.POOTLE_FS_PATH)

        project = Project.objects.get(code="project0")
        project.config["pootle_fs.fs_type"] = "localfs"
        project.config["pootle_fs.translation_paths"] = {
            "default": "/<language_code>/<dir_path>/<filename>.<ext>"
        }
        project.config["pootle_fs.fs_url"] = "/tmp/path/for/setup"
        plugin = FSPlugin(project)
        for store in plugin.resources.stores:
            add_store_fs(store=store,
                         fs_path=plugin.get_fs_path(store.pootle_path),
                         synced=True)