* add multirepo support to sourcedb
* cosmetics
This commit is contained in:
@@ -40,8 +40,7 @@ def handle_exception(exception, value, tb):
|
|||||||
show_traceback = ctx.get_option('debug')
|
show_traceback = ctx.get_option('debug')
|
||||||
elif isinstance(value, pisi.Exception):
|
elif isinstance(value, pisi.Exception):
|
||||||
show_traceback = True
|
show_traceback = True
|
||||||
ui.error(_("""
|
ui.error(_("""Unhandled internal exception.
|
||||||
Unhandled internal exception.
|
|
||||||
Please file a bug report. (http://bugs.uludag.org.tr)"""))
|
Please file a bug report. (http://bugs.uludag.org.tr)"""))
|
||||||
else:
|
else:
|
||||||
# For any other exception (possibly Python exceptions) show
|
# 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."))
|
ui.info(_("Use --debug to see a traceback."))
|
||||||
|
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
sys.excepthook = handle_exception
|
sys.excepthook = handle_exception
|
||||||
|
|||||||
+36
-2
@@ -33,8 +33,8 @@ import pisi.lockeddbshelve as shelve
|
|||||||
|
|
||||||
class SourceDB(object):
|
class SourceDB(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, id = 'repo'):
|
||||||
self.d = shelve.LockedDBShelf('source')
|
self.d = shelve.LockedDBShelf('source-%s' % id)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.d.close()
|
self.d.close()
|
||||||
@@ -72,3 +72,37 @@ def finalize():
|
|||||||
sourcedb.close()
|
sourcedb.close()
|
||||||
sourcedb = None
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user