* package-manager needs to handle ignore_file_conflicts option. It is too

cumbersome to pass ignore_file_conflicts from api to pisi internals. There
  exists many calls to pass this arg. So it would eventually be error-prone 
  and ugly.

  So a new method is added to config that makes it possible to change/add 
  options on the fly when needed. But this option should be used deliberately
  when there is no other or elegant way to do things. Since when an option
  is changed in a code path, it would make things hard to follow and leeds to
  maintanence problems.
This commit is contained in:
Faik Uygur
2006-11-05 11:12:18 +00:00
parent d557380613
commit 4e4019f013
4 changed files with 13 additions and 2 deletions
+2 -1
View File
@@ -34,6 +34,7 @@ import pisi.sourcedb
import pisi.component as component
from pisi.index import Index
import pisi.cli
from pisi.config import Options
from pisi.operations import install, remove, upgrade, emerge
from pisi.operations import plan_install_pkg_names as plan_install
from pisi.operations import plan_remove, plan_upgrade, upgrade_base, calculate_conflicts
@@ -50,7 +51,7 @@ class Error(pisi.Error):
pass
def init(database = True, write = True,
options = None, ui = None, comar = True,
options = Options(), ui = None, comar = True,
stdout = None, stderr = None,
comar_sockname = None,
signal_handling = True):
+5
View File
@@ -38,6 +38,9 @@ class Options(object):
else:
return self.__dict__[name]
def __setattr__(self, name, value):
self.__dict__[name] = value
class Config(object):
"""Config Singleton"""
@@ -62,6 +65,8 @@ class Config(object):
# build process.
self.environ = deepcopy(os.environ)
def set_option(self, opt, val):
setattr(self.options, opt, val)
def get_option(self, opt):
if self.options:
+3
View File
@@ -24,6 +24,9 @@ config = None
log = None
def set_option(opt, val):
return config and config.set_option(opt, val)
def get_option(opt):
return config and config.get_option(opt)
+3 -1
View File
@@ -69,9 +69,11 @@ def upgrade_pisi():
# high level operations
def install(packages, reinstall = False):
def install(packages, reinstall = False, ignore_file_conflicts=False):
"""install a list of packages (either files/urls, or names)"""
ctx.set_option('ignore_file_conflicts', ignore_file_conflicts)
# FIXME: this function name "install" makes impossible to import
# and use install module directly.
from pisi.atomicoperations import Error as InstallError