def _set_lock_set(self, env_spec_name, lock_set, all_names): """Library-internal method.""" assert env_spec_name is not None assert lock_set is not None assert all_names is not None assert env_spec_name in all_names # if all locking is disabled, switch to individually # disabling each env spec so we can enable the one # we care about here. for_all = self.get_value(['locking_enabled'], True) if not for_all: self.set_value(['locking_enabled'], True) new_env_specs = self.get_value(['env_specs'], None) if new_env_specs is None: new_env_specs = _CommentedMap() _block_style_all_nodes(new_env_specs) self.set_value(['env_specs'], new_env_specs) for name in all_names: if name == env_spec_name: continue single_env = new_env_specs.get(name, None) if single_env is None: single_env = _CommentedMap() _block_style_all_nodes(single_env) new_env_specs[name] = single_env single_env['locked'] = False # now set up the one env as_json = lock_set.to_json() self.set_value(['env_specs', env_spec_name], as_json)
def to_json(self): """JSON/YAML version of the lock set.""" yaml_dict = _CommentedMap() yaml_dict['locked'] = self.enabled if self.env_spec_hash is not None: yaml_dict['env_spec_hash'] = self.env_spec_hash platforms_list = _CommentedSeq() for platform in self.platforms: platforms_list.append(platform) yaml_dict['platforms'] = platforms_list packages_dict = _CommentedMap() for platform in conda_api.sort_platform_list( self._package_specs_by_platform.keys()): packages = _CommentedSeq() for package in self._package_specs_by_platform[platform]: packages.append(package) packages_dict[platform] = packages yaml_dict['packages'] = packages_dict _block_style_all_nodes(yaml_dict) return yaml_dict