Exemple #1
0
    def add_variables(self, project, vars_to_add, defaults):
        """Add variables in anaconda-project.yml, optionally setting their defaults.

        Returns a ``Status`` instance which evaluates to True on
        success and has an ``errors`` property (with a list of error
        strings) on failure.

        Args:
            project (Project): the project
            vars_to_add (list of str): variable names
            defaults (dict): dictionary from keys to defaults, can be empty

        Returns:
            ``Status`` instance
        """
        return project_ops.add_variables(project=project, vars_to_add=vars_to_add, defaults=defaults)
Exemple #2
0
def add_variables(project_dir, vars_to_add, default):
    """Add env variables to project file.

    Returns:
        Returns exit code
    """
    if len(vars_to_add) > 1 and default is not None:
        print("It isn't clear which variable your --default option goes with; "
              "add one variable at a time if using --default.",
              file=sys.stderr)
        return 1
    project = load_project(project_dir)
    status = project_ops.add_variables(project, vars_to_add, {vars_to_add[0]: default})
    if status:
        return 0
    else:
        console_utils.print_status_errors(status)
        return 1