feat: Implement double-quoted filename features. #13

Merged
glen merged 7 commits from quoted_filename into main 2021-02-12 17:11:07 +00:00
Showing only changes of commit 10f73a4828 - Show all commits

View File

@ -91,9 +91,12 @@ is checked for `{! ... !}`.
# OK, we have found (the start of) an inclusion and must process it
preamble = line[:include_match.start()]
remainder = line[include_match.end(1):]
doublequoted = False
body_pattern = StreamInclusion.include_quoted_file
if include_match[2].isspace():
body_pattern = StreamInclusion.include_bare_file
elif include_match[2] == '"':
doublequoted = True
body_match = body_pattern.search(remainder)
if not body_match:
for extra_line in self.input_stream:
@ -105,7 +108,12 @@ is checked for `{! ... !}`.
errmsg = "semiliterate: End of file while scanning for `!}`"
utils.log.error(errmsg)
raise EOFError(errmsg)
include_path = self.include_root + '/' + body_match['fn']
filename = body_match['fn']
if doublequoted:
filename = (filename.encode('latin-1', 'backslashreplace')
.decode('unicode-escape'))
include_path = self.include_root + '/' + filename
print(f"Including |{include_path}|")
new_root = re.match(r'(.*)/', include_path)[1]
try:
include_parameters = yaml.safe_load(body_match['yml'])