def update_repo(self, name, url=None):
reposfile = "%s/.kcli/repos.yml" % os.environ.get('HOME')
repodir = "%s/.kcli/repo_%s" % (os.environ.get('HOME'), name)
if url is None:
if not os.path.exists(reposfile) or os.path.getsize(reposfile) == 0:
common.pprint("Empty .kcli/repos.yml. Leaving...", color='red')
sys.exit(1)
else:
with open(reposfile, 'r') as entries:
try:
repos = yaml.load(entries)
except yaml.scanner.ScannerError:
common.pprint("Couldn't properly parse .kcli/repos.yml. Leaving...", color='red')
sys.exit(1)
if name not in repos:
common.pprint("Entry for name allready there. Leaving...", color='red')
sys.exit(1)
url = "%s/KMETA" % repos[name]
elif 'KMETA' not in url:
url = "%s/KMETA" % url
common.fetch(url, repodir)
return {'result': 'success'}
评论列表
文章目录