Use textwrap3 on Python 2

This commit is contained in:
Robin Dunn
2019-05-31 08:57:15 -07:00
parent d29f17353e
commit e234a65cd7
3 changed files with 7 additions and 12 deletions

View File

@@ -969,14 +969,3 @@ def updateLicenseFiles(cfg):
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())

View File

@@ -10,3 +10,4 @@ pytest
pytest-xdist
pytest-timeout
pathlib2 ; python_version < "3"
textwrap3 ; python_version < "3"

View File

@@ -10,7 +10,12 @@
import sys
import os
from buildtools.config import Config, runcmd, msg, indent
try:
from textwrap import indent
except ImportError:
from textwrap3 import indent
from buildtools.config import Config, runcmd, msg
cfg = Config(True)
#-----------------------------------------------------------------------------