Commit 66fa40c3 by Paul Oswald

evaluate content at function start

parent 921e4ed2
...@@ -28,13 +28,14 @@ def dedent(content): ...@@ -28,13 +28,14 @@ def dedent(content):
as it fails to dedent multiline docstrings that include as it fails to dedent multiline docstrings that include
unindented text on the initial line. unindented text on the initial line.
""" """
content = unicode(content)
whitespace_counts = [len(line) - len(line.lstrip(' ')) whitespace_counts = [len(line) - len(line.lstrip(' '))
for line in content.splitlines()[1:] if line.lstrip()] for line in content.splitlines()[1:] if line.lstrip()]
# unindent the content if needed # unindent the content if needed
if whitespace_counts: if whitespace_counts:
whitespace_pattern = '^' + (' ' * min(whitespace_counts)) whitespace_pattern = '^' + (' ' * min(whitespace_counts))
content = re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', unicode(content)) content = re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', content)
return content.strip() return content.strip()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment