make code nicer in some places
authorMoritz Warning <moritzwarning@web.de>
Sun, 2 Aug 2020 13:50:53 +0000 (15:50 +0200)
committerMoritz Warning <moritzwarning@web.de>
Sun, 2 Aug 2020 13:50:53 +0000 (15:50 +0200)
misc/collect.py
www/index.js

index 93410c03d0874281ca3d867324d5fba9a8a64a6e..70e3330815487268f56f96029b4d221a658ebaba 100755 (executable)
@@ -46,7 +46,7 @@ def merge_profiles(profiles, download_url):
   # json output data
   output = {}
 
-  def get_title_name(title):
+  def get_title(title):
     if "title" in title:
       return title["title"]
     else:
@@ -63,17 +63,17 @@ def merge_profiles(profiles, download_url):
     #if args.change_prefix:
     #    change_prefix(images, "openwrt-", args.change_prefix)
 
-    for title in profile["titles"]:
-      name = get_title_name(title)
+    for entry in profile["titles"]:
+      title = get_title(entry)
 
-      if len(name) == 0:
+      if len(title) == 0:
         sys.stderr.write(f"Empty title. Skip title in {path}\n")
         continue
 
-      output["models"][name] = {"id": id, "target": target, "images": images}
+      output["models"][title] = {"id": id, "target": target, "images": images}
 
       if code is not None:
-        output["models"][name]["code"] = code
+        output["models"][title]["code"] = code
 
   for path, content in profiles.items():
       obj = json.loads(content)
index 6f3893e45e0684846b9d8d199d2b1f55e4b6ce45..38c439504b39f94c1afc3dfafe9bf1b6716e4ab8 100644 (file)
@@ -413,8 +413,8 @@ function init() {
       if ('profiles' in obj) {
         obj['models'] = {}
         for (const [key, value] of Object.entries(obj['profiles'])) {
+          value['id'] = key
           obj['models'][get_model_titles(value.titles)] = value
-          obj['models'][get_model_titles(value.titles)]['id'] = key
         }
       }
       return obj