From: Fredrik Tolf Date: Wed, 30 Dec 2015 15:15:08 +0000 (+0100) Subject: Use profile module for consistent work-directory. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=40277671182cc3dd6ea80346630cc22d03235033;p=automanga.git Use profile module for consistent work-directory. --- 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):