Beispiel #1
0
def test_colour_validation_invalid(config):
    config.write("color = 'on_weekends_only'\n", "a")
    with patch(
            "todoman.configuration.find_config",
            return_value=(str(config)),
    ), pytest.raises(ConfigurationException):
        load_config()
Beispiel #2
0
def test_colour_validation_auto(config):
    with patch(
            "todoman.configuration.find_config",
            return_value=(str(config)),
    ):
        cfg = load_config()

    assert cfg["main"]["color"] == "auto"
Beispiel #3
0
def test_colour_validation_auto(config):
    with patch(
            'todoman.configuration.find_config',
            return_value=(str(config)),
    ):
        cfg = load_config()

    assert cfg['main']['color'] == 'auto'
Beispiel #4
0
def test_colour_validation_always(config):
    config.write("color = 'always'\n", "a")
    with patch(
            "todoman.configuration.find_config",
            return_value=(str(config)),
    ):
        cfg = load_config()

    assert cfg["main"]["color"] == "always"
Beispiel #5
0
def test_colour_validation_always(config):
    config.write("color = 'always'\n", 'a')
    with patch(
            'todoman.configuration.find_config',
            return_value=(str(config)),
    ):
        cfg = load_config()

    assert cfg['main']['color'] == 'always'
Beispiel #6
0
    def __init__(self):
        config = load_config()
        paths = [
            path for path in glob.iglob(expanduser(config['main']['path']))
            if isdir(path)
        ]

        if not paths:
            raise Exception('No todos found!')

        self.db = Database(paths, config['main']['cache_path'])
Beispiel #7
0
def cli(click_ctx, color, porcelain, humanize):
    ctx = click_ctx.ensure_object(AppContext)
    try:
        ctx.config = load_config()
    except ConfigurationException as e:
        raise click.ClickException(e.args[0])

    if porcelain and humanize:
        raise click.ClickException('--porcelain and --humanize cannot be used'
                                   ' at the same time.')

    if humanize is None:  # False means explicitly disabled
        humanize = ctx.config['main']['humanize']

    if porcelain:
        ctx.formatter_class = formatters.PorcelainFormatter
    elif humanize:
        ctx.formatter_class = formatters.HumanizedFormatter
    else:
        ctx.formatter_class = formatters.DefaultFormatter

    color = color or ctx.config['main']['color']
    if color == 'always':
        click_ctx.color = True
    elif color == 'never':
        click_ctx.color = False

    paths = [
        path for path in glob.iglob(expanduser(ctx.config["main"]["path"]))
        if isdir(path)
    ]
    if len(paths) == 0:
        raise exceptions.NoListsFound(ctx.config["main"]["path"])

    ctx.db = Database(paths, ctx.config['main']['cache_path'])

    # Make python actually use LC_TIME, or the user's locale settings
    locale.setlocale(locale.LC_TIME, "")

    if not click_ctx.invoked_subcommand:
        invoke_command(
            click_ctx,
            ctx.config['main']['default_command'],
        )