def from_code(cls, *lines, index=0):
line = lines[index].strip()
match = (cls.RE_ENV_SET.match(line) or
cls.RE_QUOTED_CAPITALS.search(line))
if not match:
log.debug("Skipped line %s without variable: %r", index + 1, line)
return None
name = match.group('name')
context = line
with suppress(IndexError):
if context.endswith('{'):
context += lines[index + 1].strip()
context += lines[index + 2].strip()
variable = cls(name, context=context)
log.info("Loaded variable: %s", variable)
return variable
评论列表
文章目录