misc/collect.py: cleanup www_path variable
authorMoritz Warning <moritzwarning@web.de>
Mon, 28 Sep 2020 09:23:41 +0000 (11:23 +0200)
committerPetr Štetiar <ynezz@true.cz>
Wed, 7 Oct 2020 19:35:53 +0000 (21:35 +0200)
misc/collect.py

index ad2741370c5f546b311230e642ad704e41c3f64e..0b2968d3f05dd1f16dc6b47243eb208cbba1329f 100755 (executable)
@@ -118,7 +118,8 @@ def merge_profiles(profiles, download_url):
     return output
 
 
-def update_config(config_path, versions):
+def update_config(www_path, versions):
+    config_path = "{}/config.js".format(www_path)
     content = ""
     with open(str(config_path), "r", encoding="utf-8") as file:
         content = file.read()
@@ -137,9 +138,7 @@ Update config.json.
 
 def scrape(args):
     url = args.domain
-    www_path = args.www_path
-    config_path = "{}/config.js".format(www_path)
-    data_path = "{}/data".format(www_path)
+    data_path = "{}/data".format(args.www_path)
     versions = {}
 
     def handle_release(target):
@@ -186,7 +185,7 @@ def scrape(args):
 
                     versions[release] = "data/{}/overview.json".format(release)
 
-    update_config(config_path, versions)
+    update_config(args.www_path, versions)
 
 
 """
@@ -198,9 +197,7 @@ Update config.json.
 
 def scrape_wget(args):
     url = args.domain
-    www_path = args.www_path
-    config_path = "{}/config.js".format(www_path)
-    data_path = "{}/data".format(www_path)
+    data_path = "{}/data".format(args.www_path)
     versions = {}
 
     with tempfile.TemporaryDirectory() as tmp_dir:
@@ -253,7 +250,7 @@ def scrape_wget(args):
                 else:
                     json.dump(output, outfile, sort_keys=True)
 
-        update_config(config_path, versions)
+        update_config(args.www_path, versions)
 
 
 """
@@ -305,8 +302,6 @@ Update config.json.
 
 
 def scan(args):
-    # firmware selector config
-    config_path = "{}/config.js".format(args.www_path)
     # the overview.json files are placed here
     data_path = "{}/data".format(args.www_path)
     versions = {}
@@ -365,7 +360,7 @@ def scan(args):
             else:
                 json.dump(output, outfile, sort_keys=True)
 
-    update_config(config_path, versions)
+    update_config(args.www_path, versions)
 
 
 def main():