예제 #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()
예제 #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"
예제 #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'
예제 #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"
예제 #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'
예제 #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'])
예제 #7
0
파일: cli.py 프로젝트: hut/todoman
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'],
        )