Python 2.7 doesn't have indent

This commit is contained in:
Robin Dunn
2019-05-27 22:51:53 -07:00
parent 1f12bb7733
commit ff1d5402a1
2 changed files with 14 additions and 3 deletions

View File

@@ -968,3 +968,15 @@ def updateLicenseFiles(cfg):
text += f.read() + '\n\n'
with open('LICENSE.txt', 'w') as f:
f.write(text)
try:
from textwrap import indent
except ImportError:
def indent(text, prefix, predicate=None):
if predicate is None:
def predicate(line):
return line.strip()
def prefixed_lines():
for line in text.splitlines(True):
yield (prefix + line if predicate(line) else line)
return ''.join(prefixed_lines())