Skip to content

Commit

Permalink
fix(linewrap): try to prevent edge case by having one char margin (#338)
Browse files Browse the repository at this point in the history
Sometimes, if we are unlucky, the line wrap (maybe due to whitespace
somewhere) fails. So, we add one extra character to have a bit more
elbow room.
  • Loading branch information
engeir authored Mar 22, 2023
1 parent 4b5294d commit 2bdf2f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Binary file modified docs/demo/latest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ncdump-rich"
version = "0.3.3"
version = "0.3.4"
description = "Rich NcDump"
authors = ["Eirik Enger <eirroleng@gmail.com>"]
license = "GPL-3.0"
Expand Down
8 changes: 4 additions & 4 deletions src/ncdump_rich/ncdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def print_ncattr(key: str) -> None:
cprint("[bold white]NetCDF Global Attributes:[/bold white]")
for nc_attr in nc_attrs:
if any(
len(line) > width - 8
len(line) > width - 9
for line in str(nc_file.getncattr(nc_attr)).splitlines()
):
lineend = (
Expand All @@ -94,7 +94,7 @@ def print_ncattr(key: str) -> None:
[
textwrap.fill(
" ".join(line.split()),
width=width - 8,
width=width - 9,
tabsize=4,
break_long_words=False,
replace_whitespace=False,
Expand All @@ -111,7 +111,7 @@ def print_ncattr(key: str) -> None:
[
textwrap.fill(
" ".join(line.split()),
width=width - 8,
width=width - 9,
tabsize=4,
break_long_words=False,
replace_whitespace=False,
Expand Down Expand Up @@ -150,7 +150,7 @@ def print_ncattr(key: str) -> None:
if len(nc_vars) > 20:
cprint("\t[italic white]Number of variables: [/italic white]", len(nc_vars))
cprint("\t[italic white]Variables list: [/italic white]")
pp = pprint.PrettyPrinter(width=width - 8, compact=True)
pp = pprint.PrettyPrinter(width=width - 9, compact=True)
cprint(textwrap.indent(pp.pformat(nc_vars), "\t\t"))
else:
for var in nc_vars:
Expand Down

0 comments on commit 2bdf2f0

Please sign in to comment.