Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions render50
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,7 @@ def concatenate(output, inputs):

def cprint(text="", color=None, on_color=None, attrs=None, end="\n"):
"""Colorize text (and wraps to terminal's width)."""

# Assume 80 in case not running in a terminal
columns, _ = get_terminal_size_fallback()
if columns == 0:
columns = 80

# Print text, flushing output
columns, _ = shutil.get_terminal_size()
termcolor.cprint(fill(text, columns, drop_whitespace=False, replace_whitespace=False),
color=color, on_color=on_color, attrs=attrs, end=end)
sys.stdout.flush()
Expand Down Expand Up @@ -444,16 +438,6 @@ def get(file):
raise RuntimeError("Could not read {}.".format(file))


def get_terminal_size_fallback():
try:
# Attempt to get terminal size
columns, rows = os.get_terminal_size()
except OSError:
# Fallback to default size if running in a non-terminal environment
columns, rows = shutil.get_terminal_size(fallback=(80, 20))
return columns, rows


def join(a, b):
"""Join a and b, where each is a URL, an absolute path, or a relative path."""

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
python_requires=">=3.9",
scripts=["render50"],
url="https://github.com/cs50/render50",
version="9.2.7"
version="9.2.8"
)
Loading