diff --git a/npf/section.py b/npf/section.py index 8ea1d30..e2cadef 100644 --- a/npf/section.py +++ b/npf/section.py @@ -35,11 +35,11 @@ class SectionFactory: varPattern = "([a-zA-Z0-9_:-]+)[=](" + Variable.VALUE_REGEX + ")?" namePattern = re.compile( "^(?P" + Variable.TAGS_REGEX + "[:])?(?Pinfo|config|variables|exit|pypost|pyexit|late_variables|" - "include (?P[a-zA-Z0-9_./-]+)(?P([ \t]+" + varPattern + ")+)?|" - "(init-)?file(:?[@](?P[a-zA-Z0-9]+))? (?P[a-zA-Z0-9_.${}-]+)(:? (?Pnoparse))?(:? (?Pjinja))?|" - "require|" + "include\s+(?P[a-zA-Z0-9_./-]+)(?P([ \t]+" + varPattern + ")+)?|" + "(init-)?file(:?[@](?P[a-zA-Z0-9]+))?\s+(?P[a-zA-Z0-9_.${}-]+)(:? (?Pnoparse))?(:? (?Pjinja))?|" + "require(:?\s+(?Pjinja))?|" "import(:?[@](?P[a-zA-Z0-9]+)(:?[-](?P[*0-9]+))?)?[ \t]+(?P" + Variable.VALUE_REGEX + ")(?P([ \t]+" + varPattern + ")+)?|" - "sendfile(:?[@](?P[a-zA-Z0-9]+))?[ \t]+(?P.*)|" + + "sendfile(:?[@](?P[a-zA-Z0-9]+))?\s+(?P.*)|" + "(:?script|init|exit)(:?[@](?P[a-zA-Z0-9]+)(:?[-](?P[*0-9]+))?)?(:? (?Pjinja))?(?P([ \t]+" + varPattern + ")*))$") @staticmethod @@ -112,7 +112,7 @@ def build(test, data): s = SectionImport(None, matcher.group('includeName').strip(), params, is_include=True) return s elif sectionName == 'require': - s = SectionRequire() + s = SectionRequire(jinja=matcher.group('requireJinja')) return s elif sectionName == 'late_variables': s = SectionLateVariable() @@ -282,9 +282,10 @@ def finish(self, test): class SectionRequire(Section): - def __init__(self): + def __init__(self, jinja=False): super().__init__('require') self.content = '' + self.jinja = jinja def role(self): # For now, require is only on one node, the default one