- if RE_BASE.search(filename.lower()):
- base_template_count += 1
- assert base_template_count == 1, 'must be 1 "*_base_*" in %s not %d' % (
- filenames,
- base_template_count,
- )
+ 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