devnomads-cli 0.5.3__tar.gz → 0.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/PKG-INFO +1 -1
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/devnomads_cli.egg-info/PKG-INFO +1 -1
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/dncli.py +5 -11
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/pyproject.toml +1 -1
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/tests/test_helpers.py +10 -10
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/LICENSE +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/README.md +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/devnomads_cli.egg-info/SOURCES.txt +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/devnomads_cli.egg-info/dependency_links.txt +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/devnomads_cli.egg-info/entry_points.txt +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/devnomads_cli.egg-info/requires.txt +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/devnomads_cli.egg-info/top_level.txt +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/setup.cfg +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/tests/test_cert.py +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/tests/test_cli.py +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/tests/test_config.py +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/tests/test_generate.py +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/tests/test_generated_cli.py +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/tests/test_hook.py +0 -0
- {devnomads_cli-0.5.3 → devnomads_cli-0.5.4}/tests/test_transfer.py +0 -0
|
@@ -342,14 +342,14 @@ def _render_kv(data: dict[str, Any], title: str | None) -> None:
|
|
|
342
342
|
def _auto_columns(rows: list[dict[str, Any]]) -> list[str]:
|
|
343
343
|
"""Choose the columns worth showing in a list view, from the data itself.
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
Two things get dropped, because a list is an overview and the full record
|
|
346
346
|
is always available via the matching ``show`` command (or ``-o json``):
|
|
347
347
|
|
|
348
348
|
* columns empty in every row (no information at all);
|
|
349
349
|
* columns holding a list of objects (instances, mailboxes, ips, ...) -
|
|
350
|
-
these are detail, belonging in the ``show`` view, not the overview
|
|
351
|
-
|
|
352
|
-
|
|
350
|
+
these are detail, belonging in the ``show`` view, not the overview.
|
|
351
|
+
|
|
352
|
+
Every other field is kept, even if its value is the same on every row.
|
|
353
353
|
"""
|
|
354
354
|
|
|
355
355
|
cols: list[str] = []
|
|
@@ -370,17 +370,11 @@ def _auto_columns(rows: list[dict[str, Any]]) -> list[str]:
|
|
|
370
370
|
for row in rows
|
|
371
371
|
)
|
|
372
372
|
|
|
373
|
-
|
|
373
|
+
return [
|
|
374
374
|
c
|
|
375
375
|
for c in cols
|
|
376
376
|
if any(not empty(row.get(c)) for row in rows) and not is_object_list(c)
|
|
377
377
|
]
|
|
378
|
-
if len(rows) > 1 and cols:
|
|
379
|
-
anchor = cols[0]
|
|
380
|
-
rendered = {c: {_cell(row.get(c)) for row in rows} for c in cols}
|
|
381
|
-
if any(len(values) > 1 for values in rendered.values()):
|
|
382
|
-
cols = [c for c in cols if c == anchor or len(rendered[c]) > 1]
|
|
383
|
-
return cols
|
|
384
378
|
|
|
385
379
|
|
|
386
380
|
def _render_rows(
|
|
@@ -231,25 +231,25 @@ def test_cell_detail_keeps_per_item_lines():
|
|
|
231
231
|
assert _cell(insts) == "id=7 state_last_known=running"
|
|
232
232
|
|
|
233
233
|
|
|
234
|
-
def
|
|
234
|
+
def test_auto_columns_drops_empty_and_object_lists_only():
|
|
235
235
|
rows = [
|
|
236
236
|
{"id": 1, "port": 80, "registry": "same", "blank": "", "instances": [{"i": 7}]},
|
|
237
237
|
{"id": 2, "port": 81, "registry": "same", "blank": "", "instances": [{"i": 8}]},
|
|
238
238
|
]
|
|
239
|
-
#
|
|
240
|
-
#
|
|
241
|
-
assert _auto_columns(rows) == ["id", "port"]
|
|
239
|
+
# blank is empty and instances is an object list -> dropped; every other
|
|
240
|
+
# scalar is kept, including the constant `registry`.
|
|
241
|
+
assert _auto_columns(rows) == ["id", "port", "registry"]
|
|
242
242
|
|
|
243
243
|
|
|
244
|
-
def
|
|
244
|
+
def test_auto_columns_keeps_constant_scalar_columns():
|
|
245
245
|
rows = [{"id": 1, "x": 9, "y": "a"}, {"id": 1, "x": 9, "y": "b"}]
|
|
246
|
-
#
|
|
247
|
-
assert _auto_columns(rows) == ["id", "y"]
|
|
246
|
+
# constant columns are no longer dropped - normal fields always show
|
|
247
|
+
assert _auto_columns(rows) == ["id", "x", "y"]
|
|
248
248
|
|
|
249
249
|
|
|
250
250
|
def test_auto_columns_single_row_keeps_nonempty_scalars():
|
|
251
251
|
rows = [{"id": 1, "name": "x", "blank": None, "items": [{"a": 1}]}]
|
|
252
|
-
#
|
|
252
|
+
# empty and object-list columns go, scalars stay
|
|
253
253
|
assert _auto_columns(rows) == ["id", "name"]
|
|
254
254
|
|
|
255
255
|
|
|
@@ -266,8 +266,8 @@ def test_object_table_uses_auto_columns():
|
|
|
266
266
|
{"emailaddress": "b@x", "quota": 2, "domain": "x"},
|
|
267
267
|
]
|
|
268
268
|
table = _object_table(items)
|
|
269
|
-
#
|
|
270
|
-
assert [c.header for c in table.columns] == ["emailaddress", "quota"]
|
|
269
|
+
# all scalar sub-fields are kept (empties/object-lists would be dropped)
|
|
270
|
+
assert [c.header for c in table.columns] == ["emailaddress", "quota", "domain"]
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
def test_render_kv_drops_empty_and_nests_objects(capsys):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|