示例#1
0
文件: tool.py 项目: bendavis78/zope
    def _getImportContext(self, context_id, should_purge=None):
        """ Crack ID and generate appropriate import context.
        """
        encoding = self.getEncoding()

        if context_id.startswith('profile-'):

            context_id = context_id[len('profile-'):]
            info = _profile_registry.getProfileInfo(context_id)

            if info.get('product'):
                path = os.path.join(self._getProductPath(info['product']),
                                    info['path'])
            else:
                path = info['path']
            if should_purge is None:
                should_purge = (info.get('type') != EXTENSION)
            return DirectoryImportContext(self, path, should_purge, encoding)

        elif context_id.startswith('snapshot-'):
            context_id = context_id[len('snapshot-'):]
            if should_purge is None:
                should_purge = True
            return SnapshotImportContext(self, context_id, should_purge,
                                         encoding)
        else:
            raise KeyError, 'Unknown context "%s"' % context_id
示例#2
0
文件: tool.py 项目: bendavis78/zope
    def runImportStep(self, step_id, run_dependencies=True, purge_old=True):
        """ See ISetupTool.
        """
        profile_path = self._getFullyQualifiedProfileDirectory()
        encoding = self.getEncoding()
        context = DirectoryImportContext(self, profile_path, purge_old,
                                         encoding)

        info = self._import_registry.getStepMetadata(step_id)

        if info is None:
            raise ValueError, 'No such import step: %s' % step_id

        dependencies = info.get('dependencies', ())

        messages = {}
        steps = []
        if run_dependencies:
            for dependency in dependencies:

                if dependency not in steps:
                    message = self._doRunImportStep(dependency, context)
                    messages[dependency] = message
                    steps.append(dependency)

        message = self._doRunImportStep(step_id, context)
        messages[step_id] = message
        steps.append(step_id)

        return {'steps': steps, 'messages': messages}
示例#3
0
文件: tool.py 项目: bendavis78/zope
    def runAllImportSteps( self, purge_old=True ):

        """ See ISetupTool.
        """
        profile_path = self._getFullyQualifiedProfileDirectory()
        context = DirectoryImportContext( self, profile_path, purge_old )

        steps = self._import_registry.sortSteps()
        messages = {}

        for step in steps:
            message = self._doRunImportStep( step, context )
            messages[ step ] = message

        return { 'steps' : steps, 'messages' : messages }
示例#4
0
文件: tool.py 项目: bendavis78/zope
    def _getImportContext(self, context_id):
        """ Crack ID and generate appropriate import context.
        """
        if context_id.startswith('profile-'):

            context_id = context_id[len('profile-'):]
            info = _profile_registry.getProfileInfo(context_id)

            if info.get('product'):
                path = os.path.join(self._getProductPath(info['product']),
                                    info['path'])
            else:
                path = info['path']

            return DirectoryImportContext(self, path)

        # else snapshot
        context_id = context_id[len('snapshot-'):]
        return SnapshotImportContext(self, context_id)