💾 Archived View for hackersphere.space › ~willowf › gemlog › journal.py captured on 2024-06-16 at 12:27:32.
⬅️ Previous capture (2024-03-21)
-=-=-=-=-=-=-
#!/usr/bin/env python3 import os import sys import subprocess from datetime import date, datetime, timedelta today = date.today().strftime("%Y-%m-%d") yesterday = (datetime.now() - timedelta(1)).strftime("%Y-%m-%d") tomorrow = (datetime.now() + timedelta(1)).strftime("%Y-%m-%d") #today_human_readable = date.today().strftime("%B %d, %Y") today_human_readable = today pwd_var = "@@" + "PWD" + "@@" jhd_var = "@@" + "JOURNAL-HEADER" + "@@" filename = today + ".gmi" label = today_human_readable if len(sys.argv) > 1: label = " ".join(sys.argv[1:]) index_line = f"=> {pwd_var}/{filename} {today} {label}\n" post_links = f""" => {pwd_var}/{yesterday}.gmi Previous post => {pwd_var}/{tomorrow}.gmi Next post """ if not os.path.exists(filename): with open(filename, "w+") as file: file.write(f"{jhd_var}{post_links}") with open("index.gmi", "a") as index_file: index_file.write(index_line) subprocess.run( f"nano -q -a -M -S -ET2 -l -L --guidestripe=100 {filename}", shell=True )