Esempio n. 1
0
def setup_package(package_key, config_dict, dotfile_path):
    """
        Setup package directory on dotfile
    """

    # Make a path for the new directory path using the name specified in the
    # config then make the folder using the path.
    package_config = config_dict['options'][package_key]
    package_name = package_config['package_name']
    new_package_path = dotfile_path + package_config['directoryName'] + "/"
    if directories.is_folder(new_package_path) is False:
        directories.create_folder(new_package_path, package_name)

    for link in package_config['links']:
        for key, value in link.items():
            source_file = HOME_PATH + value
            dest_file = new_package_path + key

            # Checks
            if directories.is_folder(dest_file):
                continue
            elif directories.is_file(dest_file):
                continue

            # Setup
            if directories.is_folder(source_file):
                symlink.copy_folder(source_file, dest_file)
                directories.delete_folder(source_file)
            elif directories.is_file(source_file):
                symlink.copy_file(source_file, dest_file)
                directories.delete_file(source_file)
            else:
                return False

    return True
Esempio n. 2
0
def install_package(package_key, config_dict, dotfile_path):
    """
        Install package to local system
    """

    # Grab dotfile package directory
    package_config = config_dict['options'][package_key]
    directory_path = dotfile_path + package_config['directoryName'] + "/"

    # Loop through files to link
    for link in package_config['links']:
        # Symlink files to local files
        for key, value in link.items():
            source_file = directory_path + key
            dest_file = HOME_PATH + value

            if directories.is_folder(dest_file):
                logging.print_warn("Folder exists, skipping: {}".format(dest_file))
                continue
            elif directories.is_file(dest_file):
                logging.print_warn("File exists, skipping: {}".format(dest_file))
                continue

            if directories.create_base_folder(dest_file):
                symlink.create_symlink(source_file, dest_file)
            else:
                return False

    return True
Esempio n. 3
0
def unlink_packages():
    """
        Unlink all files in packages_to_unlink
    """
    for path in packages_to_unlink:
        if directories.is_folder(path):
            directories.delete_folder(path)
        elif directories.is_file(path):
            directories.delete_file(path)
        else:
            logging.print_error("Nothing to unlink")
Esempio n. 4
0
def unlink_packages():
    """
        Unlink all files in packages_to_unlink
    """
    for path in packages_to_unlink:
        if directories.is_folder(path):
            directories.delete_folder(path)
        elif directories.is_file(path):
            directories.delete_file(path)
        else:
            print(errors.format_error("Sequestrum", "Nothing to unlink!"))