From ff1d5402a1a2427638df0e0d04cac523c83ea2d1 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 27 May 2019 22:51:53 -0700 Subject: [PATCH] Python 2.7 doesn't have indent --- buildtools/config.py | 12 ++++++++++++ wscript | 5 ++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/buildtools/config.py b/buildtools/config.py index 7066e8d1..398779e8 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -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()) diff --git a/wscript b/wscript index 2cebd0e6..67baae99 100644 --- a/wscript +++ b/wscript @@ -9,9 +9,8 @@ import sys import os -import textwrap -from buildtools.config import Config, runcmd, msg +from buildtools.config import Config, runcmd, msg, indent cfg = Config(True) #----------------------------------------------------------------------------- @@ -539,7 +538,7 @@ def build(bld): if not isWindows: cmd = ' '.join(bld.env.CC) + ' --version' copmpiler = runcmd(cmd, getOutput=True, echoCmd=False) - copmpiler = textwrap.indent(copmpiler, ' '*5) + copmpiler = indent(copmpiler, ' '*5) msg("**** Compiler: {}\n{}".format(cmd, copmpiler)) # Copy the license files from wxWidgets