clean: rename bulk
This commit is contained in:
32
src/main.py
32
src/main.py
@ -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)
|
||||
|
Reference in New Issue
Block a user