comictagger/testing/filenames.py

977 lines
28 KiB
Python
Raw Normal View History

2022-05-21 00:16:45 -07:00
"""
format is
(
"filename",
"reason or unique case",
{
"expected": "Dictionary of properties extracted from filename",
},
bool(xfail: expected failure on the old parser)
)
"""
2022-06-02 18:32:16 -07:00
from __future__ import annotations
import datetime
2022-07-13 19:56:34 -07:00
import os
import os.path
import pathlib
from contextlib import nullcontext as does_not_raise
import pytest
datadir = pathlib.Path(__file__).parent / "data"
cbz_path = datadir / "Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz"
names = [
(
"batman #3 title (DC).cbz",
"honorific and publisher in series",
{
"issue": "3",
"series": "batman",
"title": "title",
"publisher": "DC",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
"alternate": "",
},
(False, True),
),
(
"batman #3 title DC.cbz",
"honorific and publisher in series",
{
"issue": "3",
"series": "batman",
"title": "title DC",
"publisher": "DC",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
"alternate": "",
},
(False, True),
),
(
"ms. Marvel #3.cbz",
"honorific and publisher in series",
{
"issue": "3",
"series": "ms. Marvel",
"title": "",
"publisher": "Marvel",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
"alternate": "",
},
(False, False),
),
(
f"action comics #{datetime.datetime.now().year}.cbz",
"issue number is current year (digits == 4)",
{
"issue": f"{datetime.datetime.now().year}",
"series": "action comics",
"title": "",
"publisher": "",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
"alternate": "",
},
(False, False),
),
2023-08-04 21:04:21 -07:00
(
"action comics 1024.cbz",
"issue number is current year (digits == 4)",
{
"issue": "1024",
"series": "action comics",
"title": "",
"publisher": "",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
"alternate": "",
},
(False, False),
),
(
"Action Comics 1001 (2018).cbz",
"issue number is current year (digits == 4)",
{
"issue": "1001",
"series": "Action Comics",
"title": "",
"publisher": "",
"volume": "",
"year": "2018",
"remainder": "",
"issue_count": "",
"alternate": "",
},
(False, False),
),
(
"january jones #2.cbz",
"month in series",
{
"issue": "2",
"series": "january jones",
"title": "",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
"alternate": "",
},
(False, False),
),
(
"#52.cbz",
"issue number only",
{
"issue": "52",
"series": "52",
"title": "",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
"alternate": "",
},
(False, False),
),
(
"52 Monster_Island_v1_#2__repaired__c2c.cbz",
"leading alternate",
{
"issue": "2",
"series": "Monster Island",
"title": "",
"volume": "1",
"year": "",
"remainder": "repaired",
"issue_count": "",
"alternate": "52",
"c2c": True,
},
(True, True),
),
2022-04-18 18:29:38 -07:00
(
"Monster_Island_v1_#2__repaired__c2c.cbz",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "2",
"series": "Monster Island",
"title": "",
2022-04-18 18:29:38 -07:00
"volume": "1",
"year": "",
"remainder": "repaired",
2022-04-18 18:29:38 -07:00
"issue_count": "",
"c2c": True,
2022-04-18 18:29:38 -07:00
},
(False, False),
2022-04-18 18:29:38 -07:00
),
(
"Monster Island v1 #3 (1957) -- The Revenge Of King Klong (noads).cbz",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "3",
"series": "Monster Island",
"title": "",
2022-04-18 18:29:38 -07:00
"volume": "1",
"year": "1957",
"remainder": "The Revenge Of King Klong (noads)",
"issue_count": "",
},
(False, False),
2022-04-18 18:29:38 -07:00
),
(
"Foobar-Man Annual #121 - The Wrath of Foobar-Man, Part 1 of 2.cbz",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "121",
"series": "Foobar-Man Annual",
"title": "The Wrath of Foobar-Man, Part 1 of 2",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
"annual": True,
2022-04-18 18:29:38 -07:00
},
(False, True),
2022-04-18 18:29:38 -07:00
),
(
"Plastic Man v1 #002 (1942).cbz",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "2",
"series": "Plastic Man",
"title": "",
"volume": "1",
"year": "1942",
"remainder": "",
"issue_count": "",
},
(False, False),
2022-04-18 18:29:38 -07:00
),
(
"Blue Beetle #02.cbr",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "2",
"series": "Blue Beetle",
"title": "",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
},
(False, False),
2022-04-18 18:29:38 -07:00
),
(
"Monster Island vol. 2 #2.cbz",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "2",
"series": "Monster Island",
"title": "",
"volume": "2",
"year": "",
"remainder": "",
"issue_count": "",
},
(False, False),
2022-04-18 18:29:38 -07:00
),
(
"Crazy Weird Comics #2 (of 2) (1969).rar",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "2",
"series": "Crazy Weird Comics",
"title": "",
"volume": "",
"year": "1969",
"remainder": "",
"issue_count": "2",
},
(False, False),
2022-04-18 18:29:38 -07:00
),
(
"Super Strange Yarns (1957) #92 (1969).cbz",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "92",
"series": "Super Strange Yarns",
"title": "",
"volume": "1957",
"year": "1969",
"remainder": "",
"issue_count": "",
},
(False, False),
2022-04-18 18:29:38 -07:00
),
(
"Action Spy Tales v1965 #3.cbr",
"Example from userguide",
2022-04-18 18:29:38 -07:00
{
"issue": "3",
"series": "Action Spy Tales",
"title": "",
"volume": "1965",
"year": "",
"remainder": "",
"issue_count": "",
},
(False, False),
2022-04-18 18:29:38 -07:00
),
(
" X-Men-V1-#067.cbr",
"hyphen separated with hyphen in series", # only parses correctly because v1 designates the volume
2022-04-15 02:46:57 -07:00
{
"issue": "67",
"series": "X-Men",
"title": "",
"volume": "1",
"year": "",
"remainder": "",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
"Amazing Spider-Man #078.BEY (2022) (Digital) (Zone-Empire).cbr",
2022-04-15 02:46:57 -07:00
"number issue with extra",
{
"issue": "78.BEY",
"series": "Amazing Spider-Man",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2022",
"remainder": "(Digital) (Zone-Empire)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Angel Wings #02 - Black Widow (2015) (Scanlation) (phillywilly).cbr",
"title after #issue",
2022-04-15 02:46:57 -07:00
{
"issue": "2",
"series": "Angel Wings",
"title": "Black Widow",
"volume": "",
"year": "2015",
"remainder": "(Scanlation) (phillywilly)",
"issue_count": "",
},
(False, True),
2022-04-15 02:46:57 -07:00
),
(
"Aquaman - Green Arrow - Deep Target #01 (of 07) (2021) (digital) (Son of Ultron-Empire).cbr",
2022-04-15 02:46:57 -07:00
"issue count",
{
"issue": "1",
"series": "Aquaman - Green Arrow - Deep Target",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"issue_count": "7",
"remainder": "(digital) (Son of Ultron-Empire)",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
"Aquaman 80th Anniversary 100-Page Super Spectacular (2021) #001 (2021) (Digital) (BlackManta-Empire).cbz",
2022-04-15 02:46:57 -07:00
"numbers in series",
{
"issue": "1",
"series": "Aquaman 80th Anniversary 100-Page Super Spectacular",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "2021",
"year": "2021",
"remainder": "(Digital) (BlackManta-Empire)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Avatar - The Last Airbender - The Legend of Korra (FCBD 2021) (Digital) (mv-DCP).cbr",
"FCBD date",
{
"issue": "",
"series": "Avatar - The Last Airbender - The Legend of Korra",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(Digital) (mv-DCP)",
2022-04-15 02:46:57 -07:00
"issue_count": "",
"fcbd": True,
2022-04-15 02:46:57 -07:00
},
(True, False),
2022-05-21 00:16:45 -07:00
),
(
"Avengers By Brian Michael Bendis volume 03 (2013) (Digital) (F2) (Kileko-Empire).cbz",
"volume without issue",
{
"issue": "3",
"series": "Avengers By Brian Michael Bendis",
"title": "",
"volume": "3",
"year": "2013",
"remainder": "(Digital) (F2) (Kileko-Empire)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Avengers By Brian Michael Bendis v03 (2013) (Digital) (F2) (Kileko-Empire).cbz",
"volume without issue",
{
"issue": "3",
2022-04-15 02:46:57 -07:00
"series": "Avengers By Brian Michael Bendis",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "3",
"year": "2013",
"remainder": "(Digital) (F2) (Kileko-Empire)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
"Batman '89 (2021) (Webrip) (The Last Kryptonian-DCP).cbr",
"year in title without issue",
{
"issue": "",
"series": "Batman '89",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(Webrip) (The Last Kryptonian-DCP)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
"Batman_-_Superman_#020_(2021)_(digital)_(NeverAngel-Empire).cbr",
2022-04-15 02:46:57 -07:00
"underscores",
{
"issue": "20",
"series": "Batman - Superman",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(digital) (NeverAngel-Empire)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
"Black Widow #009 (2021) (Digital) (Zone-Empire).cbr",
2022-04-15 02:46:57 -07:00
"standard",
{
"issue": "9",
"series": "Black Widow",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(Digital) (Zone-Empire)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
"Blade Runner 2029 #006 (2021) (3 covers) (digital) (Son of Ultron-Empire).cbr",
2022-04-15 02:46:57 -07:00
"year before issue",
{
"issue": "6",
"series": "Blade Runner 2029",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(3 covers) (digital) (Son of Ultron-Empire)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Blade Runner Free Comic Book Day 2021 (2021) (digital-Empire).cbr",
"FCBD year and (year)",
{
"issue": "",
"series": "Blade Runner Free Comic Book Day 2021",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(digital-Empire)",
"issue_count": "",
"fcbd": True,
2022-04-15 02:46:57 -07:00
},
(True, False),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Bloodshot Book 03 (2020) (digital) (Son of Ultron-Empire).cbr",
"book",
{
"issue": "3",
"series": "Bloodshot",
"title": "Book 03",
"volume": "3",
"year": "2020",
"remainder": "(digital) (Son of Ultron-Empire)",
"issue_count": "",
},
(True, False),
2022-04-15 02:46:57 -07:00
),
(
"book of eli #1 (2020) (digital) (Son of Ultron-Empire).cbr",
"book",
{
"issue": "1",
"series": "book of eli",
"title": "",
"volume": "",
"year": "2020",
"remainder": "(digital) (Son of Ultron-Empire)",
"issue_count": "",
},
(False, False),
),
(
"Cyberpunk 2077 - You Have My Word #02 (2021) (digital) (Son of Ultron-Empire).cbr",
2022-04-15 02:46:57 -07:00
"title",
{
"issue": "2",
"series": "Cyberpunk 2077",
"title": "You Have My Word",
"volume": "",
"year": "2021",
"issue_count": "",
"remainder": "(digital) (Son of Ultron-Empire)",
},
(True, True),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Elephantmen 2259 #008 - Simple Truth 03 (of 06) (2021) (digital) (Son of Ultron-Empire).cbr",
"volume count",
{
"issue": "8",
"series": "Elephantmen 2259",
"title": "Simple Truth",
"volume": "3",
"year": "2021",
"volume_count": "6",
"remainder": "(digital) (Son of Ultron-Empire)",
"issue_count": "",
},
(True, True),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Free Comic Book Day - Avengers.Hulk (2021) (2048px) (db).cbz",
"'.' in name",
{
"issue": "",
"series": "Free Comic Book Day - Avengers Hulk",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(2048px) (db)",
"issue_count": "",
"fcbd": True,
2022-04-15 02:46:57 -07:00
},
(True,),
2022-04-15 02:46:57 -07:00
),
(
"Goblin (2021) (digital) (Son of Ultron-Empire).cbr",
"no-issue",
{
"issue": "",
"series": "Goblin",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(digital) (Son of Ultron-Empire)",
"issue_count": "",
},
(False,),
2022-04-15 02:46:57 -07:00
),
(
"Marvel Previews #002 (January 2022) (Digital-Empire).cbr",
2022-04-15 02:46:57 -07:00
"(month year)",
{
"issue": "2",
"series": "Marvel Previews",
"title": "",
"publisher": "Marvel",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2022",
"remainder": "(Digital-Empire)",
"issue_count": "",
},
(True, True),
2022-04-15 02:46:57 -07:00
),
(
"Marvel Two In One V1 #090 c2c (Comixbear-DCP).cbr",
"volume then issue",
{
"issue": "90",
"series": "Marvel Two In One",
"title": "",
"publisher": "Marvel",
2022-04-15 02:46:57 -07:00
"volume": "1",
"year": "",
"remainder": "(Comixbear-DCP)",
2022-04-15 02:46:57 -07:00
"issue_count": "",
"c2c": True,
2022-04-15 02:46:57 -07:00
},
(False, True),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Star Wars - War of the Bounty Hunters - IG-88 (2021) (Digital) (Kileko-Empire).cbz",
"number ends series, no-issue",
{
"issue": "",
"series": "Star Wars - War of the Bounty Hunters - IG-88",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(Digital) (Kileko-Empire)",
"issue_count": "",
},
(True,),
2022-04-15 02:46:57 -07:00
),
(
"Star Wars - War of the Bounty Hunters - IG-88 #1 (2021) (Digital) (Kileko-Empire).cbz",
"number ends series",
{
"issue": "1",
"series": "Star Wars - War of the Bounty Hunters - IG-88",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(Digital) (Kileko-Empire)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
"The Defenders v1 #058 (1978) (digital).cbz",
2022-04-15 02:46:57 -07:00
"",
{
"issue": "58",
"series": "The Defenders",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "1",
"year": "1978",
"remainder": "(digital)",
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
"The Defenders v1 Annual #01 (1976) (Digital) (Minutemen-Slayer).cbr",
2022-04-15 02:46:57 -07:00
" v in series",
{
"issue": "1",
"series": "The Defenders Annual",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "1",
"year": "1976",
"remainder": "(Digital) (Minutemen-Slayer)",
"issue_count": "",
"annual": True,
2022-04-15 02:46:57 -07:00
},
(True, True),
2022-04-15 02:46:57 -07:00
),
(
"The Magic Order 2 #06 (2022) (Digital) (Zone-Empire)[__913302__].cbz",
2022-04-15 02:46:57 -07:00
"ending id",
{
"issue": "6",
"series": "The Magic Order 2",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2022",
"remainder": "(Digital) (Zone-Empire)[913302]", # Don't really care about double underscores
2022-04-15 02:46:57 -07:00
"issue_count": "",
},
(False, False),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Wonder Woman #001 Wonder Woman Day Special Edition (2021) (digital-Empire).cbr",
"issue separates title",
{
"issue": "1",
"series": "Wonder Woman",
"title": "Wonder Woman Day Special Edition",
"volume": "",
"year": "2021",
"remainder": "(digital-Empire)",
"issue_count": "",
},
(False, True),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"Wonder Woman #49 DC Sep-Oct 1951 digital [downsized, lightened, 4 missing story pages restored] (Shadowcat-Empire).cbz",
"date-range, no paren, braces",
{
"issue": "49",
"series": "Wonder Woman",
"title": "digital", # Don't have a way to get rid of this
"publisher": "DC",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "1951",
"remainder": "[downsized, lightened, 4 missing story pages restored] (Shadowcat-Empire)",
2022-04-15 02:46:57 -07:00
"issue_count": "",
},
(True, True),
2022-04-15 02:46:57 -07:00
),
(
2022-04-15 02:46:57 -07:00
"X-Men, 2021-08-04 (#02) (digital) (Glorith-HD).cbz",
"full-date, issue in parenthesis",
{
"issue": "2",
"series": "X-Men",
"title": "",
2022-04-15 02:46:57 -07:00
"volume": "",
"year": "2021",
"remainder": "(digital) (Glorith-HD)",
"issue_count": "",
},
(True, True),
2022-04-15 02:46:57 -07:00
),
(
"Cory Doctorow's Futuristic Tales of the Here and Now: Anda's Game #001 (2007).cbz",
"title",
{
"issue": "1",
"series": "Cory Doctorow's Futuristic Tales of the Here and Now",
"title": "Anda's Game",
"volume": "",
"year": "2007",
"remainder": "",
"issue_count": "",
},
(True, True),
),
2022-04-15 02:46:57 -07:00
]
fnames = []
for p in names:
pp = list(p)
pp[3] = p[3][0]
fnames.append(tuple(pp))
if "#" in p[0]:
pp[0] = p[0].replace("#", "")
pp[3] = p[3][1]
fnames.append(tuple(pp))
rnames = [
(
"{series!c} {price} {year}", # Capitalize
False,
"universal",
"Cory doctorow's futuristic tales of the here and now 2007.cbz",
does_not_raise(),
),
(
"{series!t} {price} {year}", # Title Case
False,
"universal",
"Cory Doctorow'S Futuristic Tales Of The Here And Now 2007.cbz",
does_not_raise(),
),
(
"{series!S} {price} {year}", # Swap Case
False,
"universal",
"cORY dOCTOROW'S fUTURISTIC tALES OF THE hERE AND nOW 2007.cbz",
does_not_raise(),
),
(
"{title!l} {price} {year}", # Lowercase
False,
"universal",
"anda's game 2007.cbz",
does_not_raise(),
),
(
"{title!u} {price} {year}", # Upper Case
False,
"universal",
"ANDA'S GAME 2007.cbz",
does_not_raise(),
),
(
"{title} {price} {year+}", # Empty alternate value
False,
"universal",
"Anda's Game.cbz",
does_not_raise(),
),
(
"{title} {price} {year+year!u}", # Alternate value Upper Case
False,
"universal",
"Anda's Game YEAR.cbz",
does_not_raise(),
),
(
"{title} {price} {year+year}", # Alternate Value
False,
"universal",
"Anda's Game year.cbz",
does_not_raise(),
),
(
"{title} {price-0} {year}", # Default value
False,
"universal",
"Anda's Game 0 2007.cbz",
does_not_raise(),
),
(
"{title} {price+0} {year}", # Alternate Value
False,
"universal",
"Anda's Game 2007.cbz",
does_not_raise(),
),
(
"{series} #{issue} - {title} ({year}) ({price})", # price should be none
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} #{issue} - {title} {volume:02} ({year})", # Ensure format specifier works
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game 01 (2007).cbz",
does_not_raise(),
),
(
"{series} #{issue} - {title} ({year})({price})", # price should be none, test no space between ')('
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} #{issue} - {title} ({year}) ({price})", # price should be none, test double space ') ('
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} #{issue} - {title} ({year})",
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{title} {web_link}", # Ensure colon is replaced in metadata
False,
"universal",
"Anda's Game https---comicvine.gamespot.com-cory-doctorows-futuristic-tales-of-the-here-and-no-4000-140529-.cbz",
does_not_raise(),
),
(
"{title} {web_link}", # Ensure slashes are replaced in metadata on linux/macos
False,
"Linux",
"Anda's Game https:--comicvine.gamespot.com-cory-doctorows-futuristic-tales-of-the-here-and-no-4000-140529-.cbz",
does_not_raise(),
),
(
"{series}:{title} #{issue} ({year})", # on windows the ':' is replaced
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now-Anda's Game #001 (2007).cbz",
does_not_raise(),
),
(
"{series}: {title} #{issue} ({year})", # on windows the ':' is replaced
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now - Anda's Game #001 (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series}: {title} #{issue} ({year})", # on linux the ':' is preserved
False,
"Linux",
"Cory Doctorow's Futuristic Tales of the Here and Now: Anda's Game #001 (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{publisher}/ {series} #{issue} - {title} ({year})", # leading whitespace is removed when moving
True,
"universal",
"IDW Publishing/Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{publisher}/ {series} #{issue} - {title} ({year})", # leading whitespace is removed when only renaming
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
r"{publisher}\ {series} #{issue} - {title} ({year})", # backslashes separate directories
False,
"Linux",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} # {issue} - {title} ({year})", # double spaces are reduced to one
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now # 001 - Anda's Game (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
Convert ComicIssue into GenericMetadata I could not find a good reason for ComicIssue to exist other than that it had more attributes than GenericMetadata, so it has been replaced. New attributes for GenericMetadata: series_id: a string uniquely identifying the series to tag_origin series_aliases: alternate series names that are not the canonical name title_aliases: alternate issue titles that are not the canonical name alternate_images: a list of urls to alternate cover images Updated attributes for GenericMetadata: genre -> genres: str -> list[str] comments -> description: str -> str story_arc -> story_arcs: str -> list[str] series_group -> series_groups: str -> list[str] character -> characters: str -> list[str] team -> teams: str -> list[str] location -> locations: str -> list[str] tag_origin -> tag_origin: str -> TagOrigin (tuple[str, str]) ComicSeries has been relocated to the ComicAPI package, currently has no usage within ComicAPI. CreditMetadata has been renamed to Credit and has replaced Credit from ComicTalker. fetch_series has been added to ComicTalker, this is currently only used in the GUI when a series is selected and does not already contain the needed fields, this function should always be cached. A new split function has been added to ComicAPI, all uses of split on single characters have been updated to use this cleanup_html and the corresponding setting are now only used in ComicTagger proper, for display we want any html directly from the upstream. When applying the metadata we then strip the description of any html. A new conversion has been added to the MetadataFormatter: j: joins any lists into a string with ', '. Note this is a valid operation on strings as well, it will add ', ' in between every character. parse_settings now assigns the given ComicTaggerPaths object to the result ensuring that the correct path is always used.
2023-08-02 09:00:04 -07:00
"{series} #{issue} - {locations!j} ({year})",
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - lonely cottage (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} #{issue} - {title} - {WriteR}, {EDITOR} ({year})", # fields are case in-sensitive
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 - Anda's Game - Dara Naraghi, Ted Adams (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} v{price} #{issue} ({year})", # Remove previous text if value is ""
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} {price} #{issue} ({year})", # Ensure that a single space remains
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now #001 (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} - {title}{price} #{issue} ({year})", # Ensure removal before None values only impacts literal text
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now - Anda's Game #001 (2007).cbz",
2022-07-13 19:56:34 -07:00
does_not_raise(),
),
(
"{series} - {title} {test} #{issue} ({year})", # Test non-existent key
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now - Anda's Game {test} #001 (2007).cbz",
does_not_raise(),
),
(
"{series} - {title} #{issue} ({year} {price})", # Test null value in parenthesis with a non-null value
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now - Anda's Game #001 (2007).cbz",
does_not_raise(),
),
(
"{series} - {title} #{issue} (of {price})", # null value with literal text in parenthesis
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now - Anda's Game #001.cbz",
does_not_raise(),
),
2022-07-13 19:56:34 -07:00
(
"{series} - {title} {1} #{issue} ({year})", # Test numeric key
False,
"universal",
"Cory Doctorow's Futuristic Tales of the Here and Now - Anda's Game {test} #001 (2007).cbz",
pytest.raises(ValueError),
),
]
rfnames = [
(None, lambda x: x.path.parent.absolute()),
("", lambda x: pathlib.Path(os.getcwd())),
("test", lambda x: (pathlib.Path(os.getcwd()) / "test")),
(pathlib.Path(os.getcwd()) / "test", lambda x: pathlib.Path(os.getcwd()) / "test"),
]