1
0
mirror of https://github.com/venthur/blag.git synced 2025-11-25 20:52:43 +00:00

fixed pep8 violations

This commit is contained in:
Bastian Venthur
2018-07-14 21:44:59 +02:00
parent e9c5a17cc8
commit 4de6909e93

15
sg.py
View File

@@ -18,6 +18,7 @@
"""Small static site generator. """Small static site generator.
""" """
@@ -54,10 +55,12 @@ def prepare_site():
# check if all needed dirs and files are available # check if all needed dirs and files are available
for directory in LAYOUTS_DIR, STATIC_DIR: for directory in LAYOUTS_DIR, STATIC_DIR:
if not os.path.exists(directory): if not os.path.exists(directory):
logging.warning("Directory '%s' does not exist, creating it." % directory) logging.warning("Directory {} does not exist, creating it."
.format(directory))
os.mkdir(directory) os.mkdir(directory)
if not os.path.exists(DEFAULT_LAYOUT): if not os.path.exists(DEFAULT_LAYOUT):
logging.warning("File '%s' does not exist, creating it." % DEFAULT_LAYOUT) logging.warning("File {} does not exist, creating it."
.format(DEFAULT_LAYOUT))
filehandle = open(DEFAULT_LAYOUT, 'w') filehandle = open(DEFAULT_LAYOUT, 'w')
filehandle.write(DEFAULT_LAYOUT_HTML) filehandle.write(DEFAULT_LAYOUT_HTML)
filehandle.close() filehandle.close()
@@ -84,7 +87,7 @@ def copy_static_content():
"""Copy the static content to RESULT_DIR.""" """Copy the static content to RESULT_DIR."""
logging.info("Copying static content.") logging.info("Copying static content.")
shutil.copytree(os.path.sep.join([os.curdir, STATIC_DIR]), shutil.copytree(os.path.sep.join([os.curdir, STATIC_DIR]),
os.path.sep.join([os.curdir, RESULT_DIR])) os.path.sep.join([os.curdir, RESULT_DIR]))
def save_page(path, txt): def save_page(path, txt):
@@ -116,7 +119,7 @@ def process_markdown(txt):
def process_embed_content(template, content): def process_embed_content(template, content):
"""Embedd content into html template.""" """Embedd content into html template."""
txt = string.Template(template) txt = string.Template(template)
html = txt.safe_substitute({'content' : content}) html = txt.safe_substitute({'content': content})
return html return html
@@ -185,8 +188,8 @@ def render_page(path):
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG, format="%(levelname)s\t%(message)s") logging.basicConfig(level=logging.DEBUG,
format="%(levelname)s\t%(message)s")
prepare_site() prepare_site()
copy_static_content() copy_static_content()
generate_site() generate_site()