25 lines
805 B
Python
25 lines
805 B
Python
import logging
|
|
from typing import TYPE_CHECKING
|
|
from omicron.ssg.output.output import Output
|
|
from pathlib import Path
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
if TYPE_CHECKING:
|
|
from omicron.ssg.site import Site # for static checking with mypy
|
|
else:
|
|
Site = "omicron.ssg.site.Site" # for runtime checking with beartype
|
|
|
|
|
|
class Directory(Output):
|
|
def __init__(self, site: Site, destination: Path):
|
|
super().__init__(site, destination)
|
|
url_path = Path("/") / site.base_dir / destination
|
|
# rebuild url because Output strips /index.html which is a valid dir
|
|
self.url = url_path.as_posix()
|
|
|
|
def write(self) -> None:
|
|
dest = self.site.output_path / self.destination
|
|
dest.mkdir(parents=True, exist_ok=True)
|
|
log.debug("Created directory %s", dest)
|