This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
github-gitea-mirror/src/localCacheHelper.py
2020-10-26 08:35:29 +05:30

31 lines
787 B
Python

#!/usr/bin/env python
giteaExistsRepos = dict()
from helper import logError,log,getConfig
import json
config = getConfig()
def writeLocalCache(content):
try:
with open(config['local_cache']['file_path'], 'w') as file:
file.write(json.dumps(content, indent=4, sort_keys=True))
except:
logError('Unable To Save Local Cache !')
def readLocalCache():
try:
with open(config['local_cache']['file_path'],'r') as file:
filedata = file.read()
return json.loads(filedata)
except:
logError('Local Cache File Not Found ! / Unable To Ready It')
return dict()
giteaExistsRepos = readLocalCache()
useLocalCache = config['local_cache']['enabled']
def saveLocalCache():
writeLocalCache(giteaExistsRepos)