示例#1
0
def config_no_var(context, key, value="", journal=None):
    configuration = load_config(context.config_path)

    if journal:
        configuration = configuration["journals"][journal]

    assert key not in configuration
示例#2
0
文件: core.py 项目: signal-9/jrnl
def config_no_var(context, key, value="", journal=None):
    config = load_config(install.CONFIG_FILE_PATH)

    if journal:
        config = config["journals"][journal]

    assert key not in config
示例#3
0
def config_var(context, key, value="", journal=None):
    value = read_value_from_string(value or context.text or "")
    configuration = load_config(context.config_path)

    if journal:
        configuration = configuration["journals"][journal]

    assert key in configuration
    assert configuration[key] == value
示例#4
0
文件: core.py 项目: signal-9/jrnl
def config_var(context, key, value="", journal=None):
    value = read_value_from_string(value or context.text or "")
    config = load_config(install.CONFIG_FILE_PATH)

    if journal:
        config = config["journals"][journal]

    assert key in config
    assert config[key] == value
示例#5
0
def open_journal(context, journal_name="default"):
    configuration = load_config(context.config_path)
    journal_conf = configuration["journals"][journal_name]

    # We can override the default config on a by-journal basis
    if type(journal_conf) is dict:
        configuration.update(journal_conf)
    # But also just give them a string to point to the journal file
    else:
        configuration["journal"] = journal_conf

    return Journal.open_journal(journal_name, configuration)
示例#6
0
文件: core.py 项目: signal-9/jrnl
def open_journal(journal_name="default"):
    config = load_config(install.CONFIG_FILE_PATH)
    journal_conf = config["journals"][journal_name]

    # We can override the default config on a by-journal basis
    if type(journal_conf) is dict:
        config.update(journal_conf)
    # But also just give them a string to point to the journal file
    else:
        config["journal"] = journal_conf

    return Journal.open_journal(journal_name, config)
示例#7
0
文件: core.py 项目: koryashkin/jrnl
def config_var(context, key, value, journal=None):
    if not value[0] == "{":
        t, value = value.split(":")
        value = {
            "bool": lambda v: v.lower() == "true",
            "int": int,
            "str": str
        }[t](value)
    else:
        # Handle value being a dictionary
        value = ast.literal_eval(value)

    config = load_config(install.CONFIG_FILE_PATH)
    if journal:
        config = config["journals"][journal]
    assert key in config
    assert config[key] == value
def config_var(context, key, value="", journal=None):
    key_as_vec = key.split(".")

    if "args" in context:
        parsed = parse_args(context.args)
        overrides = parsed.config_override
    value = read_value_from_string(value or context.text or "")
    configuration = load_config(context.config_path)

    if journal:
        configuration = configuration["journals"][journal]

    if overrides:
        with patch.object(jrnl.override,
                          "_recursively_apply",
                          wraps=_recursively_apply) as spy_recurse:
            configuration = apply_overrides(overrides, configuration)
            runtime_cfg = spy_recurse.call_args_list[0][0][0]
    else:
        runtime_cfg = configuration
        # extract the value of the desired key from the configuration after overrides have been applied
    for k in key_as_vec:
        runtime_cfg = runtime_cfg["%s" % k]
    assert runtime_cfg == value
示例#9
0
def read_journal(context, journal_name="default"):
    configuration = load_config(context.config_path)
    with open(configuration["journals"][journal_name]) as journal_file:
        journal = journal_file.read()
    return journal
示例#10
0
def journal_exists(context, journal_name="default"):
    configuration = load_config(context.config_path)

    journal_path = configuration["journals"][journal_name]
    assert os.path.exists(journal_path)
示例#11
0
文件: core.py 项目: signal-9/jrnl
def read_journal(journal_name="default"):
    config = load_config(install.CONFIG_FILE_PATH)
    with open(config["journals"][journal_name]) as journal_file:
        journal = journal_file.read()
    return journal
示例#12
0
文件: core.py 项目: signal-9/jrnl
def journal_exists(context, journal_name="default"):
    config = load_config(install.CONFIG_FILE_PATH)

    journal_path = config["journals"][journal_name]
    assert os.path.exists(journal_path)