Skip to content

Commit 31c06d3

Browse files
Null Checks & Cleanups (#23)
- Fix for #19 - Update PyPI publishing - Refine README - Rename `get_cache_dir()` to `get_cache_root()` - Rename `get_config_dir()` to `get_config_root()` - Rename `get_data_dir()` to `get_data_root()` - Rename `get_project_dir()` to `get_project_root()`
1 parent 030ea14 commit 31c06d3

11 files changed

Lines changed: 70 additions & 66 deletions

File tree

.github/workflows/publishing.yaml

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
name: Publishing
22

3-
on:
4-
push:
5-
tags:
6-
- '[0-9]+.[0-9]+.[0-9]+'
3+
on: push
74

85
jobs:
9-
pypi:
10-
name: Publish to PyPI
11-
strategy:
12-
fail-fast: false
13-
matrix:
14-
python-version:
15-
- '3.12'
16-
os:
17-
- ubuntu-latest
18-
runs-on: ${{ matrix.os }}
6+
build:
7+
name: Build
8+
runs-on: ubuntu-latest
9+
1910
steps:
20-
#----------------------------------------------
21-
- name: Checkout repository
22-
uses: actions/checkout@v4
23-
#----------------------------------------------
24-
- name: Setup python
25-
uses: actions/setup-python@v5
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-python@v5
2613
with:
27-
python-version: ${{ matrix.python-version }}
28-
- name: Setup environment
29-
run: pip install twine build packaging
30-
#----------------------------------------------
31-
- name: Build project
14+
python-version: '3.12'
15+
- name: Install pypa/build
16+
run: pip install build
17+
- name: Build a binary wheel and a source tarball
3218
run: python -m build
33-
- name: Check dist
34-
run: twine check dist/*
35-
- name: Publish project
36-
run: twine upload --username __token__ --password ${{ secrets.PYPI_TOKEN }} dist/*
19+
- uses: actions/upload-artifact@v4
20+
with:
21+
name: python-package-distributions
22+
path: dist/
23+
24+
publish-to-pypi:
25+
name: Publish to PyPI
26+
if: startsWith(github.ref, 'refs/tags/')
27+
needs:
28+
- build
29+
runs-on: ubuntu-latest
30+
environment:
31+
name: pypi
32+
url: https://pypi.org/p/perdoo
33+
permissions:
34+
id-token: write
35+
36+
steps:
37+
- uses: actions/download-artifact@v4
38+
with:
39+
name: python-package-distributions
40+
path: dist/
41+
- uses: pypa/gh-action-pypi-publish@release/v1

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![Pre-Commit](https://img.shields.io/badge/Pre--Commit-informational?style=flat-square&logo=pre-commit&labelColor=grey)](https://github.com/pre-commit/pre-commit)
1010
[![Ruff](https://img.shields.io/badge/Ruff-informational?style=flat-square&logo=ruff&labelColor=grey)](https://github.com/astral-sh/ruff)
1111

12-
[![Github - Contributors](https://img.shields.io/github/contributors/ComicCorps/Perdoo.svg?logo=Github&label=Contributors&style=flat-square)](https://github.com/ComicCorps/Perdoo/graphs/contributors)
12+
[![Github - Contributors](https://img.shields.io/github/contributors/Buried-In-Code/Perdoo.svg?logo=Github&label=Contributors&style=flat-square)](https://github.com/Buried-In-Code/Perdoo/graphs/contributors)
1313

1414
Perdoo is designed to assist in sorting and organizing your comic collection by utilizing metadata files stored within comic archives.\
1515
Perdoo standardizes all your digital comics into a unified format (cb7, cbt, or cbz).\
@@ -18,20 +18,15 @@ Unlike other tagging tools, Perdoo employs a manual approach when metadata files
1818

1919
## Installation
2020

21-
### PyPI
22-
23-
1. Ensure you have a supported version of [Python](https://www.python.org/) installed: `python --version`
24-
2. Install the project from PyPI: `pip install perdoo`
25-
2621
### Pipx
2722

2823
1. Ensure you have [Pipx](https://pipxproject.github.io/pipx/) installed: `pipx --version`
2924
2. Install the project: `pipx install perdoo`
3025

31-
### GitHub
26+
### From Source
3227

3328
1. Ensure you have a supported version of [Python](https://www.python.org/) installed: `python --version`
34-
2. Clone the repository: `git clone https://github.com/ComicCorps/Perdoo`
29+
2. Clone the repository: `git clone https://github.com/Buried-In-Code/Perdoo`
3530
3. Install the project: `pip install .`
3631

3732
## Execution
@@ -63,14 +58,14 @@ Unlike other tagging tools, Perdoo employs a manual approach when metadata files
6358

6459
### Metadata Files
6560

66-
- [Metadata.xml](https://github.com/ComicCorps/Schemas)
61+
- [Metadata.xml](https://github.com/Buried-In-Code/Schemas)
6762
- [MetronInfo.xml](https://github.com/Metron-Project/metroninfo)
68-
- [ComicInfo.xml](https://github.com/anansi-project/comicinfo)
63+
- Perdoo supports a slightly modified [ComicInfo.xml](https://github.com/anansi-project/comicinfo) to ignore field ordering. _See [Buried-In-Code/Schemas](https://github.com/Buried-In-Code/Schemas) for details._
6964

7065
## Services
7166

7267
- [Comicvine](https://comicvine.gamespot.com) using the [Simyan](https://github.com/Metron-Project/Simyan) library.
73-
- [League of Comic Geeks](https://leagueofcomicgeeks.com) using the [Himon](https://github.com/ComicCorps/Himon) library.
68+
- [League of Comic Geeks](https://leagueofcomicgeeks.com) using the [Himon](https://github.com/Buried-In-Code/Himon) library.
7469
- [Marvel](https://www.marvel.com/comics) using the [Esak](https://github.com/Metron-Project/Esak) library.
7570
- [Metron](https://metron.cloud) using the [Mokkari](https://github.com/Metron-Project/Mokkari) library.
7671

@@ -114,4 +109,5 @@ Collection Root
114109

115110
## Socials
116111

112+
[![Social - Fosstodon](https://img.shields.io/badge/%40BuriedInCode-teal?label=Fosstodon&logo=mastodon&style=for-the-badge)](https://fosstodon.org/@BuriedInCode)\
117113
[![Social - Matrix](https://img.shields.io/matrix/The-Dev-Environment:matrix.org?label=The-Dev-Environment&logo=matrix&style=for-the-badge)](https://matrix.to/#/#The-Dev-Environment:matrix.org)

perdoo/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"__version__",
33
"ARCHIVE_EXTENSIONS",
44
"IMAGE_EXTENSIONS",
5-
"get_cache_dir",
6-
"get_config_dir",
7-
"get_data_dir",
5+
"get_cache_root",
6+
"get_config_root",
7+
"get_data_root",
88
"setup_logging",
99
]
10-
__version__ = "0.2.0"
10+
__version__ = "0.2.1"
1111

1212
import logging
1313
import os
@@ -22,34 +22,34 @@
2222
IMAGE_EXTENSIONS = (".jpg", ".jpeg", ".png", ".webp")
2323

2424

25-
def get_cache_dir() -> Path:
25+
def get_cache_root() -> Path:
2626
cache_home = os.getenv("XDG_CACHE_HOME", default=str(Path.home() / ".cache"))
2727
folder = Path(cache_home).resolve() / "perdoo"
2828
folder.mkdir(exist_ok=True, parents=True)
2929
return folder
3030

3131

32-
def get_config_dir() -> Path:
32+
def get_config_root() -> Path:
3333
config_home = os.getenv("XDG_CONFIG_HOME", default=str(Path.home() / ".config"))
3434
folder = Path(config_home).resolve() / "perdoo"
3535
folder.mkdir(exist_ok=True, parents=True)
3636
return folder
3737

3838

39-
def get_data_dir() -> Path:
39+
def get_data_root() -> Path:
4040
data_home = os.getenv("XDG_DATA_HOME", default=str(Path.home() / ".local" / "share"))
4141
folder = Path(data_home).resolve() / "perdoo"
4242
folder.mkdir(exist_ok=True, parents=True)
4343
return folder
4444

4545

46-
def get_project_dir() -> Path:
46+
def get_project_root() -> Path:
4747
return Path(__file__).parent.parent
4848

4949

5050
def setup_logging(debug: bool = False) -> None:
5151
install(show_locals=True, max_frames=6, console=CONSOLE)
52-
log_folder = get_project_dir() / "logs"
52+
log_folder = get_project_root() / "logs"
5353
log_folder.mkdir(parents=True, exist_ok=True)
5454

5555
console_handler = RichHandler(

perdoo/__main__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ def start(settings: Settings, force: bool = False) -> None:
321321
)
322322

323323
metadata, metron_info, comic_info = fetch_from_services(settings=settings, details=details)
324+
if not metadata:
325+
LOGGER.warning("Not enough information to organize and rename this comic, skipping")
326+
continue
324327
new_file = generate_filename(
325328
root=settings.output_folder, extension=settings.output.format.value, metadata=metadata
326329
)
@@ -341,11 +344,11 @@ def start(settings: Settings, force: bool = False) -> None:
341344
metadata_file = temp_folder / "Metadata.xml"
342345
metadata.to_file(file=metadata_file)
343346
files.append(metadata_file)
344-
if settings.output.create_metron_info:
347+
if metron_info and settings.output.create_metron_info:
345348
metron_info_file = temp_folder / "MetronInfo.xml"
346349
metron_info.to_file(file=metron_info_file)
347350
files.append(metron_info_file)
348-
if settings.output.create_comic_info:
351+
if comic_info and settings.output.create_comic_info:
349352
comic_info_file = temp_folder / "ComicInfo.xml"
350353
comic_info.to_file(file=comic_info_file)
351354
files.append(comic_info_file)

perdoo/models/comic_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def to_file(self: ComicInfo, file: Path) -> None:
327327
content = self.clean_contents(content)
328328
content["@xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
329329
content["@xsi:noNamespaceSchemaLocation"] = (
330-
"https://raw.githubusercontent.com/ComicCorps/Schemas/main/schemas/v2.0/ComicInfo.xsd"
330+
"https://raw.githubusercontent.com/Buried-In-Code/Schemas/main/schemas/v2.0/ComicInfo.xsd"
331331
)
332332

333333
with file.open("wb") as stream:

perdoo/models/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def to_file(self: Metadata, file: Path) -> None:
355355
content = self.clean_contents(content)
356356
content["@xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance"
357357
content["@xsi:noNamespaceSchemaLocation"] = (
358-
"https://raw.githubusercontent.com/ComicCorps/Schemas/main/drafts/v1.0/Metadata.xsd"
358+
"https://raw.githubusercontent.com/Buried-In-Code/Schemas/main/drafts/v1.0/Metadata.xsd"
359359
)
360360

361361
with file.open("wb") as stream:

perdoo/services/comicvine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from simyan.schemas.volume import Volume
1515
from simyan.sqlite_cache import SQLiteCache
1616

17-
from perdoo import get_cache_dir
17+
from perdoo import get_cache_root
1818
from perdoo.console import CONSOLE, create_menu
1919
from perdoo.models import ComicInfo, Metadata, MetronInfo
2020
from perdoo.models.metadata import Source
@@ -28,7 +28,7 @@
2828

2929
class Comicvine(BaseService[Volume, Issue]):
3030
def __init__(self: Comicvine, settings: ComicvineSettings):
31-
cache = SQLiteCache(path=get_cache_dir() / "simyan.sqlite", expiry=14)
31+
cache = SQLiteCache(path=get_cache_root() / "simyan.sqlite", expiry=14)
3232
self.session = Simyan(api_key=settings.api_key, cache=cache)
3333

3434
def _get_series_id(self: Comicvine, title: str | None) -> int | None:

perdoo/services/league.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from himon.schemas.series import Series
1010
from himon.sqlite_cache import SQLiteCache
1111

12-
from perdoo import get_cache_dir
12+
from perdoo import get_cache_root
1313
from perdoo.models import ComicInfo, Metadata, MetronInfo
1414
from perdoo.services._base import BaseService
1515
from perdoo.settings import LeagueofComicGeeks as LeagueSettings
@@ -20,7 +20,7 @@
2020

2121
class League(BaseService[Series, Comic]):
2222
def __init__(self: League, settings: LeagueSettings):
23-
cache = SQLiteCache(path=get_cache_dir() / "himon.sqlite", expiry=14)
23+
cache = SQLiteCache(path=get_cache_root() / "himon.sqlite", expiry=14)
2424
self.session = Himon(
2525
client_id=settings.client_id,
2626
client_secret=settings.client_secret,

perdoo/services/marvel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pydantic import HttpUrl
1414
from rich.prompt import Confirm, Prompt
1515

16-
from perdoo import get_cache_dir
16+
from perdoo import get_cache_root
1717
from perdoo.console import CONSOLE, create_menu
1818
from perdoo.models import ComicInfo, Metadata, MetronInfo
1919
from perdoo.services._base import BaseService
@@ -25,7 +25,7 @@
2525

2626
class Marvel(BaseService[Series, Comic]):
2727
def __init__(self: Marvel, settings: MarvelSettings):
28-
cache = SqliteCache(db_name=str(get_cache_dir() / "esak.sqlite"), expire=14)
28+
cache = SqliteCache(db_name=str(get_cache_root() / "esak.sqlite"), expire=14)
2929
self.session = Esak(
3030
public_key=settings.public_key, private_key=settings.private_key, cache=cache
3131
)

perdoo/services/metron.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pydantic import HttpUrl
1414
from rich.prompt import Confirm, Prompt
1515

16-
from perdoo import get_cache_dir
16+
from perdoo import get_cache_root
1717
from perdoo.console import CONSOLE, create_menu
1818
from perdoo.models import ComicInfo, Metadata, MetronInfo
1919
from perdoo.models.metadata import Source
@@ -27,7 +27,7 @@
2727

2828
class Metron(BaseService[Series, Issue]):
2929
def __init__(self: Metron, settings: MetronSettings):
30-
cache = SqliteCache(db_name=str(get_cache_dir() / "mokkari.sqlite"), expire=14)
30+
cache = SqliteCache(db_name=str(get_cache_root() / "mokkari.sqlite"), expire=14)
3131
self.session = Mokkari(username=settings.username, passwd=settings.password, cache=cache)
3232

3333
def _get_series_via_comicvine(self: Metron, comicvine_id: int | None) -> int | None:

0 commit comments

Comments
 (0)