From b5c081fbf38909d8afbfd6fbd57a7d8bb8429baa Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 12 Jun 2024 11:06:27 +0200 Subject: [PATCH] feat: Change count display to lead with count The actual count is now the first item on each line, to make it easier to sort, strip, delete and compare afterwards. --- papis_extract/formatter.py | 6 +++--- tests/test_formatting.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/papis_extract/formatter.py b/papis_extract/formatter.py index 76c977b..986d691 100644 --- a/papis_extract/formatter.py +++ b/papis_extract/formatter.py @@ -66,10 +66,10 @@ def format_count( count += 1 return ( + f"{count} " f"{document.get('author', '')}" - f"{' - ' if 'author' in document else ''}" # only put separator if author - f"{document.get('title', '')}: " - f"{count}\n" + f"{': ' if 'author' in document else ''}" # only put separator if author + f"{document.get('title', '')}" ).rstrip() diff --git a/tests/test_formatting.py b/tests/test_formatting.py index 5b805a7..b018041 100644 --- a/tests/test_formatting.py +++ b/tests/test_formatting.py @@ -48,7 +48,7 @@ def test_markdown_setext(): def test_count_default(): fmt = format_count - assert fmt(document, annotations) == ("""document-author - document-title: 2""") + assert fmt(document, annotations) == ("""2 document-author: document-title""") def test_csv_default():