Exemple #1
0
    def _update_history(
        self,
        get_command: Callable,
        packages: Packages,
        channels: ListLike,
        strict_channel_priority: bool = True,
    ):
        self.env.update_dependencies()
        self.env.history.update_packages(packages=packages,
                                         dependencies=self.env.dependencies)

        self.env.validate_packages(packages)

        log = get_command(name=self.env.name, packages=packages)
        if channels:
            log = log + " " + Channels.format_channels(channels)

        specs = self.env.history.actions.get_package_specs(
            packages=packages, dependencies=self.env.dependencies["conda"])

        channel_string = self.env.history.channels.create_channel_command(
            preferred_channels=channels,
            strict_channel_priority=strict_channel_priority)
        command_with_specs = get_command(name=self.env.name,
                                         packages=Packages.from_specs(specs))
        action = f"{command_with_specs} {channel_string}"

        self.env.history.append(log=log, action=action)
Exemple #2
0
    def update_history_remove(self,
                              packages: Packages,
                              channels: ListLike = None) -> None:
        """Update history for conda remove."""
        self.env.update_dependencies()
        self.env.history.remove_packages(packages=packages,
                                         dependencies=self.env.dependencies)
        self.env.validate_packages()

        remove_command = get_conda_remove_command(name=self.env.name,
                                                  packages=packages)
        if channels:
            log = remove_command + " " + Channels.format_channels(channels)
        else:
            log = remove_command

        channel_command = self._get_conda_remove_channel_command(
            channels=channels)
        action = f"{remove_command} {channel_command}"

        self.env.history.append(log=log, action=action)