예제 #1
0
def create(config):
    """Create database and populate it with basic data.

    The database will be populated with the predicates, persistent identifiers
    and claimants that are defined in `tests/myclaimstore/config`. An
    alternative directory can be specified thanks to the argument `--config`.
    """
    if config:
        path = Path(config)
        if not path.exists():
            raise click.BadParameter(
                'The specified config path does not exist.')
        elif not path.is_dir():
            raise click.BadParameter(
                'The specified config path is not a directory.')
        else:
            dirs = set(str(x.name) for x in path.iterdir() if x.is_dir())
            if not set(['predicates', 'pids', 'claimants']).issubset(dirs):
                raise click.BadParameter(
                    'The specified directory must contain three folders: '
                    'predicates, pids and claimants.')
    db.create_all()
    load_all_predicates(config)
    load_all_pids(config)
    load_all_claimants(config)
    click.echo('Database initialisation completed.')
예제 #2
0
파일: cli.py 프로젝트: jbenito3/claimstore
def create(config):
    """Create database and populate it with basic data.

    The database will be populated with the predicates, persistent identifiers
    and claimants that are defined in `tests/myclaimstore/config`. An
    alternative directory can be specified thanks to the argument `--config`.
    """
    if config:
        path = Path(config)
        if not path.exists():
            raise click.BadParameter("The specified config path does not exist.")
        elif not path.is_dir():
            raise click.BadParameter("The specified config path is not a directory.")
        else:
            dirs = set(str(x.name) for x in path.iterdir() if x.is_dir())
            if not set(["predicates", "pids", "claimants"]).issubset(dirs):
                raise click.BadParameter(
                    "The specified directory must contain three folders: " "predicates, pids and claimants."
                )
    db.create_all()
    load_all_predicates(config)
    load_all_pids(config)
    load_all_claimants(config)
    click.echo("Database initialisation completed.")
예제 #3
0
def database(app):
    """Ensure that the database schema is created."""
    db_.create_all()
    yield db_
    db_.session.remove()
예제 #4
0
def database(app):
    """Ensure that the database schema is created."""
    db_.create_all()
    yield db_
    db_.session.remove()