def load(): if not Config.get('cache_enabled'): return None if not os.path.exists(Config.get('cache')): return None with open(Config.get('cache'), 'r') as fd: return ResultSet.deserialize(fd.read())
def get_date(self): local_zone = tz.tzlocal() if self.due_date: if Config.get('time_offset'): dt = self.due_date.astimezone(local_zone) + timedelta(hours=Config.get('time_offset')) return dt.strftime(Config.get('output_date_format')) return self.due_date.astimezone(local_zone).strftime(Config.get('output_date_format')) return ''
def api_call(method, **options): options['token'] = Config.get('api_token') query_string = parse.urlencode(options) url = "{apiurl}/{method}?{query}".format(apiurl=API_URL, method=method, query=query_string) try: req = request.urlopen(url) content = req.read().decode('utf-8') return json.loads(content) except Exception as ex: print(ex)
def save(self): if not Config.get('cache_enabled'): return None with open(Config.get('cache'), 'w') as fd: fd.write(self.serialize())