Hello community, here is the log from the commit of package python-translation-finder for openSUSE:Factory checked in at 2019-07-22 17:19:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-translation-finder (Old) and /work/SRC/openSUSE:Factory/.python-translation-finder.new.4126 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-translation-finder" Mon Jul 22 17:19:35 2019 rev:5 rq:717567 version:1.6 Changes: -------- --- /work/SRC/openSUSE:Factory/python-translation-finder/python-translation-finder.changes 2019-06-03 18:57:48.492374601 +0200 +++ /work/SRC/openSUSE:Factory/.python-translation-finder.new.4126/python-translation-finder.changes 2019-07-22 17:19:36.481907296 +0200 @@ -1,0 +2,10 @@ +Mon Jul 22 12:32:02 UTC 2019 - Tomáš Chvátal <tchva...@suse.com> + +- Update to 1.6: + * Improved discovery of POT files. + * Added support for subtitle files supported in Weblate 3.7. + * Improved detection of actual JSON formats. + * Added support for detecting PHP files. + * Improved detection of YAML formats. + +------------------------------------------------------------------- Old: ---- 1.5.tar.gz New: ---- 1.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-translation-finder.spec ++++++ --- /var/tmp/diff_new_pack.sJhExx/_old 2019-07-22 17:19:37.009907153 +0200 +++ /var/tmp/diff_new_pack.sJhExx/_new 2019-07-22 17:19:37.009907153 +0200 @@ -20,7 +20,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define modname translation-finder Name: python-translation-finder -Version: 1.5 +Version: 1.6 Release: 0 Summary: Translation Files Finder License: GPL-3.0-or-later @@ -28,20 +28,20 @@ URL: https://github.com/WeblateOrg/translation-finder # test_data/linked has to be symlink, hance using github tar ball Source: https://github.com/WeblateOrg/translation-finder/archive/%{version}.tar.gz -BuildRequires: %{python_module PyYAML} BuildRequires: %{python_module chardet} BuildRequires: %{python_module clint} BuildRequires: %{python_module pytest-runner} BuildRequires: %{python_module pytest} BuildRequires: %{python_module requests-toolbelt} +BuildRequires: %{python_module ruamel.yaml} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module six} BuildRequires: %{python_module twine} BuildRequires: fdupes BuildRequires: python-pathlib2 BuildRequires: python-rpm-macros -Requires: python-PyYAML Requires: python-chardet +Requires: python-ruamel.yaml Requires: python-setuptools Requires: python-six Requires(post): update-alternatives ++++++ 1.5.tar.gz -> 1.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/.travis.yml new/translation-finder-1.6/.travis.yml --- old/translation-finder-1.5/.travis.yml 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/.travis.yml 2019-06-26 13:35:51.000000000 +0200 @@ -1,9 +1,10 @@ language: python +dist: xenial python: - "2.7" - - "3.4" - "3.5" - "3.6" + - "3.7" - "pypy3" matrix: include: @@ -31,9 +32,6 @@ - choco install python2 - export PATH="/c/Python27:/c/Python27/Scripts:$PATH" - python -m pip install --upgrade pip wheel - # Obtain Python 3.7 from xenial as per https://github.com/travis-ci/travis-ci/issues/9815 - - python: 3.7 - dist: xenial install: # Get newer pip and whell for binary caching support - pip install --upgrade pip wheel diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/CHANGES.rst new/translation-finder-1.6/CHANGES.rst --- old/translation-finder-1.5/CHANGES.rst 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/CHANGES.rst 2019-06-26 13:35:51.000000000 +0200 @@ -1,6 +1,16 @@ Changelog ========= +1.6 +--- + +* Released on 26th June 2019. +* Improved discovery of POT files. +* Added support for subtitle files supported in Weblate 3.7. +* Improved detection of actual JSON formats. +* Added support for detecting PHP files. +* Improved detection of YAML formats. + 1.5 --- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/README.rst new/translation-finder-1.6/README.rst --- old/translation-finder-1.5/README.rst 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/README.rst 2019-06-26 13:35:51.000000000 +0200 @@ -32,13 +32,13 @@ >>> from pprint import pprint >>> results = discover('translation_finder/test_data/') >>> len(results) - 13 + 19 >>> pprint(results[0].match) {'file_format': 'aresource', 'filemask': 'app/src/res/main/values-*/strings.xml', 'name': 'android', 'template': 'app/src/res/main/values/strings.xml'} - >>> pprint(results[5].match) + >>> pprint(results[8].match) {'file_format': 'po', 'filemask': 'locales/*.po', 'new_base': 'locales/messages.pot'} @@ -49,7 +49,7 @@ >>> pprint(results[0].meta) {'discovery': 'TransifexDiscovery', 'origin': 'Transifex', 'priority': 500} - >>> pprint(results[5].meta) + >>> pprint(results[8].meta) {'discovery': 'GettextDiscovery', 'origin': None, 'priority': 1000} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/requirements.txt new/translation-finder-1.6/requirements.txt --- old/translation-finder-1.5/requirements.txt 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/requirements.txt 2019-06-26 13:35:51.000000000 +0200 @@ -1,4 +1,4 @@ pathlib2; python_version < '3.4' six chardet -pyyaml +ruamel.yaml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/scripts/generate-language-data new/translation-finder-1.6/scripts/generate-language-data --- old/translation-finder-1.5/scripts/generate-language-data 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/scripts/generate-language-data 2019-06-26 13:35:51.000000000 +0200 @@ -82,6 +82,7 @@ "sa", "io", "no", + "nav", "source", } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/__init__.py new/translation-finder-1.6/translation_finder/__init__.py --- old/translation-finder-1.5/translation_finder/__init__.py 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/translation_finder/__init__.py 2019-06-26 13:35:51.000000000 +0200 @@ -26,4 +26,4 @@ from .finder import Finder __all__ = ("Finder", "discover", "DiscoveryResult") -__version__ = "1.5" +__version__ = "1.6" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/api.py new/translation-finder-1.6/translation_finder/api.py --- old/translation-finder-1.5/translation_finder/api.py 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/translation_finder/api.py 2019-06-26 13:35:51.000000000 +0200 @@ -27,14 +27,19 @@ from .discovery.files import ( AndroidDiscovery, AppStoreDiscovery, + ASSDiscovery, FluentDiscovery, GettextDiscovery, JavaDiscovery, JoomlaDiscovery, JSONDiscovery, OSXDiscovery, + PHPDiscovery, QtDiscovery, RESXDiscovery, + SRTDiscovery, + SSADiscovery, + SUBDiscovery, WebExtensionDiscovery, XliffDiscovery, YAMLDiscovery, @@ -44,18 +49,23 @@ BACKENDS = [ TransifexDiscovery, + AndroidDiscovery, + AppStoreDiscovery, + ASSDiscovery, FluentDiscovery, GettextDiscovery, - QtDiscovery, - AndroidDiscovery, - OSXDiscovery, JavaDiscovery, JoomlaDiscovery, + JSONDiscovery, + OSXDiscovery, + PHPDiscovery, + QtDiscovery, RESXDiscovery, - XliffDiscovery, + SRTDiscovery, + SSADiscovery, + SUBDiscovery, WebExtensionDiscovery, - AppStoreDiscovery, - JSONDiscovery, + XliffDiscovery, YAMLDiscovery, ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/discovery/files.py new/translation-finder-1.6/translation_finder/discovery/files.py --- old/translation-finder-1.5/translation_finder/discovery/files.py 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/translation_finder/discovery/files.py 2019-06-26 13:35:51.000000000 +0200 @@ -21,9 +21,11 @@ """Individual discovery rules for translation formats.""" from __future__ import absolute_import, unicode_literals +import json from itertools import chain -import yaml +import six +from ruamel.yaml import YAML, YAMLError from .base import BaseDiscovery, EncodingDiscovery @@ -47,6 +49,13 @@ mono["file_format"] = "po-mono" yield mono + def fill_in_new_base(self, result): + super(GettextDiscovery, self).fill_in_new_base(result) + if "new_base" not in result: + pot_name = result["filemask"].replace("po/*/", "pot/") + "t" + if self.finder.has_file(pot_name): + result["new_base"] = pot_name + class QtDiscovery(BaseDiscovery): """Qt Linguist files discovery.""" @@ -190,9 +199,43 @@ class JSONDiscovery(BaseDiscovery): """JSON files discovery.""" - file_format = "json" + file_format = "json-nested" mask = "*.json" + def adjust_format(self, result): + if "template" not in result: + return + + path = list(self.finder.mask_matches(result["template"]))[0] + + if not hasattr(path, "open"): + return + + with self.finder.open(path, "r") as handle: + data = json.load(handle) + if not isinstance(data, dict): + return + all_strings = True + i18next = False + for key, value in data.items(): + if ( + isinstance(value, dict) + and "message" in value + and "description" in value + ): + result["file_format"] = "webextension" + break + if not isinstance(key, six.string_types) or not isinstance( + value, six.string_types + ): + all_strings = False + break + elif key.endswith("_plural") or "{{" in value: + i18next = True + + if all_strings and i18next: + result["file_format"] = "i18next" + class FluentDiscovery(BaseDiscovery): """Fluent files discovery.""" @@ -229,8 +272,50 @@ return with self.finder.open(path, "rb") as handle: - data = yaml.load(handle) + yaml = YAML() + try: + data = yaml.load(handle) + except YAMLError: + return if isinstance(data, dict) and len(data) == 1: key = list(data.keys())[0] - if result["filemask"].replace("*", key) == result["template"]: + if "filemask" in result: + if result["filemask"].replace("*", key) == result["template"]: + result["file_format"] = "ruby-yaml" + elif key in result["template"]: result["file_format"] = "ruby-yaml" + + +class SRTDiscovery(BaseDiscovery): + """SRT subtitle files discovery.""" + + file_format = "srt" + mask = "*.srt" + + +class SUBDiscovery(BaseDiscovery): + """SUB subtitle files discovery.""" + + file_format = "sub" + mask = "*.sub" + + +class ASSDiscovery(BaseDiscovery): + """ASS subtitle files discovery.""" + + file_format = "ass" + mask = "*.ass" + + +class SSADiscovery(BaseDiscovery): + """SSA subtitle files discovery.""" + + file_format = "ssa" + mask = "*.ssa" + + +class PHPDiscovery(BaseDiscovery): + """PHP files discovery.""" + + file_format = "php" + mask = "*.php" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/languages.py new/translation-finder-1.6/translation_finder/languages.py --- old/translation-finder-1.5/translation_finder/languages.py 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/translation_finder/languages.py 2019-06-26 13:35:51.000000000 +0200 @@ -51,11 +51,13 @@ "anp", "ar", "ar_ar", + "ar_bh", "ar_dz", "ar_eg", "ar_kw", "ar_ma", "ar_sa", + "ar_ye", "ara", "arabic", "arg", @@ -87,6 +89,7 @@ "bel", "bem", "ben", + "ber", "bez", "bg", "bh", @@ -394,10 +397,10 @@ "mya", "na", "nah", + "nan", "nap", "naq", "nau", - "nav", "nb", "nb_no", "nbl", @@ -415,6 +418,7 @@ "nnh", "nno", "no_nb", + "no_no", "nob", "nor", "norwegian", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/test_api.py new/translation-finder-1.6/translation_finder/test_api.py --- old/translation-finder-1.5/translation_finder/test_api.py 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/translation_finder/test_api.py 2019-06-26 13:35:51.000000000 +0200 @@ -64,6 +64,22 @@ "name": "android", "template": "app/src/res/main/values/strings.xml", }, + {"file_format": "json-nested", "filemask": "json/bi-*.json"}, + { + "file_format": "i18next", + "filemask": "json/i18next-*.json", + "template": "json/i18next-en.json", + }, + { + "file_format": "json-nested", + "filemask": "json/nested-*.json", + "template": "json/nested-en.json", + }, + { + "file_format": "webextension", + "filemask": "json/webext-*.json", + "template": "json/webext-en.json", + }, { "filemask": "locales/*.po", "new_base": "locales/messages.pot", @@ -111,6 +127,16 @@ "file_format": "ruby-yaml", "template": "yaml/en.yml", }, + { + "filemask": "yaml/*/nomatch.yml", + "template": "yaml/en/nomatch.yml", + "file_format": "yaml", + }, + { + "filemask": "yaml/*/corrupt.yml", + "template": "yaml/en/corrupt.yml", + "file_format": "yaml", + }, ], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/test_data/json/bi-cs.json new/translation-finder-1.6/translation_finder/test_data/json/bi-cs.json --- old/translation-finder-1.5/translation_finder/test_data/json/bi-cs.json 1970-01-01 01:00:00.000000000 +0100 +++ new/translation-finder-1.6/translation_finder/test_data/json/bi-cs.json 2019-06-26 13:35:51.000000000 +0200 @@ -0,0 +1,6 @@ +{ + "Hello, world!\n": "", + "Orangutan has %d banana.\n": "", + "Try Weblate at https://demo.weblate.org/!\n": "", + "Thank you for using Weblate.": "" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/test_data/json/i18next-en.json new/translation-finder-1.6/translation_finder/test_data/json/i18next-en.json --- old/translation-finder-1.5/translation_finder/test_data/json/i18next-en.json 1970-01-01 01:00:00.000000000 +0100 +++ new/translation-finder-1.6/translation_finder/test_data/json/i18next-en.json 2019-06-26 13:35:51.000000000 +0200 @@ -0,0 +1,6 @@ +{ + "hello": "Hello", + "apple": "I have an apple", + "apple_plural": "I have {{count}} apples", + "apple_negative": "I have no apples" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/test_data/json/nested-en.json new/translation-finder-1.6/translation_finder/test_data/json/nested-en.json --- old/translation-finder-1.5/translation_finder/test_data/json/nested-en.json 1970-01-01 01:00:00.000000000 +0100 +++ new/translation-finder-1.6/translation_finder/test_data/json/nested-en.json 2019-06-26 13:35:51.000000000 +0200 @@ -0,0 +1,8 @@ +{ + "weblate": { + "hello": "Hello, world!\n", + "orangutan": "Orangutan has %d banana.\n", + "try": "Try Weblate at https://demo.weblate.org/!\n", + "thanks": "Thank you for using Weblate." + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/test_data/json/webext-en.json new/translation-finder-1.6/translation_finder/test_data/json/webext-en.json --- old/translation-finder-1.5/translation_finder/test_data/json/webext-en.json 1970-01-01 01:00:00.000000000 +0100 +++ new/translation-finder-1.6/translation_finder/test_data/json/webext-en.json 2019-06-26 13:35:51.000000000 +0200 @@ -0,0 +1,18 @@ +{ + "hello": { + "message": "Hello, world!\n", + "description": "Description" + }, + "orangutan": { + "message": "Orangutan has %d banana.\n", + "description": "Description" + }, + "try": { + "message": "Try Weblate at https://demo.weblate.org/!\n", + "description": "Description" + }, + "thanks": { + "message": "Thank you for using Weblate.", + "description": "Description" + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/test_data/yaml/en/corrupt.yml new/translation-finder-1.6/translation_finder/test_data/yaml/en/corrupt.yml --- old/translation-finder-1.5/translation_finder/test_data/yaml/en/corrupt.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/translation-finder-1.6/translation_finder/test_data/yaml/en/corrupt.yml 2019-06-26 13:35:51.000000000 +0200 @@ -0,0 +1 @@ +" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/test_data/yaml/en/nomatch.yml new/translation-finder-1.6/translation_finder/test_data/yaml/en/nomatch.yml --- old/translation-finder-1.5/translation_finder/test_data/yaml/en/nomatch.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/translation-finder-1.6/translation_finder/test_data/yaml/en/nomatch.yml 2019-06-26 13:35:51.000000000 +0200 @@ -0,0 +1,5 @@ +weblate: + hello: "Hello, world!\n" + orangutan: "Orangutan has %d banana.\n" + try: "Try Weblate at https://demo.weblate.org/!\n" + thanks: "Thank you for using Weblate." diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/translation-finder-1.5/translation_finder/test_discovery.py new/translation-finder-1.6/translation_finder/test_discovery.py --- old/translation-finder-1.5/translation_finder/test_discovery.py 2019-05-29 10:22:34.000000000 +0200 +++ new/translation-finder-1.6/translation_finder/test_discovery.py 2019-06-26 13:35:51.000000000 +0200 @@ -93,6 +93,8 @@ "Source/WebCore/platform/gtk/po/sv.po", "desktop-docs/gpl/sr/sr.po", "desktop-docs/gpl/sr@latin/s...@latin.po", + "po/jp/rawhide/pages/welcome/Welcome.po", + "pot/rawhide/pages/welcome/Welcome.pot", ] ) ) @@ -125,6 +127,11 @@ "filemask": "Source/WebCore/platform/gtk/po/*.po", "file_format": "po", }, + { + "file_format": "po", + "filemask": "po/*/rawhide/pages/welcome/Welcome.po", + "new_base": "pot/rawhide/pages/welcome/Welcome.pot", + }, ], ) @@ -550,17 +557,17 @@ [ { "filemask": "tr/wizard-*.json", - "file_format": "json", + "file_format": "json-nested", "template": "tr/wizard-en.json", }, { "filemask": "tr/register-*.json", - "file_format": "json", + "file_format": "json-nested", "template": "tr/register-en.json", }, { "filemask": "tr/recordings-*.json", - "file_format": "json", + "file_format": "json-nested", "template": "tr/recordings-en.json", }, ],