[Collab-maint-devel] SVN: r109 - in lib/trunk: bin lib/collabmaint
lib/collabmaint/repos
hertzog at debian.org
hertzog at debian.org
Sun Mar 26 20:54:22 UTC 2006
Author: hertzog
Date: 2006-03-26 20:54:21 +0000 (Sun, 26 Mar 2006)
New Revision: 109
Added:
lib/trunk/bin/update-db.py
Modified:
lib/trunk/bin/list-packages.py
lib/trunk/lib/collabmaint/__init__.py
lib/trunk/lib/collabmaint/db.py
lib/trunk/lib/collabmaint/repos/base.py
lib/trunk/lib/collabmaint/repos/builder.py
lib/trunk/lib/collabmaint/repos/subversion.py
Log:
Update some backend implementation.
Modified: lib/trunk/bin/list-packages.py
===================================================================
--- lib/trunk/bin/list-packages.py 2006-03-26 20:53:13 UTC (rev 108)
+++ lib/trunk/bin/list-packages.py 2006-03-26 20:54:21 UTC (rev 109)
@@ -4,18 +4,9 @@
sys.path.append("./lib")
from collabmaint.conf import Cnf
-from collabmaint.repos.builder import RepositoryBuilder
+import collabmaint.repos.builder
-builder = RepositoryBuilder()
-objects = []
-for name in Cnf["ActiveRepositories"].split(" "):
- object = builder.build(Cnf["Repositories::" + name + "::type"])
- if object != None:
- object.initialize(Cnf, "Repositories::" + name)
- objects.append(object)
- else:
- #Ignoring repository since object creation failed
- pass
+objects = collabmaint.repos.builder.getAllRepositories(Cnf)
for obj in objects:
list = obj.getPackageList()
Added: lib/trunk/bin/update-db.py
===================================================================
--- lib/trunk/bin/update-db.py 2006-03-26 20:53:13 UTC (rev 108)
+++ lib/trunk/bin/update-db.py 2006-03-26 20:54:21 UTC (rev 109)
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+
+import sys
+sys.path.append("./lib")
+
+from collabmaint.conf import Cnf
+import collabmaint.repos.builder
+
+import collabmaint.db
+from sqlobject import *
+
+objects = collabmaint.repos.builder.getAllRepositories(Cnf)
+
+# TODO:
+# this script should insert everything in the DB and for some reasons,
+# doesn't manage to handle the versions ...
+
+for obj in objects:
+ mylist = obj.getPackageList()
+ for pkg_name in mylist:
+ meta = obj.getMetaInformation(pkg_name)
+ try:
+ package = collabmaint.db.Package.byName(pkg_name)
+ except SQLObjectNotFound:
+ package = collabmaint.db.Package(name=pkg_name)
+ try:
+ suite = collabmaint.db.Suite.byDistribution(meta["distribution"])
+ except SQLObjectNotFound:
+ suite = collabmaint.db.Suite(distribution=meta["distribution"])
+ versions = list(collabmaint.db.Version.select( AND(
+ collabmaint.db.Version.q.packageID == package.q.id,
+ collabmaint.db.Version.q.source == obj.id)))
+ if len(versions) == 0:
+ version = collabmaint.db.Version(package=package, version=meta["version"],
+ suite=suite, source=obj.id)
+ else:
+ version = versions[0]
+ if version not in package.versions:
+ print package
+ print version
Property changes on: lib/trunk/bin/update-db.py
___________________________________________________________________
Name: svn:executable
+ *
Modified: lib/trunk/lib/collabmaint/__init__.py
===================================================================
--- lib/trunk/lib/collabmaint/__init__.py 2006-03-26 20:53:13 UTC (rev 108)
+++ lib/trunk/lib/collabmaint/__init__.py 2006-03-26 20:54:21 UTC (rev 109)
@@ -1 +1 @@
-__all__ = ["conf", "repos"]
+__all__ = ["conf", "repos", "web"]
Modified: lib/trunk/lib/collabmaint/db.py
===================================================================
--- lib/trunk/lib/collabmaint/db.py 2006-03-26 20:53:13 UTC (rev 108)
+++ lib/trunk/lib/collabmaint/db.py 2006-03-26 20:54:21 UTC (rev 109)
@@ -5,7 +5,7 @@
__connection__ = Cnf["DB"]
class Package(SQLObject):
- name = StringCol()
+ name = StringCol(alternateID=True)
versions = MultipleJoin('Version')
class Suite(SQLObject):
Modified: lib/trunk/lib/collabmaint/repos/base.py
===================================================================
--- lib/trunk/lib/collabmaint/repos/base.py 2006-03-26 20:53:13 UTC (rev 108)
+++ lib/trunk/lib/collabmaint/repos/base.py 2006-03-26 20:54:21 UTC (rev 109)
@@ -4,8 +4,12 @@
class Repository:
"Interface to a VCS repository used to handle Debian packages"
- def initialize(self, Cnf, basekey):
+ id = ""
+
+ def initialize(self, Cnf, name):
"Initialize the internal data of the modules"
+ # name is the identifier of the repository
+ # Cnf["Repositories::name::*"] contains more infos
pass
# Those functions must be implemented by any derived module
Modified: lib/trunk/lib/collabmaint/repos/builder.py
===================================================================
--- lib/trunk/lib/collabmaint/repos/builder.py 2006-03-26 20:53:13 UTC (rev 108)
+++ lib/trunk/lib/collabmaint/repos/builder.py 2006-03-26 20:54:21 UTC (rev 109)
@@ -7,3 +7,16 @@
if type == "subversion":
repo = SVNRepository()
return repo
+
+def getAllRepositories(Cnf):
+ builder = RepositoryBuilder()
+ objects = []
+ for name in Cnf["ActiveRepositories"].split(" "):
+ object = builder.build(Cnf["Repositories::" + name + "::type"])
+ if object != None:
+ object.initialize(Cnf, name)
+ objects.append(object)
+ else:
+ #Ignoring repository since object creation failed
+ pass
+ return objects
Modified: lib/trunk/lib/collabmaint/repos/subversion.py
===================================================================
--- lib/trunk/lib/collabmaint/repos/subversion.py 2006-03-26 20:53:13 UTC (rev 108)
+++ lib/trunk/lib/collabmaint/repos/subversion.py 2006-03-26 20:54:21 UTC (rev 109)
@@ -23,11 +23,13 @@
if initialized == 0:
svn.core.apr_terminate()
- def initialize(self, Cnf, basekey):
+ def initialize(self, Cnf, name):
"Initialize the internal data"
+ basekey = "Repositories::" + name
assert Cnf[basekey + "::type"] == "subversion"
self.localpath = Cnf[basekey + "::localpath"]
self.subdir = Cnf[basekey + "::subdirectory"]
+ self.id = name
# Open the repository at REPOS_PATH, and get a reference to its
# versioning filesystem.
self.repos_obj = svn.repos.svn_repos_open(self.localpath, self.pool)
More information about the Collab-maint-devel
mailing list