Skip to content

Commit

Permalink
Code updates for git->codehost change
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Dec 31, 2024
1 parent 7e12d53 commit 2ac476c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions bin/fm-git-to-codehost.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 2ac476c

Please sign in to comment.