From fe9f5a92729734c353ae7c4778451f62b95af8dc Mon Sep 17 00:00:00 2001 From: Maks Snegov Date: Mon, 2 Feb 2026 20:59:18 -0800 Subject: [PATCH] Improve library status output formatting Add dynamic column width alignment for library names up to 30 chars. Prevents excessive whitespace when library names vary significantly in length while maintaining readability for typical names. --- dsc/client.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dsc/client.py b/dsc/client.py index 98b2029..56c7ec1 100644 --- a/dsc/client.py +++ b/dsc/client.py @@ -198,13 +198,18 @@ class SeafileClient: def watch_status(self): prev_status = dict() + max_name_len = 0 + fmt = "Library {:%ds} {}" % max_name_len while True: time.sleep(const.STATUS_POLL_PERIOD) cur_status = self.get_status() - for folder, state in cur_status.items(): - if state != prev_status.get(folder): - logging.info("Library %s:\t%s", folder, state) - prev_status[folder] = cur_status[folder] + for library, state in cur_status.items(): + if state != prev_status.get(library): + if 30 > len(library) > max_name_len: + max_name_len = len(library) + fmt = "Library {:%ds} {}" % max_name_len + logging.info(fmt.format(library, state)) + prev_status[library] = cur_status[library] def get_local_libraries(self) -> set: cmd = "seaf-cli list"