community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1772739 - in /comdev/tmp: ./ random_projects.py
Date Mon, 05 Dec 2016 18:06:15 GMT
Author: stain
Date: Mon Dec  5 18:06:15 2016
New Revision: 1772739

URL: http://svn.apache.org/viewvc?rev=1772739&view=rev
Log:
Print out 5 random projects

Added:
    comdev/tmp/
    comdev/tmp/random_projects.py   (with props)

Added: comdev/tmp/random_projects.py
URL: http://svn.apache.org/viewvc/comdev/tmp/random_projects.py?rev=1772739&view=auto
==============================================================================
--- comdev/tmp/random_projects.py (added)
+++ comdev/tmp/random_projects.py Mon Dec  5 18:06:15 2016
@@ -0,0 +1,46 @@
+#!/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
+"""
+
+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)

Propchange: comdev/tmp/random_projects.py
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message