From 1648e4f8b41e0c0417485e0375a1675cd7ab7746 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Fri, 4 Jun 2021 22:57:59 -0600 Subject: add ability to copy basic template files --- src/pyssg/builder.py | 1 - src/pyssg/plt/__init__.py | 0 src/pyssg/pyssg.py | 17 ++++++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 src/pyssg/plt/__init__.py (limited to 'src') diff --git a/src/pyssg/builder.py b/src/pyssg/builder.py index 3a4474e..b6bd371 100644 --- a/src/pyssg/builder.py +++ b/src/pyssg/builder.py @@ -1,7 +1,6 @@ import os import shutil from operator import itemgetter -from copy import deepcopy from jinja2 import Environment, Template from markdown import Markdown from importlib.metadata import version diff --git a/src/pyssg/plt/__init__.py b/src/pyssg/plt/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/pyssg/pyssg.py b/src/pyssg/pyssg.py index 933f7d3..76361f5 100644 --- a/src/pyssg/pyssg.py +++ b/src/pyssg/pyssg.py @@ -1,10 +1,11 @@ import os +import shutil from argparse import ArgumentParser, Namespace from typing import Union from jinja2 import Environment, FileSystemLoader from markdown import Markdown from importlib.metadata import version -from importlib.resources import contents +from importlib.resources import path from datetime import datetime, timezone from .configuration import Configuration @@ -117,8 +118,18 @@ def main() -> None: except FileExistsError: pass - for f in contents('pyssg'): - print(f) + # copy basic template files + files: list[str] = ('index.html', + 'page.html', + 'tag.html', + 'rss.xml', + 'sitemap.xml') + for f in files: + plt_file: str = os.path.join(config.plt, f) + with path('pyssg.plt', f) as p: + if not os.path.exists(plt_file): + shutil.copy(p, plt_file) + return if opts['build']: -- cgit v1.2.3-70-g09d2