Beispiel #1
0
def install(package_specifier):
    """Install a package."""
    project_id = package_specifier.project

    # Look up project.
    project = recipe.get_project(project_id)
    if not project:
        return error("No such project.")

    # Ensure not already installed.
    if find_installed_packages(package_specifier):
        return error("Already installed.")

    # Create a package representing an installed instance of the project with
    # the given parameters.
    package = factory(project, package_specifier)
    if package is no_factory:
        return error("Not installable.")
    if not package:
        return error("Invalid configuration.")
    if isinstance(package, basestring):
        return error(package)
    assert package_specifier.match(package)

    # Install to default location.
    package[a_location] = join(paths.packages, package.project.name)
    installer(package)

    # Update database.
    with catalogue.modify(catalogue_path) as cat:
        cat[package.project.id].append(package)

    # If no packages from this project are already selected, select this one.
    selected = select.get_selected_packages()
    if not any(p for p in selected if p.project.id == project_id):
        select.select_package(package)
Beispiel #2
0
def deselect_package(package):
    with catalogue.modify(segment_path) as segment:
        remove_all(segment[package.project.id], package)
    environment.reload()
Beispiel #3
0
def select_package(package):
    with catalogue.modify(segment_path) as segment:
        segment[package.project.id].append(package)
    environment.reload()