[sysadmin-bin: 88/168] Use categories from module .doap files for CGIT grops



commit c56077b905d617189e69afb73f84baa893df7617
Author: Shaun McCance <shaunm gnome org>
Date:   Sun Apr 19 00:56:45 2009 -0500

    Use categories from module .doap files for CGIT grops
    
    find-cgit-repos: Rewrite to Python and group by category
    extract-doap-info extract-doap-shortdesc: Generalize
     extract-doap-shortdesc to also extract out a category and write
     it to $GIT_DIR/gnome_group.
    post-receive-update-description: Use extract-doap-info
    semi_rdf.py: Fix bug where URL resources were getting rdf:resource
     as their value rather than the URL.

 extract-doap-info               |   45 +++++++++++++++++++++++++++
 extract-doap-shortdesc          |   18 -----------
 find-cgit-repos                 |   64 +++++++++++++++++++++++++++++++++++++++
 find-cgit-repos.sh              |   46 ----------------------------
 post-receive-update-description |    3 +-
 semi_rdf.py                     |    2 +-
 update-cgit                     |    2 +-
 7 files changed, 112 insertions(+), 68 deletions(-)
---
diff --git a/extract-doap-info b/extract-doap-info
new file mode 100755
index 0000000..a97d238
--- /dev/null
+++ b/extract-doap-info
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+
+import os
+import sys
+
+script_path = os.path.realpath(os.path.abspath(sys.argv[0]))
+script_dir = os.path.dirname(script_path)
+sys.path.insert(0, script_dir)
+
+if len(sys.argv) < 2:
+    sys.exit(1)
+git_dir = sys.argv[1]
+
+import semi_rdf
+
+DOAP = "http://usefulinc.com/ns/doap#";
+GNOME = "http://api.gnome.org/doap-extensions#";
+
+groups = {
+    (GNOME + 'admin'): 'admin',
+    (GNOME + 'bindings'): 'platform',
+    (GNOME + 'deprecated'): 'deprecated',
+    (GNOME + 'desktop'): 'desktop',
+    (GNOME + 'development'): 'development',
+    (GNOME + 'infrastructure'): 'infrastructure',
+    (GNOME + 'platform'): 'platform',
+    (GNOME + 'productivity'): 'productivity'
+    }
+
+
+nodes = semi_rdf.read_rdf(sys.stdin)
+for node in nodes:
+    if node.name != (DOAP, "Project"):
+        continue
+
+    shortdesc = node.find_property((DOAP, "shortdesc"))
+    fd = open(os.path.join(git_dir, 'description'), 'w')
+    print >> fd, shortdesc
+    fd.close()
+
+    group = node.find_property((DOAP, "category"))
+    group = groups.get(group, 'other')
+    fd = open(os.path.join(git_dir, 'gnome_group'), 'w')
+    print >> fd, group
+    fd.close()
diff --git a/find-cgit-repos b/find-cgit-repos
new file mode 100755
index 0000000..bcd8f7a
--- /dev/null
+++ b/find-cgit-repos
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+
+# This script should be run with the output written to /git/cgit.repositories, which
+# is included from /etc/cgitrc
+
+import os
+import re
+
+grouplist = ('Administration Tools', 'Bindings', 'Deprecated', 'Desktop', 'Development Tools',
+             'Infrastructure', 'Platform', 'Productivity Tools', 'Other')
+groupmap = {
+    'admin': 'Administration Tools',
+    'bindings': 'Bindings',
+    'deprecated': 'Deprecated',
+    'desktop': 'Desktop',
+    'development': 'Development Tools',
+    'infrastructure': 'Infrastructure',
+    'platform': 'Platform',
+    'productivity': 'Productivity Tools'
+    }
+groups = {}
+for group in grouplist:
+    groups[group] = []
+
+def list_repos (paths):
+    for path in paths:
+        if not os.path.isdir(path):
+            continue
+        for repo in os.listdir(path):
+            repopath = os.path.join (path, repo)
+            if not os.path.isdir(repopath):
+                continue
+            shortname = re.sub('/git/', '', repopath)
+            shortname = re.sub('/srv/', '', shortname)
+            shortname = re.sub('\.git$', '', shortname)
+            shortname = re.sub('/home/', '~', shortname)
+            pending = ''
+            if os.path.isfile(os.path.join(repopath, 'pending')):
+                pending = '[PENDING] '
+
+            desc_file = os.path.join(repopath, 'description')
+            desc = ''
+            if os.path.isfile(desc_file):
+                desc = open(desc_file).readline().strip()
+            desc = pending + desc
+                
+            group_file = os.path.join(repopath, 'gnome_group')
+            group = None
+            if os.path.isfile(group_file):
+                group = open(group_file).readline().strip()
+            group = groupmap.get(group, 'Other')
+
+            groups[group].append ((shortname, shortname, desc, repopath))
+
+    for group in grouplist:
+        for repo in groups[group]:
+            print 'repo.group=%s' % group
+            print 'repo.url=%s' % repo[0]
+            print 'repo.name=%s' % repo[1]
+            print 'repo.desc=%s' % repo[2]
+            print 'repo.path=%s' % repo[3]
+            print
+
+list_repos (('/git', '/git/preview'))
diff --git a/post-receive-update-description b/post-receive-update-description
index 9bcf419..9e57d52 100755
--- a/post-receive-update-description
+++ b/post-receive-update-description
@@ -17,8 +17,7 @@ update_description_from_file() {
         return
     fi
 
-    shortdesc=$(git cat-file blob "$newrev:$path" | $BINDIR/extract-doap-shortdesc)
-    echo $shortdesc > $GIT_DIR/description
+    git cat-file blob "$newrev:$path" | $BINDIR/extract-doap-info $GIT_DIR
     $BINDIR/update-cgit
 }
 
diff --git a/semi_rdf.py b/semi_rdf.py
index 9f113de..5e9dfba 100755
--- a/semi_rdf.py
+++ b/semi_rdf.py
@@ -81,7 +81,7 @@ class RdfHandler(xml.sax.handler.ContentHandler):
                 if attrname == (XML, "lang"):
                     pass
                 elif attrname == (RDF, "resource"):
-                    resource = attrname
+                    resource = attributes.getValue(attrname)
                 elif attrname == (RDF, "parseType"):
                     parseType = attributes.getValue(attrname)
                     if parseType == "resource":
diff --git a/update-cgit b/update-cgit
index 841b7fe..c0544d2 100755
--- a/update-cgit
+++ b/update-cgit
@@ -13,5 +13,5 @@ if [ `whoami` != gitadmin ] ; then
 fi
 
 echo -n "Updating the cgit repository list... "
-$BINDIR/find-cgit-repos.sh > /git/cgit.repositories
+$BINDIR/find-cgit-repos > /git/cgit.repositories
 echo "done"



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]