summaryrefslogtreecommitdiff
path: root/src/pyssg/parser.py
blob: 8b8d1082c94fc4a0d6c38b24b906b2895da383ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from .discovery import get_all_files


def create_dir_structure(dirs: list[str]):
    cwd = os.getcwd()

    for d in dirs:
        try:
            os.makedirs(os.path.join(cwd, d[1:]))
        except FileExistsError:
            pass


def generate_static_site(src: str, dst: str):
    iwd = os.getcwd()

    os.chdir(src)
    dirs, md_files, html_files = get_all_files()
    os.chdir(iwd)

    os.chdir(dst)
    create_dir_structure(dirs)
    os.chdir(iwd)