Skip to content

Commit 1682f11

Browse files
committed
Small cleanup
1 parent 41baee3 commit 1682f11

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cf_xarray/formatting.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import warnings
22

3+
STAR = " * "
4+
TAB = len(STAR) * " "
5+
36

47
def _format_missing_row(row: str, rich: bool) -> str:
58
if rich:
@@ -44,8 +47,6 @@ def make_text_section(
4447
vardict = getattr(accessor, attr, {})
4548
except ValueError:
4649
vardict = {}
47-
star = " * "
48-
tab = len(star) * " "
4950

5051
# Sort keys if there aren't extra keys,
5152
# preserve default keys order otherwise.
@@ -65,7 +66,7 @@ def make_text_section(
6566
# Star for keys with dims only, tab otherwise
6667
rows = [
6768
(
68-
f"{star if dims and set(value) <= set(dims) else tab}"
69+
f"{STAR if dims and set(value) <= set(dims) else TAB}"
6970
f"{_format_cf_name(key, rich)}: {_format_varname(sorted(value), rich)}"
7071
)
7172
for key, value in vardict.items()
@@ -76,10 +77,10 @@ def make_text_section(
7677
missing_keys = [key for key in default_keys if key not in vardict]
7778
if missing_keys:
7879
rows.append(
79-
_format_missing_row(tab + ", ".join(missing_keys) + ": n/a", rich)
80+
_format_missing_row(TAB + ", ".join(missing_keys) + ": n/a", rich)
8081
)
8182
elif not rows:
82-
rows.append(_format_missing_row(tab + "n/a", rich))
83+
rows.append(_format_missing_row(TAB + "n/a", rich))
8384

8485
return _print_rows(subtitle, rows, rich)
8586

@@ -120,7 +121,7 @@ def _format_flags(accessor, rich):
120121

121122
flag_dict = create_flag_dict(accessor._obj)
122123
rows = [
123-
f" {_format_varname(v, rich)}: {_format_cf_name(k, rich)}"
124+
f"{TAB}{_format_varname(v, rich)}: {_format_cf_name(k, rich)}"
124125
for k, v in flag_dict.items()
125126
]
126127
return _print_rows("Flag Meanings", rows, rich)

0 commit comments

Comments
 (0)