clean: rename bulk

This commit is contained in:
Starnakin 2025-05-06 22:54:18 +02:00
parent 129dfe7df9
commit 6d1661131f
8 changed files with 27 additions and 27 deletions

View File

@ -10,9 +10,9 @@ if TYPE_CHECKING:
from path import Path
env = Environment(loader=FileSystemLoader('src/templates'))
album_template = env.get_template('album.jinja')
album_template = env.get_template('bulk_album.jinja')
class Album():
class BulkAlbum():
def __init__(self, name: str, albums_path: Path, pictures: list[Picture] = None, is_repertoried: bool = False):
self.name: str = name

View File

@ -9,13 +9,13 @@ from path import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from page import Page
from bulk_page import Page
from picture import Picture
env = Environment(loader=FileSystemLoader('src/templates'))
page_template = env.get_template('page.jinja')
page_template = env.get_template('bulk_page.jinja')
class Page():
class BulkPage():
def __init__(self, path: Path, name: str, pictures: list[Picture] = None, prev: Page|None = None, next: Page|None = None):
self.name: str = name

View File

@ -4,8 +4,8 @@ from progress.bar import Bar
from path import Path
from picture import Picture
from page import Page
from album import Album
from bulk_page import BulkPage
from bulk_album import BulkAlbum
import argparse
import config
@ -16,14 +16,14 @@ def argument_parsing():
args = parser.parse_args()
return args
def scan_pages(folders: list[Path]) -> list[Page]:
pages: list[Page] = []
prev: Page = None
def scan_pages(folders: list[Path]) -> list[BulkPage]:
pages: list[BulkPage] = []
prev: BulkPage = None
with Bar("Scanning Pages...", max=len(folders)) as bar:
for folder in folders:
files: list[Path] = folder.get_files()
page: Page = Page(folder, folder.get_name(), prev=prev)
page: BulkPage = BulkPage(folder, folder.get_name(), prev=prev)
raw: Path = Path(folder, folder.get_name() + ".NEF")
id: int = 0
@ -46,28 +46,28 @@ def scan_pages(folders: list[Path]) -> list[Page]:
pages[0].prev = pages[-1]
return pages
def create_pages(pages: list[Page]) -> None:
def create_pages(pages: list[BulkPage]) -> None:
with Bar("Generating Pages...", max=len(pages)) as bar:
for page in pages:
page.create()
bar.next()
def scan_albums(pages: list[Page], albums_path: Path) -> list[Album]:
albums: dict[str, Album] = {}
def scan_albums(pages: list[BulkPage], albums_path: Path) -> list[BulkAlbum]:
albums: dict[str, BulkAlbum] = {}
with Bar("Scanning pages...", max=len(pages)) as bar:
for page in pages:
for picture in page.get_pictures():
for album_name in picture.get_albums_name():
album: Album | None = albums.get(album_name)
album: BulkAlbum | None = albums.get(album_name)
if (album is None):
album = Album(album_name, albums_path)
album = BulkAlbum(album_name, albums_path)
albums.update({album_name: album})
picture.albums.append(album)
album.add_picture(picture)
bar.next()
return (albums.values())
def create_albums(albums: list[Album]) -> None:
def create_albums(albums: list[BulkAlbum]) -> None:
with Bar("Generating albums...", max=len(albums)) as bar:
for album in albums:
album.create()
@ -76,18 +76,18 @@ def create_albums(albums: list[Album]) -> None:
def gen_bulk(bulk_path: Path):
album_path: Path = Path(bulk_path, "albums")
pages: list[Page] = scan_pages(bulk_path.get_dirs())
albums: list[Album] = scan_albums(pages, album_path)
pages: list[BulkPage] = scan_pages(bulk_path.get_dirs())
albums: list[BulkAlbum] = scan_albums(pages, album_path)
if config.CREATE_GENERAL_ALBUM:
for album in albums:
if (album.name == "general"):
album.path = Path(bulk_path, "general.html")
Path("./src/templates/page.css").copy_to(Path(bulk_path, "page.css"))
Path("./src/templates/bulk_page.css").copy_to(Path(bulk_path, "bulk_page.css"))
create_pages(pages)
Path("./src/templates/album.css").copy_to(Path(bulk_path, "album.css"))
Path("./src/templates/bulk_album.css").copy_to(Path(bulk_path, "bulk_album.css"))
if (not album_path.exist()):
album_path.create()
create_albums(albums)

View File

@ -10,11 +10,11 @@ from typing import TYPE_CHECKING
import config
if TYPE_CHECKING:
from page import Page
from album import Album
from bulk_page import BulkPage
from bulk_album import Album
class Picture():
def __init__(self, picture_path: Path, id: int, page = None, raw: Path|None = None, is_repertoried: bool = True):
def __init__(self, picture_path: Path, id: int, page: BulkPage = None, raw: Path|None = None, is_repertoried: bool = True):
self._large: Path = picture_path
self._small: Path = Path(picture_path.get_absolute_path()[:-4] + "_small.jpg")
self._thumb: Path = Path(picture_path.get_absolute_path()[:-4] + "_thumb.jpg")
@ -22,7 +22,7 @@ class Picture():
self._albums_file: Path = Path(picture_path.get_absolute_path()[:-4] + "_albums.txt")
self._raw: Path|None = raw
self.id: int = id
self._page: Page = page
self._page: BulkPage = page
self._albums_name: list[str] = []
self.albums: list[Album] = []
if self._albums_file.exist():

View File

@ -2,7 +2,7 @@
<html>
<head>
<link rel="stylesheet" href="/bulk/album.css">
<link rel="stylesheet" href="/bulk/bulk_album.css">
</head>
<body>

View File

@ -2,7 +2,7 @@
<html>
<head>
<link rel="stylesheet" href="/bulk/page.css">
<link rel="stylesheet" href="/bulk/bulk_page.css">
</head>
<body>