[damned-lies] Allow read of meson.build data_dirs gettext parameter
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Allow read of meson.build data_dirs gettext parameter
- Date: Wed, 28 Mar 2018 11:52:01 +0000 (UTC)
commit e46aba9212a6bd6f6f7a63f6bd1cbfc19e7d9a46
Author: Claude Paroz <claude 2xlibre net>
Date: Wed Mar 28 13:48:30 2018 +0200
Allow read of meson.build data_dirs gettext parameter
Fixes bug #794742.
stats/models.py | 6 ++++++
stats/tests/meson-ui2.build | 10 ++++++++++
stats/tests/tests.py | 9 +++++++++
stats/utils.py | 14 ++++++++++++--
4 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 0327be4..77eb135 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -931,6 +931,12 @@ class Domain(models.Model):
extra_args = makefile.read_variable('gettext.args')
if extra_args:
pot_command.extend(extra_args)
+ datadirs = makefile.read_variable('gettext.data_dirs')
+ if datadirs:
+ env['GETTEXTDATADIRS'] = ':'.join(
+ [env['GETTEXTDATADIRS']] +
+ [str(branch.co_path / path) for path in datadirs]
+ )
# Added last as some chars in it may disturb CLI parsing
bugs_url = self.module.get_bugs_enter_url()
if bugs_url:
diff --git a/stats/tests/meson-ui2.build b/stats/tests/meson-ui2.build
new file mode 100644
index 0000000..cfac442
--- /dev/null
+++ b/stats/tests/meson-ui2.build
@@ -0,0 +1,10 @@
+i18n.gettext('gnome-builder',
+ preset: 'glib',
+ args: [
+ '--msgid-bugs-address=https://gitlab.gnome.org/GNOME/gnome-builder/issues',
+ ],
+ data_dirs: [
+ join_paths(meson.source_root(), 'src/gstyle/data'),
+ join_paths(meson.source_root(), 'data/style-schemes')
+ ],
+)
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 61fa27b..73f4036 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -585,6 +585,15 @@ class UtilsTests(TestCase):
self.assertEqual(meson_file.read_variable('gettext.preset'), 'glib')
self.assertEqual(meson_file.read_variable('gettext.args'), ['--keyword=Description'])
+ # UI meson file (with data_dirs)
+ path = Path(__file__).parent / "meson-ui2.build"
+ meson_file = utils.MesonfileWrapper(self.branch, path)
+ self.assertEqual(
+ meson_file.read_variable('gettext.data_dirs'),
+ [str(self.branch.co_path / 'src/gstyle/data'),
+ str(self.branch.co_path / 'data/style-schemes')]
+ )
+
def test_read_cmake_variables(self):
domain = Domain.objects.create(
module=self.mod, name='help', dtype='doc', directory='help_mallard'
diff --git a/stats/utils.py b/stats/utils.py
index 97f7758..4ba10ac 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -234,15 +234,25 @@ class MesonfileWrapper(MakefileWrapper):
def gettext(self, *args, **kwargs):
catched['gettext.project_id'] = args[0]
- for var_name in {'languages', 'args', 'preset'}:
+ for var_name in MesonfileWrapper.i18n_gettext_kwargs:
if var_name in kwargs:
catched['gettext.%s' % var_name] = kwargs[var_name]
catcher = VarCatcher()
+ this_instance = self
+
+ class MesonMock:
+ def __getattr__(self, name):
+ return MagicMock()
+
+ def source_root(self):
+ return str(this_instance.branch.co_path)
+
meson_locals = {
'gnome': catcher, 'i18n': catcher,
'GNOME': catcher, 'I18N': catcher,
- 'install_data': MagicMock(), 'meson': MagicMock(),
+ 'install_data': MagicMock(), 'meson': MesonMock(),
+ 'join_paths': lambda *args: os.sep.join(args),
}
while True:
try:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]