Load given file into knowledge base.

    Simply load data into an existing knowledge base:

    .. code-block:: console

        $ inveniomanage knowledge load mykb /path/to/file.kb

    The file is expected to have a mapping with values: ``foo<seperator>bar``
    (per line).

    ``<separator>`` is by default set to **---**, but can be overridden with
    ``-s someseperator`` or ``--sep someseperator``.

def load(name, filepath, separator="---"):
    """Load given file into knowledge base.

    Simply load data into an existing knowledge base:

    .. code-block:: console

        $ inveniomanage knowledge load mykb /path/to/file.kb

    The file is expected to have a mapping with values: ``foo<seperator>bar``
    (per line).

    ``<separator>`` is by default set to **---**, but can be overridden with
    ``-s someseperator`` or ``--sep someseperator``.
    """
    current_app.logger.info(
        ">>> Going to load knowledge base {0} into '{1}'...".format(
            filepath, name
        )
    )
    if not os.path.isfile(filepath):
        current_app.logger.error(
            "Path to non-existing file\n",
            file=sys.stderr
        )
        sys.exit(1)
    try:
        get_kb_by_name(name)
    except NoResultFound:
        current_app.logger.error(
            "KB does not exist\n",
            file=sys.stderr
        )
        sys.exit(1)
    num_added = load_kb_mappings_file(name, filepath, separator)
    current_app.logger.info(
        ">>> Knowledge '{0}' updated successfully with {1} entries.".format(
            name, num_added
        )
    )