Commit 0aee7b2e authored by Claude Paroz's avatar Claude Paroz

Catch DocFormat exception in can_build_docs

parent 684a77c4
......@@ -23,7 +23,7 @@ from django.utils import dateformat
from django.db import models
from common.fields import DictionaryField, JSONField
from common.utils import is_site_admin, run_shell_command
from common.utils import UndetectableDocFormat, is_site_admin, run_shell_command
from stats import utils, signals
from stats.doap import update_doap_infos
from people.models import Person
......@@ -786,7 +786,10 @@ class Domain(models.Model):
self.dtype == 'doc' and self.layout == 'help/{lang}/{lang}.po')
def can_build_docs(self, branch):
return self.dtype == 'doc' and self.doc_format(branch).format == 'mallard'
try:
return self.dtype == 'doc' and self.doc_format(branch).format == 'mallard'
except UndetectableDocFormat:
return False
def get_po_path(self, locale):
"""
......
......@@ -46,6 +46,10 @@ def patchedAddunit(self, unit):
TranslationStore.addunit = patchedAddunit
class UndetectableDocFormat(Exception):
pass
class DocFormat:
itstool_regex = re.compile("^msgid \"external ref=\'(?P<path>[^\']*)\' md5=\'(?P<hash>[^\']*)\'\"")
xml2po_regex = re.compile("^msgid \"@@image: \'(?P<path>[^\']*)\'; md5=(?P<hash>[^\"]*)\"")
......@@ -55,7 +59,9 @@ class DocFormat:
self.vcs_path = branch.domain_path(domain)
self.makefile = MakefileWrapper.find_file(branch, [self.vcs_path])
if self.makefile is None:
raise Exception(gettext_noop("Unable to find a makefile for module %s") % branch.module.name)
raise UndetectableDocFormat(
gettext_noop("Unable to find a makefile for module %s") % branch.module.name
)
doc_id = self.makefile.read_variable("HELP_ID", "yelp.project_id")
uses_itstool = doc_id is not None or self.use_meson
has_page_files = any(f.suffix == '.page' for f in self.list_C_files())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment