generated from mwc/lab_terminal
26 lines
709 B
Python
26 lines
709 B
Python
# fancy_printing.py
|
|
# -----------------
|
|
# By MWC Contributors
|
|
#
|
|
# This module defines the `fancy_printing` function,
|
|
# which nicely formats and prints a list of strings.
|
|
# All the other python programs in this lab import
|
|
# `fancy_printing`.
|
|
|
|
from click import secho
|
|
from textwrap import wrap
|
|
|
|
def print_fancy(paragraphs):
|
|
"""Formats and prints paragraphs.
|
|
`paragraphs` should be a list of strings.
|
|
"""
|
|
for paragraph in paragraphs:
|
|
wrapped_text = wrap(paragraph, initial_indent=' ', subsequent_indent=' ')
|
|
for line in wrapped_text:
|
|
secho(line, fg='cyan')
|
|
print('')
|
|
|
|
if __name__ == '__main__':
|
|
print_fancy(["This is a just a helper program :)"])
|
|
|