- if (filename.endswith("_base") or
- filename.startswith("base_") or
- filename == "base" or
- filename.find("_base_") > 0):
- base_template_count += 1
- assert base_template_count == 1
+ if RE_BASE.search(basename.lower()):
+ base_modules.append(filename)
+
+ if not base_modules:
+ msg = (
+ "No base module detected in the following files "
+ "from the template directory: {}"
+ ).format(", ".join(filenames))
+ elif len(base_modules) > 1:
+ msg = (
+ "Multiple base modules detected in the template "
+ "directory, but only one is allowed: {}"
+ ).format(", ".join(base_modules))
+ else:
+ msg = ""
+
+ assert len(base_modules) == 1, msg