config: init data/output modules in constructor
authorZac Medico <zmedico@gentoo.org>
Sat, 10 Dec 2011 22:33:42 +0000 (14:33 -0800)
committerZac Medico <zmedico@gentoo.org>
Sat, 10 Dec 2011 22:33:42 +0000 (14:33 -0800)
The first constructed config object initializes these modules, and
subsequent calls to the _init() functions have no effect.

pym/_emerge/actions.py
pym/portage/_legacy_globals.py
pym/portage/data.py
pym/portage/package/ebuild/config.py

index 7150c236384c138cfa6ed50170473a84f293871e..484f6b09bf20f88524fcf194f1dd2df0d28461c2 100644 (file)
@@ -2990,10 +2990,6 @@ def load_emerge_config(trees=None):
        settings = trees[trees._target_eroot]['vartree'].settings
        mtimedbfile = os.path.join(settings['EROOT'], portage.CACHE_PATH, "mtimedb")
        mtimedb = portage.MtimeDB(mtimedbfile)
-       portage.output._init(config_root=settings['PORTAGE_CONFIGROOT'])
-       # The portage_uid initialization here must happen before
-       # the _init_dirs() calls below.
-       portage.data._init(settings)
        QueryCommand._db = trees
 
        for root, root_trees in trees.items():
index e818e7e7a18873a6d457bedbb805f3ac9c0faaf6..abffa0e9a0f110a8f7a84f62fdd190a852f62337 100644 (file)
@@ -36,8 +36,6 @@ def _get_legacy_global(name):
        del portage._initializing_globals
 
        settings = portage.db[portage.db._target_eroot]["vartree"].settings
-       portage.output._init(config_root=settings['PORTAGE_CONFIGROOT'])
-       portage.data._init(settings)
 
        portage.settings = settings
        constructed.add('settings')
index 53af6b9665405fe99b93fd0ffcde36068cb890d3..7c17334451217df552bf65015991012f0f468c91 100644 (file)
@@ -169,13 +169,14 @@ def _init(settings):
        initialize global variables. This allows settings to come from make.conf
        instead of requiring them to be set in the calling environment.
        """
-       if '_portage_grpname' not in _initialized_globals:
+       if '_portage_grpname' not in _initialized_globals and \
+               '_portage_uname' not in _initialized_globals:
+
                v = settings.get('PORTAGE_GRPNAME')
                if v is not None:
                        globals()['_portage_grpname'] = v
                        _initialized_globals.add('_portage_grpname')
 
-       if '_portage_uname' not in _initialized_globals:
                v = settings.get('PORTAGE_USERNAME')
                if v is not None:
                        globals()['_portage_uname'] = v
index 7fb4ff0962996611dc34579d16609c1280d9b5fc..21af0de7682e286495ba3287675490bee0586a2a 100644 (file)
@@ -789,6 +789,11 @@ class config(object):
                                        self[k] = self[k].lower()
                                        self.backup_changes(k)
 
+                       # The first constructed config object initializes these modules,
+                       # and subsequent calls to the _init() functions have no effect.
+                       portage.output._init(config_root=self['PORTAGE_CONFIGROOT'])
+                       portage.data._init(self)
+
                if mycpv:
                        self.setcpv(mycpv)