From 40277671182cc3dd6ea80346630cc22d03235033 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Wed, 30 Dec 2015 16:15:08 +0100 Subject: [PATCH] Use profile module for consistent work-directory. --- manga/htcache.py | 6 ++---- manga/profile.py | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/manga/htcache.py b/manga/htcache.py index 5f28c00..2aa594e 100644 --- a/manga/htcache.py +++ b/manga/htcache.py @@ -1,4 +1,5 @@ import os, hashlib, urllib.request, time +from . import profile pj = os.path.join class cache(object): @@ -31,10 +32,7 @@ class cache(object): f.write(data) return data -home = os.getenv("HOME") -if home is None or not os.path.isdir(home): - raise Exception("Could not find home directory for HTTP caching") -default = cache(pj(home, ".manga", "htcache")) +default = cache(pj(profile.confdir, "htcache")) def fetch(url, expire=3600): return default.fetch(url, expire) diff --git a/manga/profile.py b/manga/profile.py index 081cd6c..ecfb354 100644 --- a/manga/profile.py +++ b/manga/profile.py @@ -4,7 +4,8 @@ pj = os.path.join home = os.getenv("HOME") if home is None or not os.path.isdir(home): raise Exception("Could not find home directory for profile keeping") -basedir = pj(home, ".manga", "profiles") +confdir = pj(home, ".manga") +basedir = pj(confdir, "profiles") class txfile(object): def __init__(self, name, mode): -- 2.11.0