From d3e542ab7e7f95d82fe07620eda8b30b786a326d Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 10 Sep 2015 18:19:41 +0200 Subject: [PATCH] lister.py: add conffile setting to en/disable JSON caching --- bin/ghlister | 11 +++++++++-- ghlister/lister.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/ghlister b/bin/ghlister index cf28499..6a3eb71 100755 --- a/bin/ghlister +++ b/bin/ghlister @@ -18,8 +18,9 @@ from ghlister.db_utils import session_scope DEFAULT_CONF = { - 'cache_dir': './cache', - 'log_dir': './log', + 'cache_dir': './cache', + 'log_dir': './log', + 'cache_json': 'False', } @@ -93,6 +94,12 @@ def read_conf(args): if args.db_url: conf['db_url'] = args.db_url + # typing + if 'cache_json' in conf and conf['cache_json'].lower() == 'true': + conf['cache_json'] = True + else: + conf['cache_json'] = False + return conf diff --git a/ghlister/lister.py b/ghlister/lister.py index 9d19189..dea59a3 100644 --- a/ghlister/lister.py +++ b/ghlister/lister.py @@ -137,7 +137,7 @@ def fetch(conf, mk_session, min_id=None, max_id=None): since = next_id - 1 # github API ?since=... is '>' strict, not '>=' repos_res = gh_api_request('/repositories?since=%d' % since, **cred) - if 'cache_dir' in conf: + if 'cache_dir' in conf and conf['cache_json']: save_http_response(repos_res, conf['cache_dir']) if not repos_res.ok: raise FetchError(repos_res)