clean: rename bulk_album category
This commit is contained in:
50
src/main.py
50
src/main.py
@ -5,7 +5,7 @@ from progress.bar import Bar
|
||||
from path import Path
|
||||
from picture import Picture
|
||||
from bulk_page import BulkPage
|
||||
from bulk_album import BulkAlbum
|
||||
from bulk_category import BulkCategory
|
||||
import argparse
|
||||
import config
|
||||
|
||||
@ -57,45 +57,45 @@ def create_pages(pages: list[BulkPage]) -> None:
|
||||
page.create()
|
||||
bar.next()
|
||||
|
||||
def scan_albums(pages: list[BulkPage], albums_path: Path) -> list[BulkAlbum]:
|
||||
albums: dict[str, BulkAlbum] = {}
|
||||
def scan_categories(pages: list[BulkPage], categories_path: Path) -> list[BulkCategory]:
|
||||
categories: dict[str, BulkCategory] = {}
|
||||
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: BulkAlbum | None = albums.get(album_name)
|
||||
if (album is None):
|
||||
album = BulkAlbum(album_name, albums_path)
|
||||
albums.update({album_name: album})
|
||||
picture.albums.append(album)
|
||||
album.add_picture(picture)
|
||||
for category_name in picture.get_categories_name():
|
||||
category: BulkCategory | None = categories.get(category_name)
|
||||
if (category is None):
|
||||
category = BulkCategory(category_name, categories_path)
|
||||
categories.update({category_name: category})
|
||||
picture.categories.append(category)
|
||||
category.add_picture(picture)
|
||||
bar.next()
|
||||
return (albums.values())
|
||||
return (categories.values())
|
||||
|
||||
def create_albums(albums: list[BulkAlbum]) -> None:
|
||||
with Bar("Generating albums...", max=len(albums)) as bar:
|
||||
for album in albums:
|
||||
album.create()
|
||||
def create_categories(categories: list[BulkCategory]) -> None:
|
||||
with Bar("Generating categories...", max=len(categories)) as bar:
|
||||
for category in categories:
|
||||
category.create()
|
||||
bar.next()
|
||||
|
||||
def gen_bulk(bulk_path: Path):
|
||||
album_path: Path = Path(bulk_path, "albums")
|
||||
category_path: Path = Path(bulk_path, "categories")
|
||||
|
||||
pages: list[BulkPage] = scan_pages(bulk_path.get_dirs())
|
||||
albums: list[BulkAlbum] = scan_albums(pages, album_path)
|
||||
categories: list[BulkCategory] = scan_categories(pages, category_path)
|
||||
|
||||
if config.CREATE_GENERAL_ALBUM:
|
||||
for album in albums:
|
||||
if (album.name == "general"):
|
||||
album.path = Path(bulk_path, "index.html")
|
||||
if config.CREATE_GENERAL_CATEGORY:
|
||||
for category in categories:
|
||||
if (category.name == "general"):
|
||||
category.path = Path(bulk_path, "index.html")
|
||||
|
||||
Path("./src/templates/bulk_page.css").copy_to(Path(bulk_path, "bulk_page.css"))
|
||||
create_pages(pages)
|
||||
|
||||
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)
|
||||
Path("./src/templates/bulk_category.css").copy_to(Path(bulk_path, "bulk_category.css"))
|
||||
if (not category_path.exist()):
|
||||
category_path.create()
|
||||
create_categories(categories)
|
||||
|
||||
|
||||
def regen(bulk_path: Path, is_thumb: bool, is_small: bool):
|
||||
|
Reference in New Issue
Block a user