Пример #1
0
def with_config(cfg: Union[str, Config]):
    import promnesia.config as C
    assert not C.has()
    cfg2: Config = make(cfg) if isinstance(cfg, str) else cfg
    try:
        C.instance = cfg2
        assert C.has()
        yield
    finally:
        C.reset()
Пример #2
0
def index(cfg: Config, check=True):
    import promnesia.config as config
    from promnesia.__main__ import _do_index
    config.instance = cfg
    try:
        errors = list(_do_index())
        if check:
            assert len(errors) == 0, errors
        # visits = cfg.output_dir / 'promnesia.sqlite'
        # TODO query visit count too
        return errors
    finally:
        config.reset()
Пример #3
0
def adhoc_config(tmp_path: Path):
    cdir = tmp_path / 'cache'
    cdir.mkdir()

    from promnesia import config

    try:
        config.instance = config.Config(
            OUTPUT_DIR=tmp_path,
            CACHE_DIR=cdir,
        )
        yield
    finally:
        config.reset()