~reedwade/wee-matter

bae75823f05a289f097a049c2746de419072f307 — Stacy Harper 1 year, 1 month ago 85a8471
Do not enforce the download_location config value.

This allow the user to unset the value and prevent miss-matching configs
shared accross multiple systems with multiple users by example.
1 files changed, 8 insertions(+), 10 deletions(-)

M wee_matter/config.py
M wee_matter/config.py => wee_matter/config.py +8 -10
@@ 24,7 24,14 @@ def server_completion_cb(data, completion_item, current_buffer, completion):
    return weechat.WEECHAT_RC_OK

def download_location():
    return weechat.config_get_plugin("download_location")
    if weechat.config_is_set_plugin("download_location"):
        value = weechat.config_get_plugin("download_location")
        return weechat.string_eval_expression(value, {}, {}, {})

    if "" == weechat.string_eval_expression("${env:XDG_CACHE_HOME}", {}, {}, {}):
        return weechat.string_eval_expression("~/.cache/wee-matter/downloads", {}, {}, {})
    else :
        return weechat.string_eval_expression("${env:XDG_CACHE_HOME}/wee-matter/downloads", {}, {}, {})

def get_server_option(server_name, key):
    full_key = server_name + "." + key


@@ 37,14 44,6 @@ def get_server_config(server_name, key):

    return expanded_value

def setup_download_location():
    if not weechat.config_is_set_plugin("download_location"):
        cache_root = weechat.string_eval_expression("${env:XDG_CACHE_HOME}/wee-matter", {}, {}, {})
        if not cache_root:
            cache_root = weechat.string_eval_path_home("~/.cache/wee-matter", {}, {}, {})

        weechat.config_set_plugin("download_location", cache_root + "/downloads")

def last_post_id_option(channel_id):
    return weechat.config_search_option(wee_matter_cache_file, wee_matter_last_post_section, channel_id)



@@ 164,7 163,6 @@ def setup():
        "server_section_delete_option_cb", "")

    weechat.config_read(wee_matter_config_file)
    setup_download_location()

    global wee_matter_cache_file
    global wee_matter_last_post_section