Files
spark/tools/py/core/build_step.py
John Colvin c8eb51c303 build (refactor): Move web build scripts to tools/py
Even though they're specific to the web CMakeLists proj, it's good to have all
build scripts in one place
2022-09-21 00:17:31 -05:00

28 lines
819 B
Python

import termcolor
class BuildStep:
def __init__(self, header, body=None, begin_color='green', end_color='cyan'):
self.header = header
self.body = body
self.begin_color = begin_color
self.end_color = end_color
def _desc_parts(self):
parts = [self.header]
if self.body is not None:
parts.append(self.body)
return parts
def __str__(self):
return ': '.join(self._desc_parts())
def __enter__(self):
termcolor.cprint(
f'\n* BEGIN {self.header}', color=self.begin_color, flush=True)
if self.body is not None:
print(f'{self.body}', flush=True)
def __exit__(self, exc_type, exc_val, exc_tb):
termcolor.cprint(
f'* END {self.header}', color=self.end_color, flush=True)