clean: rename bulk
This commit is contained in:
parent
129dfe7df9
commit
6d1661131f
@ -10,9 +10,9 @@ if TYPE_CHECKING:
|
|||||||
from path import Path
|
from path import Path
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('src/templates'))
|
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):
|
def __init__(self, name: str, albums_path: Path, pictures: list[Picture] = None, is_repertoried: bool = False):
|
||||||
self.name: str = name
|
self.name: str = name
|
@ -9,13 +9,13 @@ from path import Path
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from page import Page
|
from bulk_page import Page
|
||||||
from picture import Picture
|
from picture import Picture
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader('src/templates'))
|
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):
|
def __init__(self, path: Path, name: str, pictures: list[Picture] = None, prev: Page|None = None, next: Page|None = None):
|
||||||
self.name: str = name
|
self.name: str = name
|
32
src/main.py
32
src/main.py
@ -4,8 +4,8 @@ from progress.bar import Bar
|
|||||||
|
|
||||||
from path import Path
|
from path import Path
|
||||||
from picture import Picture
|
from picture import Picture
|
||||||
from page import Page
|
from bulk_page import BulkPage
|
||||||
from album import Album
|
from bulk_album import BulkAlbum
|
||||||
import argparse
|
import argparse
|
||||||
import config
|
import config
|
||||||
|
|
||||||
@ -16,14 +16,14 @@ def argument_parsing():
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def scan_pages(folders: list[Path]) -> list[Page]:
|
def scan_pages(folders: list[Path]) -> list[BulkPage]:
|
||||||
pages: list[Page] = []
|
pages: list[BulkPage] = []
|
||||||
prev: Page = None
|
prev: BulkPage = None
|
||||||
with Bar("Scanning Pages...", max=len(folders)) as bar:
|
with Bar("Scanning Pages...", max=len(folders)) as bar:
|
||||||
for folder in folders:
|
for folder in folders:
|
||||||
files: list[Path] = folder.get_files()
|
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")
|
raw: Path = Path(folder, folder.get_name() + ".NEF")
|
||||||
id: int = 0
|
id: int = 0
|
||||||
@ -46,28 +46,28 @@ def scan_pages(folders: list[Path]) -> list[Page]:
|
|||||||
pages[0].prev = pages[-1]
|
pages[0].prev = pages[-1]
|
||||||
return pages
|
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:
|
with Bar("Generating Pages...", max=len(pages)) as bar:
|
||||||
for page in pages:
|
for page in pages:
|
||||||
page.create()
|
page.create()
|
||||||
bar.next()
|
bar.next()
|
||||||
|
|
||||||
def scan_albums(pages: list[Page], albums_path: Path) -> list[Album]:
|
def scan_albums(pages: list[BulkPage], albums_path: Path) -> list[BulkAlbum]:
|
||||||
albums: dict[str, Album] = {}
|
albums: dict[str, BulkAlbum] = {}
|
||||||
with Bar("Scanning pages...", max=len(pages)) as bar:
|
with Bar("Scanning pages...", max=len(pages)) as bar:
|
||||||
for page in pages:
|
for page in pages:
|
||||||
for picture in page.get_pictures():
|
for picture in page.get_pictures():
|
||||||
for album_name in picture.get_albums_name():
|
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):
|
if (album is None):
|
||||||
album = Album(album_name, albums_path)
|
album = BulkAlbum(album_name, albums_path)
|
||||||
albums.update({album_name: album})
|
albums.update({album_name: album})
|
||||||
picture.albums.append(album)
|
picture.albums.append(album)
|
||||||
album.add_picture(picture)
|
album.add_picture(picture)
|
||||||
bar.next()
|
bar.next()
|
||||||
return (albums.values())
|
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:
|
with Bar("Generating albums...", max=len(albums)) as bar:
|
||||||
for album in albums:
|
for album in albums:
|
||||||
album.create()
|
album.create()
|
||||||
@ -76,18 +76,18 @@ def create_albums(albums: list[Album]) -> None:
|
|||||||
def gen_bulk(bulk_path: Path):
|
def gen_bulk(bulk_path: Path):
|
||||||
album_path: Path = Path(bulk_path, "albums")
|
album_path: Path = Path(bulk_path, "albums")
|
||||||
|
|
||||||
pages: list[Page] = scan_pages(bulk_path.get_dirs())
|
pages: list[BulkPage] = scan_pages(bulk_path.get_dirs())
|
||||||
albums: list[Album] = scan_albums(pages, album_path)
|
albums: list[BulkAlbum] = scan_albums(pages, album_path)
|
||||||
|
|
||||||
if config.CREATE_GENERAL_ALBUM:
|
if config.CREATE_GENERAL_ALBUM:
|
||||||
for album in albums:
|
for album in albums:
|
||||||
if (album.name == "general"):
|
if (album.name == "general"):
|
||||||
album.path = Path(bulk_path, "general.html")
|
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)
|
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()):
|
if (not album_path.exist()):
|
||||||
album_path.create()
|
album_path.create()
|
||||||
create_albums(albums)
|
create_albums(albums)
|
||||||
|
@ -10,11 +10,11 @@ from typing import TYPE_CHECKING
|
|||||||
import config
|
import config
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from page import Page
|
from bulk_page import BulkPage
|
||||||
from album import Album
|
from bulk_album import Album
|
||||||
|
|
||||||
class Picture():
|
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._large: Path = picture_path
|
||||||
self._small: Path = Path(picture_path.get_absolute_path()[:-4] + "_small.jpg")
|
self._small: Path = Path(picture_path.get_absolute_path()[:-4] + "_small.jpg")
|
||||||
self._thumb: Path = Path(picture_path.get_absolute_path()[:-4] + "_thumb.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._albums_file: Path = Path(picture_path.get_absolute_path()[:-4] + "_albums.txt")
|
||||||
self._raw: Path|None = raw
|
self._raw: Path|None = raw
|
||||||
self.id: int = id
|
self.id: int = id
|
||||||
self._page: Page = page
|
self._page: BulkPage = page
|
||||||
self._albums_name: list[str] = []
|
self._albums_name: list[str] = []
|
||||||
self.albums: list[Album] = []
|
self.albums: list[Album] = []
|
||||||
if self._albums_file.exist():
|
if self._albums_file.exist():
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="/bulk/album.css">
|
<link rel="stylesheet" href="/bulk/bulk_album.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="/bulk/page.css">
|
<link rel="stylesheet" href="/bulk/bulk_page.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
Loading…
Reference in New Issue
Block a user