Move 'phase' attribute to AbstractEbuildProcess from subclasses, so
authorZac Medico <zmedico@gentoo.org>
Sat, 14 Aug 2010 16:37:43 +0000 (09:37 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 14 Aug 2010 16:37:43 +0000 (09:37 -0700)
the _get_phase() method isn't needed.

pym/_emerge/AbstractEbuildProcess.py
pym/_emerge/EbuildProcess.py
pym/_emerge/MiscFunctionsProcess.py

index 21fd8803874221e7becd4aa3c45d30045c67cd31..0dec6503659e72e34211077753a4465f137b6947 100644 (file)
@@ -19,21 +19,21 @@ from portage.util import writemsg_stdout
 
 class AbstractEbuildProcess(SpawnProcess):
 
-       __slots__ = ('settings',) + \
+       __slots__ = ('phase', 'settings',) + \
                ('_ipc_daemon', '_exit_command',)
        _phases_without_builddir = ('clean', 'cleanrm', 'depend', 'help',)
 
-       def _get_phase(self):
-               phase = getattr(self, 'phase', None)
-               if not phase:
+       def __init__(self, **kwargs):
+               SpawnProcess.__init__(self, **kwargs)
+               if self.phase is None:
                        phase = self.settings.get("EBUILD_PHASE")
                        if not phase:
                                phase = 'other'
-               return phase
+                       self.phase = phase
 
        def _start(self):
 
-               if self._get_phase() not in self._phases_without_builddir:
+               if self.phase not in self._phases_without_builddir:
                        self.settings['PORTAGE_IPC_DAEMON'] = "1"
                        self._exit_command = ExitCommand()
                        self._exit_command.reply_hook = self._exit_command_callback
@@ -71,7 +71,7 @@ class AbstractEbuildProcess(SpawnProcess):
                                self.cancel()
 
        def _orphan_process_warn(self):
-               phase = self._get_phase()
+               phase = self.phase
 
                msg = _("The ebuild phase '%s' with pid %s appears "
                "to have left an orphan process running in the "
@@ -94,7 +94,7 @@ class AbstractEbuildProcess(SpawnProcess):
 
        def _unexpected_exit(self):
 
-               phase = self._get_phase()
+               phase = self.phase
 
                msg = _("The ebuild phase '%s' has exited "
                "unexpectedly. This type of behavior "
@@ -120,7 +120,7 @@ class AbstractEbuildProcess(SpawnProcess):
 
        def _eerror(self, lines):
                out = StringIO()
-               phase = self._get_phase()
+               phase = self.phase
                for line in lines:
                        eerror(line, phase=phase, key=self.settings.mycpv, out=out)
                logfile = self.logfile
index 147f73a16db1329bc8191092a51afb5138fd7645..c643c3bd297e99a6f959b2340575599d585b2913 100644 (file)
@@ -8,7 +8,7 @@ from portage.package.ebuild.doebuild import doebuild, \
 
 class EbuildProcess(AbstractEbuildProcess):
 
-       __slots__ = ('phase', 'pkg', 'tree',)
+       __slots__ = ('pkg', 'tree',)
 
        def _start(self):
                # Don't open the log file during the clean phase since the
index bc70448d0d76bdaf4c2180dc30dfea00834f29fa..eaf8c2235b12d378fd2aef5fb6c5de30665178bf 100644 (file)
@@ -11,7 +11,7 @@ class MiscFunctionsProcess(AbstractEbuildProcess):
        Spawns misc-functions.sh with an existing ebuild environment.
        """
 
-       __slots__ = ('commands', 'phase', 'pkg',)
+       __slots__ = ('commands', 'pkg',)
 
        def _start(self):
                settings = self.settings