Name no template fields that Bindery does not have

This commit is contained in:
tim
2026-10-03 08:09:41 +02:00
parent 3e29ab6bf0
commit 323bec3c04
2 changed files with 5 additions and 8 deletions
+1 -2
View File
@@ -472,8 +472,7 @@ names, so a template from Calibre gives the same name in Bindery. Bindery adds `
| `{last_modified}` | The date when the chapters last changed. | | `{last_modified}` | The date when the chapters last changed. |
| `{id}` | The CWA book ID. For a story with no library book, and without CWA, the Bindery story ID. | | `{id}` | The CWA book ID. For a story with no library book, and without CWA, the Bindery story ID. |
- A field with no value becomes empty text. So does a field that Bindery does not have, such as - A field with no value becomes empty text.
`{rating}` or a custom column.
- `{field:format|text before|text after}` adds the two texts only when the field has a value. Each - `{field:format|text before|text after}` adds the two texts only when the field has a value. Each
of the three parts can be empty. `{series:|| - }` adds ` - ` after the series. of the three parts can be empty. `{series:|| - }` adds ` - ` after the series.
- The format is a Python format. `{series_index:0>3s}` gives `002`, and `{title:.20s}` gives the - The format is a Python format. `{series_index:0>3s}` gives `002`, and `{title:.20s}` gives the
+4 -6
View File
@@ -1,7 +1,6 @@
"""The file name templates, against the results of Calibre 9.2.1. """The file name templates, against the results of Calibre 9.2.1.
Each expected text is what Calibre gives for the same book and template. Bindery has no rating and no custom Each expected text is what Calibre gives for the same book and template.
columns, and it has one date format, so there are no cases for those.
""" """
import pytest import pytest
@@ -70,7 +69,7 @@ def test_reference_cases_for_a_missing_series_and_for_alphabetic_order():
("{title[0]}{title[1]}", "Bo"), ("{title[0]}{title[1]}", "Bo"),
("{title} {{{id}}}", "Book, The {42}"), ("{title} {{{id}}}", "Book, The {42}"),
(" {title} -\t{authors} ", "Book, The - Ann Writer & Ben Reader"), (" {title} -\t{authors} ", "Book, The - Ann Writer & Ben Reader"),
("{ title }{rating}{isbn}{#custom}", ""), ("{ title }{other}", ""),
("a|b|c{title:|-|}", "a|b|c-Book, The"), ("a|b|c{title:|-|}", "a|b|c-Book, The"),
("{series}/{series_index:0>2s| | - }{title}", "Saga, The/ 2.35 - Book, The"), ("{series}/{series_index:0>2s| | - }{title}", "Saga, The/ 2.35 - Book, The"),
], ],
@@ -179,8 +178,7 @@ def test_check_refuses_what_bindery_does_not_support(template, error):
def test_check_accepts_the_templates_of_calibre(): def test_check_accepts_the_templates_of_calibre():
templates = ("", "{author_sort}/{title}/{title} - {authors}", "{title:>255s}", "x" * 1024, "{#saga_index:0>3s}") for template in ("", "{author_sort}/{title}/{title} - {authors}", "{title:>255s}", "x" * 1024):
for template in templates:
ft.check(template) ft.check(template)
@@ -199,7 +197,7 @@ def test_file_name_is_the_last_part_of_the_path():
assert file_name("{author_sort}/{title}/{title} - {authors}") == "Book, The - Ann Writer & Ben Reader" assert file_name("{author_sort}/{title}/{title} - {authors}") == "Book, The - Ann Writer & Ben Reader"
assert file_name("{series}//{title} /") == "Book, The" assert file_name("{series}//{title} /") == "Book, The"
assert file_name("{author_sort[0]}/{series}", series="") == "W" assert file_name("{author_sort[0]}/{series}", series="") == "W"
assert file_name("{series}/{rating}", series="") == "" assert file_name("{series}/{other}", series="") == ""
assert file_name(" / ") == "" assert file_name(" / ") == ""