From 2ac476c34779699d6cb041b6a539d4ca56d84336 Mon Sep 17 00:00:00 2001 From: Andrew Marcuse Date: Tue, 31 Dec 2024 14:41:38 -0500 Subject: [PATCH] Code updates for git->codehost change --- bin/fm-git-to-codehost.py | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bin/fm-git-to-codehost.py diff --git a/bin/fm-git-to-codehost.py b/bin/fm-git-to-codehost.py new file mode 100755 index 000000000..9dc580813 --- /dev/null +++ b/bin/fm-git-to-codehost.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +# +# + +import argparse +import frontmatter +import os +import yaml + +default_path = "../www/logos" + +parser = argparse.ArgumentParser() +parser.add_argument("--directory", help="directory with logo subdirectories", action="store", default=default_path) +parser.add_argument("-q", "--quiet", help="hide status messages", default=True, dest='verbose', action="store_false") + +args = parser.parse_args() + +logoroot = args.directory +dirs = [f for f in os.listdir(logoroot) if os.path.isdir(os.path.join(logoroot, f))] +dirs.sort() +for logodir in dirs: + #print("INFO: procssing %s" % logodir) + + indexfn = os.path.join(logoroot, logodir, "index.md") + if os.path.exists(indexfn) == False: + print("WARNING: no index.md for %s" % logodir) + continue + + indexmd = frontmatter.load(indexfn) + + if "git" not in indexmd.keys(): + print("DEBUG: skipping %s (%s)" % (indexmd["title"], indexmd["logohandle"])) + continue + print("DEBUG: processing %s (%s)" % (indexmd["title"], indexmd["logohandle"])) + + indexmd["codehost"] = "https://github.com/%s" % indexmd["git"] + del indexmd["git"] + + #print("%s" % frontmatter.dumps(indexmd)) + + frontmatter.dump(indexmd, indexfn)