Minor clarification of dedent().
This commit is contained in:
parent
9e082f4eae
commit
2557100b9e
|
@ -334,16 +334,16 @@ def dedent(text):
|
||||||
lines = text.expandtabs().split('\n')
|
lines = text.expandtabs().split('\n')
|
||||||
margin = None
|
margin = None
|
||||||
for line in lines:
|
for line in lines:
|
||||||
content = len(line.lstrip())
|
content = line.lstrip()
|
||||||
if not content:
|
if not content:
|
||||||
continue
|
continue
|
||||||
indent = len(line) - content
|
indent = len(line) - len(content)
|
||||||
if margin is None:
|
if margin is None:
|
||||||
margin = indent
|
margin = indent
|
||||||
else:
|
else:
|
||||||
margin = min(margin, indent)
|
margin = min(margin, indent)
|
||||||
|
|
||||||
if margin is not None:
|
if margin is not None and margin > 0:
|
||||||
for i in range(len(lines)):
|
for i in range(len(lines)):
|
||||||
lines[i] = lines[i][margin:]
|
lines[i] = lines[i][margin:]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue