Commit e28f9a48 authored by thiolliere's avatar thiolliere
Browse files

use pyyaml for reading catalog

it is useful for more complete app like GUI app
parent 4a04dd45
......@@ -3,6 +3,7 @@
import os
import argparse
import sys
import yaml
from backend import vexpress_boot
from backend import catalog
from backend import raspbian
......@@ -31,7 +32,8 @@ os.makedirs("build", exist_ok=True)
os.chdir("build")
if args.catalog:
print(catalog.get_catalog())
for catalog in catalog.get_catalogs():
print(yaml.dump(catalog, default_flow_style=False, default_style=''))
exit(0)
vexpress_boot.get()
......
import os
import urllib.request
import yaml
from . import pretty_print
catalog_dir = "catalog"
catalog_url_path = "http://catalog.ideascube.org/"
catalog_files = [
......@@ -12,9 +11,10 @@ catalog_files = [
"bibliotecamovil.yml",
]
def get_catalog():
catalog = ""
def get_catalogs():
catalog = []
for catalog_file in catalog_files:
with urllib.request.urlopen(catalog_url_path + catalog_file) as f:
catalog += f.read().decode("utf-8")
catalog.append(yaml.load(f.read().decode("utf-8")))
return catalog
......@@ -7,4 +7,5 @@ paramiko==2.1.2
pyasn1==0.2.3
pycparser==2.17
pyparsing==2.2.0
PyYAML==3.12
six==1.10.0
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