Commit 78b65eaf authored by rgaudin's avatar rgaudin
Browse files

improved catalog definition

	replaced flat list of catalog URLs with a list of dict (name, url, description)
	catalogs are now defined only in this file and sent to ansiblecube (no duplicates)
	dict is populated upon import so network is used only once (kiwix catalog is huge)
	no change for the user ; popup window is still raised upon load error
parent f6c096b0
import urllib.request
import requests
import yaml
catalog_urls = [
"http://download.kiwix.org/library/ideascube.yml",
"http://catalog.ideascube.org/static-sites.yml",
"http://catalog.ideascube.org/bibliotecamovil.yml",
CATALOGS = [
{'name': "Kiwix",
'description': "Kiwix ZIM Content",
'url': "http://download.kiwix.org/library/ideascube.yml"},
{'name': "StaticSites",
'description': "Static sites",
'url': "http://catalog.ideascube.org/static-sites.yml"}
]
def get_catalogs():
catalog = []
for catalog_url in catalog_urls:
with urllib.request.urlopen(catalog_url) as f:
catalog.append(yaml.load(f.read().decode("utf-8")))
return catalog
YAML_CATALOGS = []
try:
for catalog in CATALOGS:
YAML_CATALOGS.append(yaml.load(
requests.get(catalog.get('url')).content.decode("utf-8")))
except Exception:
pass
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment