[damned-lies] Allow custom pot methods also for doc domains
- From: Claude Paroz <claudep src gnome org>
- To: svn-commits-list gnome org
- Subject: [damned-lies] Allow custom pot methods also for doc domains
- Date: Thu, 25 Jun 2009 21:39:52 +0000 (UTC)
commit 401bf768aa0fcb0c966313f2b7b74e1611a4a207
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Jun 25 23:39:39 2009 +0200
Allow custom pot methods also for doc domains
stats/management/commands/update-stats.py | 2 +
stats/models.py | 30 ++++++++++++++++++++--------
2 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/stats/management/commands/update-stats.py b/stats/management/commands/update-stats.py
index 29421db..cf47f84 100644
--- a/stats/management/commands/update-stats.py
+++ b/stats/management/commands/update-stats.py
@@ -52,6 +52,7 @@ class Command(BaseCommand):
self.get_lock_for_module(module_arg, branch.name)
branch.update_stats(options['force'])
except:
+ print >> sys.stderr, traceback.format_exc()
print "Error while updating stats for %s (branch '%s')" % (module_arg, branch.name)
finally:
self.release_lock_for_module(module_arg, branch.name)
@@ -69,6 +70,7 @@ class Command(BaseCommand):
self.get_lock_for_module(mod.name, branch.name)
branch.update_stats(options['force'])
except:
+ print >> sys.stderr, traceback.format_exc()
print "Error while updating stats for %s (branch '%s')" % (mod.name, branch.name)
finally:
self.release_lock_for_module(mod.name, branch.name)
diff --git a/stats/models.py b/stats/models.py
index 18ac03f..67b9225 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -311,10 +311,14 @@ class Branch(models.Model):
# 3. Generate a fresh pot file
# ****************************
if dom.dtype == 'ui':
- potfile, errs = dom.generate_pot_file(domain_path)
+ potfile, errs = dom.generate_pot_file(self)
linguas = utils.get_ui_linguas(self.co_path(), domain_path)
- elif dom.dtype == 'doc': # only gnome-doc-utils toolchain supported so far for docs
- potfile, errs = utils.generate_doc_pot_file(domain_path, dom.potbase(), self.module.name, settings.DEBUG)
+ elif dom.dtype == 'doc':
+ if dom.pot_method:
+ potfile, errs = dom.generate_pot_file(self)
+ else:
+ # Standard gnome-doc-utils pot generation
+ potfile, errs = utils.generate_doc_pot_file(domain_path, dom.potbase(), self.module.name, settings.DEBUG)
if not potfile:
print >> sys.stderr, "\n".join([e[1] for e in errs])
continue
@@ -394,7 +398,7 @@ class Branch(models.Model):
langstats = utils.po_file_stats(outpo, True)
if linguas['langs'] is not None and lang not in linguas['langs']:
- langstats['errors'].append("warn-ext", linguas['error'])
+ langstats['errors'].append(("warn-ext", linguas['error']))
if dom.dtype == "doc":
fig_stats = utils.get_fig_stats(outpo)
for fig in fig_stats:
@@ -439,10 +443,12 @@ class Branch(models.Model):
pofile = os.path.join(dom_path, f)
flist.append((lang, pofile))
if domain.dtype == "doc":
- for d in os.listdir(dom_path):
- pofile = os.path.join(dom_path, d, d + ".po")
- if os.path.isfile(pofile):
- flist.append((d, pofile))
+ for lang_dir in os.listdir(dom_path):
+ for base_name in [lang_dir, domain.name.replace("_","/")]:
+ pofile = os.path.join(dom_path, lang_dir, base_name + ".po")
+ if os.path.isfile(pofile):
+ flist.append((lang_dir, pofile))
+ break
return flist
def checkout(self):
@@ -652,9 +658,10 @@ class Domain(models.Model):
else:
return self.potbase()
- def generate_pot_file(self, vcs_path):
+ def generate_pot_file(self, current_branch):
""" Return the pot file generated, and the error if any """
+ vcs_path = os.path.join(current_branch.co_path(), self.directory)
pot_command = self.pot_method
podir = vcs_path
env = None
@@ -672,6 +679,11 @@ class Domain(models.Model):
(status, output, errs) = utils.run_shell_command(command, env=env)
potfile = os.path.join(vcs_path, self.potbase() + ".pot")
+ if not os.access(potfile, os.R_OK):
+ # Try to get POT file from command output, with path relative to checkout root
+ m = re.search('([\w/]*\.pot)', output)
+ if m:
+ potfile = os.path.join(current_branch.co_path(), m.group(0))
if status != utils.STATUS_OK or not os.access(potfile, os.R_OK):
return "", (("error", ugettext_noop("Error regenerating POT file for %(file)s:\n<pre>%(cmd)s\n%(output)s</pre>")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]