[damned-lies] Changed get linguas APIs to pass the branch
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Changed get linguas APIs to pass the branch
- Date: Wed, 28 Mar 2018 11:51:51 +0000 (UTC)
commit b910a3c5e1c2db70a79027755baeee26ad3039ad
Author: Claude Paroz <claude 2xlibre net>
Date: Wed Mar 28 10:49:03 2018 +0200
Changed get linguas APIs to pass the branch
stats/models.py | 12 ++++++------
stats/utils.py | 26 ++++++++++++++++----------
2 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index b09e3fc..8d70a2d 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -440,14 +440,13 @@ class Branch(models.Model):
potfile, errs = dom.generate_pot_file(self)
else:
# Standard gnome-doc-utils pot generation
- potfile, errs, pot_method = utils.generate_doc_pot_file(
- domain_path, dom.potbase(), self.module.name)
+ potfile, errs, pot_method = utils.generate_doc_pot_file(self, dom)
else:
logging.error("Unknown domain type '%s', ignoring domain '%s'" % (
dom.dtype, dom.name))
continue
errors.extend(errs)
- linguas = dom.get_linguas(self.co_path)
+ linguas = dom.get_linguas(self)
if linguas['langs'] is None and linguas['error']:
errors.append(("warn", linguas['error']))
@@ -938,8 +937,9 @@ class Domain(models.Model):
pot_command.extend(['--msgid-bugs-address', bugs_url])
return pot_command, env
- def get_linguas(self, base_path):
+ def get_linguas(self, branch):
""" Return a linguas dict like this: {'langs':['lang1', lang2], 'error':"Error"} """
+ base_path = branch.co_path
if self.linguas_location:
# Custom (or no) linguas location
if self.linguas_location == 'no':
@@ -959,9 +959,9 @@ class Domain(models.Model):
'var': variable, 'file': file_path})}
# Standard linguas location
if self.dtype == 'ui':
- return utils.get_ui_linguas(base_path, base_path / self.directory)
+ return utils.get_ui_linguas(branch, self.directory)
elif self.dtype == 'doc':
- return utils.get_doc_linguas(base_path, base_path / self.directory)
+ return utils.get_doc_linguas(branch, self.directory)
else:
raise ValueError("Domain dtype should be one of 'ui', 'doc'")
diff --git a/stats/utils.py b/stats/utils.py
index 50fdf59..e3cfdf4 100644
--- a/stats/utils.py
+++ b/stats/utils.py
@@ -408,10 +408,12 @@ def check_potfiles(po_path):
)
return errors
-def generate_doc_pot_file(vcs_path, potbase, moduleid):
+
+def generate_doc_pot_file(branch, domain):
""" Return the pot file for a document-type domain, and the error if any """
errors = []
-
+ vcs_path = branch.domain_path(domain)
+ moduleid = branch.module.name
makefile = MakefileWrapper.find_file([vcs_path])
if makefile is None:
errors.append(
@@ -439,6 +441,7 @@ def generate_doc_pot_file(vcs_path, potbase, moduleid):
return "", errors, doc_format
files.extend(doc_format.source_files())
+ potbase = domain.potbase()
potfile = vcs_path / "C" / (potbase + ".pot")
command = doc_format.command(potfile, files)
status, output, errs = run_shell_command(command, cwd=vcs_path)
@@ -573,24 +576,25 @@ def insert_locale_in_linguas(linguas_path, locale):
fout.write(locale + "\n")
temp_linguas.replace(linguas_path)
-def get_ui_linguas(module_path, po_path):
+
+def get_ui_linguas(branch, subdir):
"""Get language list in one of po/LINGUAS, configure.ac or configure.in"""
- LINGUAShere = po_path / "LINGUAS"
- LINGUASpo = module_path / "po" / "LINGUAS" # if we're in eg. po-locations/
+ LINGUAShere = branch.co_path / subdir/ "LINGUAS"
+ LINGUASpo = branch.co_path / "po" / "LINGUAS" # if we're in eg. po-locations/
# is "lang" listed in either of po/LINGUAS, ./configure.ac(ALL_LINGUAS) or ./configure.in(ALL_LINGUAS)
for LINGUAS in [LINGUAShere, LINGUASpo]:
if LINGUAS.exists():
return read_linguas_file(LINGUAS)
# AS_ALL_LINGUAS is a macro that takes all po files by default
- status, output, errs = run_shell_command("grep -qs AS_ALL_LINGUAS %s%sconfigure.*" % (module_path,
os.sep))
+ status, output, errs = run_shell_command("grep -qs AS_ALL_LINGUAS %s%sconfigure.*" % (branch.co_path,
os.sep))
if status == 0:
return {'langs': None,
'error': ugettext_noop("No need to edit LINGUAS file or variable for this module")}
- configureac = module_path / "configure.ac"
- configurein = module_path / "configure.in"
+ configureac = branch.co_path / "configure.ac"
+ configurein = branch.co_path / "configure.in"
for configure in [configureac, configurein]:
found = MakefileWrapper(configure).read_variable('ALL_LINGUAS')
if found is not None:
@@ -599,10 +603,12 @@ def get_ui_linguas(module_path, po_path):
return {'langs':None,
'error': ugettext_noop("Don’t know where to look for the LINGUAS variable, ask the module
maintainer.") }
-def get_doc_linguas(module_path, po_path):
+
+def get_doc_linguas(branch, subdir):
"""Get language list in one Makefile.am (either path) """
linguas = None
- linguas_file = MakefileWrapper.find_file([po_path, module_path])
+ po_path = branch.co_path / subdir
+ linguas_file = MakefileWrapper.find_file([po_path, branch.co_path])
if linguas_file:
linguas = linguas_file.read_variable("DOC_LINGUAS", "HELP_LINGUAS", "gettext.languages")
if linguas is None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]