import os import subprocess from time import mktime, ctime from email.utils import parsedate def file_last_modified(path): git_time = f"git log -n1 --pretty=%aD {path}".split() try: mod_time = subprocess.check_output(git_time) except: # File is not in the git log, no biggie, just blank the date return None # Git outputs in RFC2822 format return parsedate(mod_time.decode('ascii').strip()) updates = {} dirs = [x for x in os.listdir() if os.path.isdir(x) and not x.startswith(".") ] for top in dirs: for root,_,files in os.walk(top): for f in files: if f.endswith(".html") or f.endswith(".txt"): path = os.path.join(root, f) t = file_last_modified(path) if t: updates[path] = mktime(t) print("") print("") print("

LATEST CHANGES

") print("") print("") print("")