def test_init_fs_project_cmd_nosync(settings, test_fs, tmpdir, revision): settings.POOTLE_FS_WORKING_PATH = str(tmpdir) fs_path = test_fs.path("data/fs/example_fs/non_gnu_style_minimal/") tr_path = "<language_code>/<filename>.<ext>" call_command( "init_fs_project", "foo", fs_path, tr_path, "--nosync", "--checkstyle=standard", "--filetypes=po", "--source-language=en", "--name=Foo" ) project = Project.objects.get(code='foo') assert project is not None assert project.code == "foo" assert project.fullname == "Foo" assert "po" in project.filetypes.values_list("name", flat=True) assert project.checkstyle == "standard" assert project.source_language.code == "en" assert project.treestyle == 'pootle_fs' assert project.config.get('pootle_fs.fs_type') == 'localfs' assert project.config.get('pootle_fs.fs_url') == fs_path assert project.config.get( 'pootle_fs.translation_mappings')['default'] == tr_path assert project.translationproject_set.all().count() == 0 plugin = FSPlugin(project) plugin.fetch() state = plugin.state() assert "fs_untracked: 1" in str(state)
def _parse_tps_to_create(self, project): plugin = FSPlugin(project) plugin.fetch() untracked_languages = set( fs.pootle_path.split("/")[1] for fs in plugin.state()["fs_untracked"]) new_langs = ([ lang for lang in untracked_languages if lang in self.languages ] if self.languages else untracked_languages) return Language.objects.filter(code__in=new_langs).exclude( code__in=project.translationproject_set.values_list( "language__code", flat=True))
def handle_all_stores(self, translation_project, **options): path_glob = "%s*" % translation_project.pootle_path plugin = FSPlugin(translation_project.project) plugin.fetch() if translation_project.project.pk not in self.warn_on_conflict: state = plugin.state() if any(k in state for k in ["conflict", "conflict_untracked"]): logger.warn( "The project '%s' has conflicting changes in the database " "and translation files. Use `pootle fs resolve` to tell " "pootle how to merge", translation_project.project.code) self.warn_on_conflict.append(translation_project.project.pk) if not options["skip_missing"]: plugin.add(pootle_path=path_glob, update="fs") plugin.sync(pootle_path=path_glob, update="fs")
def handle_all_stores(self, translation_project, **options): path_glob = "%s*" % translation_project.pootle_path plugin = FSPlugin(translation_project.project) plugin.fetch() if translation_project.project.pk not in self.warn_on_conflict: state = plugin.state() if any(k in state for k in ["conflict", "conflict_untracked"]): logger.warn( "The project '%s' has conflicting changes in the database " "and translation files. Use `pootle fs resolve` to tell " "pootle how to merge", translation_project.project.code) self.warn_on_conflict.append( translation_project.project.pk) if not options["skip_missing"]: plugin.add(pootle_path=path_glob, update="fs") plugin.sync(pootle_path=path_glob, update="fs")