Esempio n. 1
0
 def test_it(self, _walk, _isfile):
     # all pages translated, but split between vendor and community
     pontoon_config, vendor_config, files = self._list('it', _walk, _isfile)
     pontoon_files = ProjectFiles('it', [pontoon_config])
     vendor_files = ProjectFiles('it', [vendor_config])
     self.assertListEqual(files, [
         'firefox/feature.ftl',
         'firefox/home.ftl',
         'mozorg/mission.ftl',
     ])
     l10n_path = self.path('/it/firefox/home.ftl')
     ref_path = self.path('/en/firefox/home.ftl')
     file = File(l10n_path, 'it/firefox/home.ftl', locale='it')
     self.assertEqual(pontoon_config.filter(file), 'ignore')
     self.assertEqual(vendor_config.filter(file), 'error')
     self.assertIsNone(pontoon_files.match(l10n_path))
     self.assertIsNone(pontoon_files.match(ref_path))
     self.assertIsNotNone(vendor_files.match(l10n_path))
     self.assertIsNotNone(vendor_files.match(ref_path))
Esempio n. 2
0
 def test_gd(self, _walk, _isfile):
     # only community localization
     pontoon_config, vendor_config, files = self._list('gd', _walk, _isfile)
     pontoon_files = ProjectFiles('gd', [pontoon_config])
     vendor_files = ProjectFiles('gd', [vendor_config])
     self.assertListEqual(files, [
         'firefox/feature.ftl',
         'firefox/home.ftl',
         'mozorg/mission.ftl',
     ])
     l10n_path = self.path('/gd/firefox/home.ftl')
     ref_path = self.path('/en/firefox/home.ftl')
     self.assertEqual(
         pontoon_config.filter(
             File(l10n_path, 'gd/firefox/home.ftl', locale='gd')), 'error')
     self.assertIsNotNone(pontoon_files.match(l10n_path))
     self.assertIsNotNone(pontoon_files.match(ref_path))
     self.assertIsNone(vendor_files.match(l10n_path))
     self.assertIsNone(vendor_files.match(ref_path))
Esempio n. 3
0
    def resource_paths_with_pc(self):
        """
        List of absolute paths for all supported source resources
        as specified through project configuration.
        """
        path = self.source_directory_path
        project_files = ProjectFiles(None,
                                     [self.configuration.parsed_configuration])

        for root, dirnames, filenames in scandir.walk(path):
            if is_hidden(root):
                continue

            for filename in filenames:
                absolute_path = os.path.join(root, filename)
                if project_files.match(absolute_path):
                    yield absolute_path
Esempio n. 4
0
    def locale_resources(self, locale):
        """
        Return a list of Resource instances, which need to be enabled for the
        given locale.
        """
        resources = []
        project_files = ProjectFiles(locale.code, [self.parsed_configuration])

        for resource in self.vcs_project.db_project.resources.all():
            absolute_resource_path = os.path.join(
                self.vcs_project.source_directory_path,
                resource.path,
            )

            if project_files.match(absolute_resource_path):
                resources.append(resource)

        return resources
Esempio n. 5
0
 def test_reference(self, _walk, _isfile):
     pontoon_config, vendor_config, files = self._list(None, _walk, _isfile)
     pontoon_files = ProjectFiles(None, [pontoon_config])
     vendor_files = ProjectFiles(None, [vendor_config])
     self.assertListEqual(files, [
         'firefox/feature.ftl',
         'firefox/home.ftl',
         'mozorg/mission.ftl',
     ])
     ref_path = self.path('/en/firefox/feature.ftl')
     self.assertIsNotNone(pontoon_files.match(ref_path))
     self.assertIsNotNone(vendor_files.match(ref_path))
     ref_path = self.path('/en/firefox/home.ftl')
     self.assertIsNotNone(pontoon_files.match(ref_path))
     self.assertIsNotNone(vendor_files.match(ref_path))
     ref_path = self.path('/en/mozorg/mission.ftl')
     self.assertIsNotNone(pontoon_files.match(ref_path))
     self.assertIsNone(vendor_files.match(ref_path))
Esempio n. 6
0
 def test_de(self, _walk, _isfile):
     # home.ftl excluded completely by configs-special-templates.toml
     # firefox/* only in vendor
     pontoon_config, vendor_config, files = self._list('de', _walk, _isfile)
     pontoon_files = ProjectFiles('de', [pontoon_config])
     vendor_files = ProjectFiles('de', [vendor_config])
     self.assertListEqual(
         files,
         [
             'firefox/feature.ftl',
             # 'firefox/home.ftl',
             'mozorg/mission.ftl',
         ])
     l10n_path = self.path('/de/firefox/feature.ftl')
     ref_path = self.path('/en/firefox/feature.ftl')
     self.assertEqual(
         pontoon_config.filter(
             File(l10n_path, 'de/firefox/feature.ftl', locale='de')),
         'ignore')
     self.assertIsNone(pontoon_files.match(l10n_path))
     self.assertIsNone(pontoon_files.match(ref_path))
     self.assertIsNotNone(vendor_files.match(l10n_path))
     self.assertIsNotNone(vendor_files.match(ref_path))
     l10n_path = self.path('/de/firefox/home.ftl')
     ref_path = self.path('/en/firefox/home.ftl')
     self.assertEqual(
         pontoon_config.filter(
             File(l10n_path, 'de/firefox/home.ftl', locale='de')), 'ignore')
     self.assertIsNone(pontoon_files.match(l10n_path))
     self.assertIsNone(pontoon_files.match(ref_path))
     self.assertIsNone(vendor_files.match(l10n_path))
     self.assertIsNone(vendor_files.match(ref_path))
     l10n_path = self.path('/de/mozorg/mission.ftl')
     ref_path = self.path('/en/mozorg/mission.ftl')
     self.assertEqual(
         pontoon_config.filter(
             File(l10n_path, 'de/mozorg/mission.ftl', locale='de')),
         'error')
     self.assertIsNotNone(pontoon_files.match(l10n_path))
     self.assertIsNotNone(pontoon_files.match(ref_path))
     self.assertIsNone(vendor_files.match(l10n_path))
     self.assertIsNone(vendor_files.match(ref_path))