本文整理汇总了Python中database.DatabaseManager.register方法的典型用法代码示例。如果您正苦于以下问题:Python DatabaseManager.register方法的具体用法?Python DatabaseManager.register怎么用?Python DatabaseManager.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.DatabaseManager
的用法示例。
在下文中一共展示了DatabaseManager.register方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Session
# 需要导入模块: from database import DatabaseManager [as 别名]
# 或者: from database.DatabaseManager import register [as 别名]
class Session(object):
"""Represents a session between libalpm and pyalpmm"""
options_to_apply = ["ignorepkgs", "ignoregrps", "noupgrades",
"noextracts", "cachedirs"]
def __init__(self, config):
config.events.StartInitSession()
# init alpm
if p.alpm_initialize() == -1:
raise SessionError("Could not initialize session (alpm_initialize)")
self.config = config
p.alpm_option_set_root(config.rootpath)
p.alpm_option_set_arch(config.architecture)
# set up and register databases
if p.alpm_option_set_dbpath(config.local_db_path) == -1:
raise SessionError("Could not open the database path: %s" % \
config.local_db_path)
self.db_man = DatabaseManager(config.events)
self.db_man.register("local", LocalDatabase())
for repo, url in config.available_repositories.items():
self.db_man.register(repo, SyncDatabase(repo, url))
if config.aur_support:
self.db_man.register("aur", AURDatabase(config))
self.apply_config()
self.config.events.DoneInitSession()
def release(self):
"""Release the session"""
p.alpm_release()
def apply_config(self):
"""Apply some special options to the libalpm session at the end of
initilization.
"""
# applying only listoptions, because 'logfile', 'rootpath'
# and 'dbroot' are already set somewhere else
for opt in self.options_to_apply:
confdata = self.config[opt]
if len(confdata) > 0:
fn = getattr(p, "alpm_option_set_{0}".format(opt))
fn(p.helper_create_alpm_list(list(confdata)))
#p.alpm_option_set_xfercommand(const char *cmd)
self.config.events.DoneApplyConfig()