[PATCH] extracting cgit groups from doap files
- From: Shaun McCance <shaunm gnome org>
- Subject: [PATCH] extracting cgit groups from doap files
- Date: Sun, 19 Apr 2009 00:56:45 -0500
---
extract-doap-info | 45 +++++++++++++++++++++++++++
extract-doap-shortdesc | 18 -----------
find-cgit-repos | 64 +++++++++++++++++++++++++++++++++++++++
find-cgit-repos.sh | 34 --------------------
post-receive-update-description | 3 +-
semi_rdf.py | 2 +-
update-cgit | 2 +-
7 files changed, 112 insertions(+), 56 deletions(-)
create mode 100755 extract-doap-info
delete mode 100755 extract-doap-shortdesc
create mode 100755 find-cgit-repos
delete mode 100755 find-cgit-repos.sh
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/extract-doap-shortdesc b/extract-doap-shortdesc
deleted file mode 100755
index 23bcaae..0000000
--- a/extract-doap-shortdesc
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/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)
-
-import semi_rdf
-
-DOAP = "http://usefulinc.com/ns/doap#"
-
-nodes = semi_rdf.read_rdf(sys.stdin)
-for node in nodes:
- if node.name != (DOAP, "Project"):
- continue
- print node.find_property((DOAP, "shortdesc"))
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/find-cgit-repos.sh b/find-cgit-repos.sh
deleted file mode 100755
index 543721f..0000000
--- a/find-cgit-repos.sh
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-
-# This script should be run with the output written to /git/cgit.repositories, which
-# is included from /etc/cgitrc
-
-function list_repos() {
- paths=$1
- group=$2
- for p in $paths; do
- for r in $(echo $p/*); do
- if test -d $r/objects; then
- shortname=${r/\/git\//}
- shortname=${shortname/\/srv\//}
- shortname=${shortname%%.git}
- shortname=${shortname/\/home\//\~}
- url=${shortname}
- if test -f $r/pending ; then
- pending="[PENDING] "
- else
- pending=""
- fi
- test -z "$group" || echo repo.group=$group
- echo repo.url=$url
- echo repo.name=$shortname
- echo repo.desc=$pending$(test -f $r/description && cat $r/description)
- echo repo.path=$r
- echo
- fi
- done
- done
-}
-
-list_repos "/git" "GNOME git repositories"
-list_repos "/git/preview" "Git conversion preview repositories"
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"
--
1.6.0.6
--=-cM3pdxRaf2CWIIzvW++i--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]