Skip to content

Instantly share code, notes, and snippets.

@yosshy
Last active September 6, 2017 09:38
Show Gist options
  • Save yosshy/4cf7c724bc31826f50a5fda154c0ff75 to your computer and use it in GitHub Desktop.
Save yosshy/4cf7c724bc31826f50a5fda154c0ff75 to your computer and use it in GitHub Desktop.
OpenStack Repositories Counter
#!/usr/bin/python
import requests
import yaml
URL = ("https://git.openstack.org/cgit/openstack/"
"governance/plain/reference/projects.yaml")
def walk(data):
refs = 0
for key, value in data.items():
if isinstance(value, dict):
refs += walk(value)
if key == "repos":
refs += 1
return refs
with requests.get(URL) as r:
p = yaml.load(r.text)
print(walk(p))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment