<commit_before>#!/usr/bin/env python
"""Script to perform operations on the database of our application."""
import click
from remoteappmanager.db import orm


def database(db_url):
    """Retrieves the orm.Database object from the
       passed db url. It also accepts absolute or relative disk paths.
       In that case, the database will be assumed to be a sqlite one.

    Parameters
    ----------
    db_url : str
        A string containing a db sqlalchemy url, or a disk path.

    Returns
    -------
    orm.Database instance.
    """
    if ":" not in db_url:
        db_url = "sqlite:///"+db_url
    else:
        db_url = db_url

    return orm.Database(url=db_url)


@click.group()
@click.option("--db",
              type=click.STRING,
              help='The database sqlalchemy string to connect to, '
                   'or an absolute or relative disk path.',

              default="sqlite:///sqlite.db")
@click.pass_context
def cli(ctx, db):
    """Main click group placeholder."""
    ctx.obj["db"] = database(db)


@cli.command()
@click.pass_context
def init(ctx):
    """Initializes the database."""
    db = ctx.obj["db"]
    db.reset()

# -------------------------------------------------------------------------
# User commands


@cli.group()
def user():
    """Subcommand to manage users."""
    pass


@user.command()<commit_msg>Flake8<commit_after>#!/usr/bin/env python
"""Script to perform operations on the database of our application."""
import click
from remoteappmanager.db import orm


def database(db_url):
    """Retrieves the orm.Database object from the
       passed db url. It also accepts absolute or relative disk paths.
       In that case, the database will be assumed to be a sqlite one.

    Parameters
    ----------
    db_url : str
        A string containing a db sqlalchemy url, or a disk path.

    Returns
    -------
    orm.Database instance.
    """
    if ":" not in db_url:
        db_url = "sqlite:///"+db_url
    else:
        db_url = db_url

    return orm.Database(url=db_url)


@click.group()
@click.option("--db",
              type=click.STRING,
              help='The database sqlalchemy string to connect to, '
                   'or an absolute or relative disk path.',
              default="sqlite:///sqlite.db")
@click.pass_context
def cli(ctx, db):
    """Main click group placeholder."""
    ctx.obj["db"] = database(db)


@cli.command()
@click.pass_context
def init(ctx):
    """Initializes the database."""
    db = ctx.obj["db"]
    db.reset()

# -------------------------------------------------------------------------
# User commands


@cli.group()
def user():
    """Subcommand to manage users."""
    pass


@user.command()
{'fraction_non_alphanumeric': 0.1779911373707533, 'fraction_numerical': 0.00036927621861152144, 'mean_word_length': 1.9966814159292035, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '64502', 'n_tokens_mistral': 788, 'n_tokens_neox': 758, 'n_words': 253}