#!/usr/bin/env python3 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Prints out some random projects (by default 5) from https://projects.apache.org/json/foundation/projects.json Example: stain@biggiebuntu:~/src/comdev/tmp$ ./random_projects.py 3 karaf activemq oozie """ import urllib.request import json import random import codecs import sys utf8 = codecs.getreader("utf-8") def main(argv): num = 5 if (len(argv) > 1): num = int(argv[1]) with(urllib.request.urlopen("https://projects.apache.org/json/foundation/projects.json")) as f: projects = json.load(utf8(f)) names = list(projects.keys()) random.shuffle(names) for p in names[:num]: print(p) if __name__ == "__main__": main(sys.argv)