* add multirepo support to sourcedb

* cosmetics
This commit is contained in:
Eray Özkural
2005-12-06 12:05:54 +00:00
parent ec7ee96f19
commit d2d288bff8
2 changed files with 38 additions and 5 deletions
+2 -3
View File
@@ -40,8 +40,7 @@ def handle_exception(exception, value, tb):
show_traceback = ctx.get_option('debug')
elif isinstance(value, pisi.Exception):
show_traceback = True
ui.error(_("""
Unhandled internal exception.
ui.error(_("""Unhandled internal exception.
Please file a bug report. (http://bugs.uludag.org.tr)"""))
else:
# For any other exception (possibly Python exceptions) show
@@ -64,7 +63,7 @@ Please file a bug report. (http://bugs.uludag.org.tr)"""))
ui.info(_("Use --debug to see a traceback."))
exit()
if __name__ == "__main__":
sys.excepthook = handle_exception
+36 -2
View File
@@ -33,8 +33,8 @@ import pisi.lockeddbshelve as shelve
class SourceDB(object):
def __init__(self):
self.d = shelve.LockedDBShelf('source')
def __init__(self, id = 'repo'):
self.d = shelve.LockedDBShelf('source-%s' % id)
def close(self):
self.d.close()
@@ -72,3 +72,37 @@ def finalize():
sourcedb.close()
sourcedb = None
sourcedbs = {}
def add_db(name):
pisi.sourcedb.sourcedbs[name] = SourceDB('repo-' + name)
def get_db(name):
return pisi.sourcedb.sourcedbs[name]
def remove_db(name):
del pisi.sourcedb.sourcedbs[name]
#FIXME: erase database file?
def has_package(name):
repo = which_repo(name)
if repo:# or thirdparty_packagedb.has_package(name) or inst_packagedb.has_package(name):
return True
return False
def which_repo(name):
import pisi.repodb
for repo in pisi.repodb.db.list():
if get_db(repo).has_source(name):
return repo
return None
def get_package(name):
repo = which_repo(name)
if repo:
return get_db(repo).get_source(name)
if thirdparty_packagedb.has_source(name):
return thirdparty_packagedb.get_source(name)
if inst_packagedb.has_source(name):
return inst_packagedb.get_source(name)
raise Error(_('get_source: source %s not found') % name)