all repos — site @ 39835f2fedd98cf5326b1c7f0d9d006b6ba102a0

source for my site, found at icyphox.sh

Format bin/ with black

Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Sun, 20 Oct 2019 17:47:15 +0530
commit

39835f2fedd98cf5326b1c7f0d9d006b6ba102a0

parent

de847825428d331ffb008357798d0e2aa5a73abd

2 files changed, 18 insertions(+), 19 deletions(-)

jump to
M bin/rss.pybin/rss.py

@@ -11,7 +11,7 @@ import arrow

import operator import warnings -#warnings.simplefilter("ignore", arrow.factory.ArrowParseWarning) +# warnings.simplefilter("ignore", arrow.factory.ArrowParseWarning) items_raw = [] from lxml import etree as ET

@@ -22,6 +22,7 @@

PREFIX_URL = "https://icyphox.sh/blog/" link_extractor = re.compile("\/([^\/]*)\.md$") + def generate_node(rendered, path):
M bin/update_index.pybin/update_index.py

@@ -6,44 +6,42 @@ import fileinput

import sys # change our cwd -os.chdir('bin') +os.chdir("bin") -blog = '../pages/blog/' +blog = "../pages/blog/" # bunch of file hacks to get to the most recent file def getrecent(path): - files = [path + f for f in os.listdir(blog) - if f not in ['_index.md', 'feed.xml']] + files = [path + f for f in os.listdir(blog) if f not in ["_index.md", "feed.xml"]] files.sort(key=os.path.getmtime, reverse=True) return files[0] def update_index(s): - path = '../pages/_index.md' - with open(path, 'r') as f: + path = "../pages/_index.md" + with open(path, "r") as f: md = f.readlines() - ruler = md.index('| --- | --: |\n') - md[ruler + 1] = s + '\n' + ruler = md.index("| --- | --: |\n") + md[ruler + 1] = s + "\n" - with open(path, 'w') as f: + with open(path, "w") as f: f.writelines(md) def update_blog(s): - path = '../pages/blog/_index.md' - s = s + '\n' + path = "../pages/blog/_index.md" + s = s + "\n" for l in fileinput.FileInput(path, inplace=1): if "--:" in l: - l=l.replace(l, l + s) - print(l, end=''), - + l = l.replace(l, l + s) + print(l, end=""), + + # fetch title and date -meta = markdown_path(getrecent(blog), extras=['metadata']).metadata +meta = markdown_path(getrecent(blog), extras=["metadata"]).metadata fname = os.path.basename(os.path.splitext(getrecent(blog))[0]) -url = '/blog/' + fname +url = "/blog/" + fname line = f"| [{meta['title']}]({url}) | `{meta['date']}` |" update_index(line) update_blog(line) - -