示例#1
0
文件: database.py 项目: LLNL/spack
    def installed_relatives(self, spec, direction='children', transitive=True):
        """Return installed specs related to this one."""
        if direction not in ('parents', 'children'):
            raise ValueError("Invalid direction: %s" % direction)

        relatives = set()
        for spec in self.query(spec):
            if transitive:
                to_add = spec.traverse(direction=direction, root=False)
            elif direction == 'parents':
                to_add = spec.dependents()
            else:  # direction == 'children'
                to_add = spec.dependencies()

            for relative in to_add:
                hash_key = relative.dag_hash()
                if hash_key not in self._data:
                    reltype = ('Dependent' if direction == 'parents'
                               else 'Dependency')
                    tty.warn("Inconsistent state! %s %s of %s not in DB"
                             % (reltype, hash_key, spec.dag_hash()))
                    continue

                if not self._data[hash_key].installed:
                    continue

                relatives.add(relative)
        return relatives
示例#2
0
    def installed_relatives(self, spec, direction='children', transitive=True):
        """Return installed specs related to this one."""
        if direction not in ('parents', 'children'):
            raise ValueError("Invalid direction: %s" % direction)

        relatives = set()
        for spec in self.query(spec):
            if transitive:
                to_add = spec.traverse(direction=direction, root=False)
            elif direction == 'parents':
                to_add = spec.dependents()
            else:  # direction == 'children'
                to_add = spec.dependencies()

            for relative in to_add:
                hash_key = relative.dag_hash()
                if hash_key not in self._data:
                    reltype = ('Dependent' if direction == 'parents'
                               else 'Dependency')
                    tty.warn("Inconsistent state! %s %s of %s not in DB"
                             % (reltype, hash_key, spec.dag_hash()))
                    continue

                if not self._data[hash_key].installed:
                    continue

                relatives.add(relative)
        return relatives
示例#3
0
文件: database.py 项目: lorak41/spack
    def installed_relatives(self, spec, direction='children', transitive=True,
                            deptype='all'):
        """Return installed specs related to this one."""
        if direction not in ('parents', 'children'):
            raise ValueError("Invalid direction: %s" % direction)

        relatives = set()
        for spec in self.query(spec):
            if transitive:
                to_add = spec.traverse(
                    direction=direction, root=False, deptype=deptype)
            elif direction == 'parents':
                to_add = spec.dependents(deptype=deptype)
            else:  # direction == 'children'
                to_add = spec.dependencies(deptype=deptype)

            for relative in to_add:
                hash_key = relative.dag_hash()
                upstream, record = self.query_by_spec_hash(hash_key)
                if not record:
                    reltype = ('Dependent' if direction == 'parents'
                               else 'Dependency')
                    msg = ("Inconsistent state! %s %s of %s not in DB"
                           % (reltype, hash_key, spec.dag_hash()))
                    if self._fail_when_missing_deps:
                        raise MissingDependenciesError(msg)
                    tty.warn(msg)
                    continue

                if not record.installed:
                    continue

                relatives.add(relative)
        return relatives