Author: sebb
Date: Wed Jun 18 10:06:27 2025
New Revision: 1926539

URL: http://svn.apache.org/viewvc?rev=1926539&view=rev
Log:
Don't create unnecessary global variables

Modified:
    comdev/projects.apache.org/trunk/scripts/cronjobs/generaterepos.py

Modified: comdev/projects.apache.org/trunk/scripts/cronjobs/generaterepos.py
URL: 
http://svn.apache.org/viewvc/comdev/projects.apache.org/trunk/scripts/cronjobs/generaterepos.py?rev=1926539&r1=1926538&r2=1926539&view=diff
==============================================================================
--- comdev/projects.apache.org/trunk/scripts/cronjobs/generaterepos.py 
(original)
+++ comdev/projects.apache.org/trunk/scripts/cronjobs/generaterepos.py Wed Jun 
18 10:06:27 2025
@@ -33,33 +33,36 @@ class SVNRepoParser(HTMLParser):
             repos[committee + '-svn'] = 'https://svn.apache.org/repos/asf/' + 
committee + '/'
 
 
-# Parse svn repos
-try:
-    svnResponse = requests.get("https://svn.apache.org/repos/asf/";, 
timeout=120)
-    svnResponse.raise_for_status()
-
-    parser = SVNRepoParser()
-    parser.feed(svnResponse.content.decode("utf-8"))
-except requests.exceptions.RequestException as e:  # This is the correct syntax
-    print("ERROR: Unable to retrieve svn repos: %s", e)
-
-
-# Parse git repos
-try:
-    gitResponse = requests.get("https://gitbox.apache.org/repositories.json";, 
timeout=120)
-    gitResponse.raise_for_status()
-    gitData = json.loads(gitResponse.content.decode("utf-8"))
-
-    for committee in gitData['projects']:
-        for repo in gitData['projects'][committee]['repositories']:
-            repos[repo] = 'https://gitbox.apache.org/repos/asf/' + repo + 
'.git'
-except requests.exceptions.RequestException as e:  # This is the correct syntax
-    print("ERROR: Unable to retrieve git repos: %s", e)
-
-print("Writing json/foundation/repositories.json...")
-with open("../../site/json/foundation/repositories.json", "w", 
encoding='utf-8') as f:
-    json.dump(repos, f, sort_keys=True, indent=0)
-    f.close()
+def main():
+    # Parse svn repos
+    try:
+        svnResponse = requests.get("https://svn.apache.org/repos/asf/";, 
timeout=120)
+        svnResponse.raise_for_status()
+
+        parser = SVNRepoParser()
+        parser.feed(svnResponse.content.decode("utf-8"))
+    except requests.exceptions.RequestException as e:  # This is the correct 
syntax
+        print("ERROR: Unable to retrieve svn repos: %s", e)
+
+
+    # Parse git repos
+    try:
+        gitResponse = 
requests.get("https://gitbox.apache.org/repositories.json";, timeout=120)
+        gitResponse.raise_for_status()
+        gitData = json.loads(gitResponse.content.decode("utf-8"))
+
+        for committee in gitData['projects']:
+            for repo in gitData['projects'][committee]['repositories']:
+                repos[repo] = 'https://gitbox.apache.org/repos/asf/' + repo + 
'.git'
+    except requests.exceptions.RequestException as e:  # This is the correct 
syntax
+        print("ERROR: Unable to retrieve git repos: %s", e)
+
+    print("Writing json/foundation/repositories.json...")
+    with open("../../site/json/foundation/repositories.json", "w", 
encoding='utf-8') as f:
+        json.dump(repos, f, sort_keys=True, indent=0)
+        f.close()
 
-print("All done!")
+    print("All done!")
 
+if __name__ == '__main__':
+    main()


Reply via email to