Move indent_block to common

This commit is contained in:
Dave Halter committed 2020-02-19 09:15:39 +01:00
1 parent b1d3c7ef52
commit 50be49544d
5 files changed
+13 -13

No files matched your search

+10
View File
@@ -24,3 +24,13 @@ def monkeypatch(obj, attribute_name, new_value):
yield
finally:
setattr(obj, attribute_name, old_value)
def indent_block(text, indention=' '):
"""This function indents a text block with a default of four spaces."""
temp = ''
while text and text[-1] == '\n':
temp += text[-1]
text = text[:-1]
lines = text.split('\n')
return '\n'.join(map(lambda s: indention + s, lines)) + temp