Initial commit
Initial structure with little functionality
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import logging
|
||||
import sys
|
||||
from omicron.ssg.site import Site
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def setup_logging(verbose: bool = False, log_file: str | None = None) -> None:
|
||||
logger = logging.getLogger("omicron.ssg")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
console = logging.StreamHandler(sys.stderr)
|
||||
console.setLevel(logging.DEBUG if verbose else logging.INFO)
|
||||
console.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
|
||||
logger.addHandler(console)
|
||||
|
||||
|
||||
def main():
|
||||
setup_logging(verbose=True)
|
||||
site = Site(Path("."))
|
||||
site.build()
|
||||
@@ -0,0 +1,8 @@
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Content:
|
||||
def __init__(self, path):
|
||||
pass
|
||||
@@ -0,0 +1,35 @@
|
||||
import logging
|
||||
|
||||
from omicron.ssg.content import Content
|
||||
from pathlib import Path
|
||||
import yaml
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Site:
|
||||
def __init__(self, site: Path):
|
||||
self.site_path = site.absolute()
|
||||
self.content: list[Content] = []
|
||||
self.config: dict = {}
|
||||
self.by_tag: dict[str, list[Content]]
|
||||
self.by_uri: dict[str, Content]
|
||||
self.read_config()
|
||||
|
||||
def read_config(self) -> None:
|
||||
config_path = self.site_path / "config.yml"
|
||||
log.debug("Reading config file %s", config_path)
|
||||
with open(config_path, "r") as f:
|
||||
self.config = yaml.safe_load(f)
|
||||
|
||||
def discover(self) -> None:
|
||||
log.info("Discovering content...")
|
||||
content_path = self.site_path / "content"
|
||||
for file in content_path.rglob("*"):
|
||||
if file.is_file():
|
||||
self.content.append(Content(file))
|
||||
log.info("Discovered %d content items", len(self.content))
|
||||
|
||||
def build(self):
|
||||
self.discover()
|
||||
pass
|
||||
Reference in New Issue
Block a user