Ejemplo n.º 1
0
    def test_rdepends(self):

        for mfmap in (IPMAP, APMAP):
            pilist = DependencyUtils.rdepends(
                PackageIdentifier.parse_list(["condition-A_1.0"]), mfmap)
            self.assertEqual(["condition_1.0"], list(map(str, pilist)))

            pilist = DependencyUtils.rdepends(PackageIdentifier.parse_list(
                ["condition-A_1.0"]),
                                              mfmap,
                                              env=Environment(None, {}))
            self.assertEqual([], list(map(str, pilist)))

            pilist = DependencyUtils.rdepends(
                PackageIdentifier.parse_list(["condition-A_1.0"]),
                mfmap,
                env=Environment(None, {"FOO": "BAR"}))
            self.assertEqual(["condition_1.0"], list(map(str, pilist)))

            pilist = DependencyUtils.rdepends(PackageIdentifier.parse_list(
                ["condition-B_1.0"]),
                                              mfmap,
                                              env=Environment(None, {}))
            self.assertEqual(["condition_1.0"], list(map(str, pilist)))

            pilist = DependencyUtils.rdepends(
                PackageIdentifier.parse_list(["condition-B_1.0"]),
                mfmap,
                env=Environment(None, {"FOO": "BAR"}))
            self.assertEqual([], list(map(str, pilist)))

            pilist = DependencyUtils.rdepends(
                PackageIdentifier.parse_list(["condition-B_1.0"]), {})
            self.assertEqual([], list(map(str, pilist)))
Ejemplo n.º 2
0
    def execute(self, args, uargs):
        pm = PackageManager()
        env = None
        # If the user specified env values, build a complete env
        if args.custom_envlist is not None:
            env = Environment.build(
                pm.build_builtin_environment(), pm.build_user_environment(),
                Environment("Custom env",
                            env_list_to_map(args.custom_envlist)))

        items = None
        if args.dependency_type == "available":
            items = DependencyUtils.install(PackageIdentifier.parse_list(
                args.packages),
                                            pm.list_available_packages(), {},
                                            env=env)
        elif args.dependency_type == "install":
            items = DependencyUtils.install(PackageIdentifier.parse_list(
                args.packages),
                                            pm.list_available_packages(),
                                            pm.list_installed_packages(),
                                            env=env)
        elif args.dependency_type == "installed":
            items = DependencyUtils.installed(PackageIdentifier.parse_list(
                args.packages),
                                              pm.list_installed_packages(),
                                              env=env,
                                              ignore_unknown=True)
        elif args.dependency_type == "uninstall":
            items = DependencyUtils.uninstall(PackageIdentifier.parse_list(
                args.packages),
                                              pm.list_installed_packages(),
                                              env=env)
        elif args.dependency_type == "prereq":
            items = DependencyUtils.prereq(PackageIdentifier.parse_list(
                args.packages),
                                           pm.list_available_packages(),
                                           pm.list_installed_packages(),
                                           env=env)
        elif args.dependency_type == "upgrade":
            items, _ = DependencyUtils.upgrade(
                None if len(args.packages) == 0 else args.packages,
                pm.list_available_packages(),
                pm.list_installed_packages(),
                env=env)
        elif args.dependency_type == "rdepends":
            mfmap = OrderedDict()
            mfmap.update(
                DependencyUtils.rdepends(PackageIdentifier.parse_list(
                    args.packages),
                                         pm.list_available_packages(),
                                         env=env))
            mfmap.update(
                DependencyUtils.rdepends(PackageIdentifier.parse_list(
                    args.packages),
                                         pm.list_installed_packages(),
                                         env=env))
            items = mfmap.values()
        else:
            raise ValueError()

        rend = ManifestListRenderer()
        rend.extend(items)
        pm.print_renderer(rend)