Skip to content

Instantly share code, notes, and snippets.

@piusayowale
Created January 10, 2023 14:26
Show Gist options
  • Save piusayowale/a14633b3f11e45dfe0e5a85cf9c7a926 to your computer and use it in GitHub Desktop.
Save piusayowale/a14633b3f11e45dfe0e5a85cf9c7a926 to your computer and use it in GitHub Desktop.
get list of packages and their descriptions
import os
import json
import sys
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
def save(dat):
with open('dump', 'a') as file:
file.write(dat)
#file.close()
def readfile(file):
f = open(file, "r")
return f.read()
def parseDes(input):
js = readfile(input)
parsed = json.loads(js)
save(parsed["name"] + ": ")
try:
desc = parsed["description"]
if(desc is not None):
save(desc)
save("\r\n\n")
except:
pass
directory = "/vcpkg/ports"
for filename in os.listdir(directory):
temp = os.path.join(directory, filename)
f = os.path.join(temp, "vcpkg.json")
if(os.path.isfile(f)):
parseDes(f)
print("Done!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment