[damned-lies] Ensure file sources in doc pot files are relative to help dir
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Ensure file sources in doc pot files are relative to help dir
- Date: Sun, 11 Mar 2018 08:45:01 +0000 (UTC)
commit 4fe5f8e1dfad5fe4712b97142f3e36ee1f904aec
Author: Claude Paroz <claude 2xlibre net>
Date: Sun Mar 11 09:41:53 2018 +0100
Ensure file sources in doc pot files are relative to help dir
Fixes bug #794227.
stats/tests/tests.py | 4 ++++
stats/utils.py | 16 +++++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index ab8693f..4e6fa13 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -577,6 +577,8 @@ class UtilsTests(TestCase):
self.assertEqual(doc_format.format, 'docbook')
pot_path = os.path.join(help_path, "C", "release-notes.pot")
self.assertTrue(os.access(pot_path, os.R_OK))
+ with open(pot_path, mode='r') as fh:
+ self.assertIn('#: C/rnlookingforward.xml:11(para)', fh.read())
res = utils.get_fig_stats(pot_path, doc_format=doc_format)
self.assertEqual(len(res), 1)
self.assertEqual(res[0]['path'], "figures/rnusers.nautilus.png")
@@ -592,6 +594,8 @@ class UtilsTests(TestCase):
self.assertEqual(potfile, os.path.join(help_path, 'C', 'gnome-hello.pot'))
self.assertEqual(doc_format.tool, 'itstool')
self.assertEqual(doc_format.format, 'mallard')
+ with open(potfile, mode='r') as fh:
+ self.assertIn('#: C/what-is.page:7', fh.read())
res = utils.get_fig_stats(potfile, doc_format=doc_format)
self.assertEqual(len(res), 1)
self.assertEqual(res[0]['path'], "figures/gnome-hello-logo.png")
diff --git a/stats/utils.py b/stats/utils.py
index b7f2714..e66601c 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -52,11 +52,11 @@ class DocFormat:
return isinstance(self.makefile, MesonfileWrapper)
def source_files(self, force_all=False):
- """Return absolute paths to help source files."""
- base_path = os.path.dirname(self.makefile.path)
+ """Return help source files, with path relative to help base dir."""
if force_all:
+ base_path = os.path.dirname(self.makefile.path)
source_dir = os.path.join(base_path, 'C')
- return os.listdir(source_dir)
+ return [os.path.join('C', fname) for fname in os.listdir(source_dir)]
else:
sources = self.makefile.read_variable(self.include_var)
if not sources:
@@ -70,7 +70,7 @@ class DocFormat:
if isinstance(sources, str):
sources = sources.split()
return [
- os.path.join(base_path, 'C', src) for src in sources
+ os.path.join('C', src) for src in sources
if src not in ("", "$(NULL)")
]
@@ -414,22 +414,20 @@ def generate_doc_pot_file(vcs_path, potbase, moduleid):
modulename = moduleid
for index_page in ("index.docbook", modulename + ".xml", moduleid + ".xml"):
if os.access(os.path.join(vcs_path, "C", index_page), os.R_OK):
- files.append(index_page)
+ files.append(os.path.join("C", index_page))
break
if not files:
# Last try: only one xml file in C/...
xml_files = [f for f in doc_format.source_files(force_all=True) if f.endswith(".xml")]
if len(xml_files) == 1:
- files.append(os.path.basename(xml_files[0]))
+ files.append(xml_files[0])
else:
errors.append(("error", ugettext_noop("%s doesn’t point to a real file, probably a macro.")
% doc_format.module_var))
return "", errors, doc_format
files.extend(doc_format.source_files())
potfile = os.path.join(vcs_path, "C", potbase + ".pot")
- command = doc_format.command(potfile, [
- os.path.join("C", f) if not os.path.isabs(f) else f for f in files
- ])
+ command = doc_format.command(potfile, files)
status, output, errs = run_shell_command(command, cwd=vcs_path)
if status != STATUS_OK:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]