[Replicant] [PATCH][vendor/replicant-scripts] find_lineageos_devices.py: Handle arbitrary repository paths

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Sun Dec 22 17:02:41 UTC 2019


Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 research/README                    |  4 +---
 research/find_lineageos_devices.py | 28 ++++++++++++++++++++--------
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/research/README b/research/README
index 5367826..cb18d94 100644
--- a/research/README
+++ b/research/README
@@ -1,5 +1,3 @@
 == Usage ==
 $ git clone git://github.com/LineageOS/lineage_wiki.git
-$ cd lineage_wiki
-$ ln -s ../find_lineageos_devices.py ./
-$ ./find_lineageos_devices.py
+$ ./find_lineageos_devices.py lineage_wiki
diff --git a/research/find_lineageos_devices.py b/research/find_lineageos_devices.py
index cb388ca..4a4c3d3 100755
--- a/research/find_lineageos_devices.py
+++ b/research/find_lineageos_devices.py
@@ -17,6 +17,7 @@
 
 import os
 import re
+import sys
 import yaml
 
 basedir = '_data' + os.sep + 'devices'
@@ -83,12 +84,23 @@ def print_results(results):
         for device in results[soc]:
             print ("- {0}:".format(device))
 
-for filename in os.listdir(basedir):
-    filepath = basedir + os.sep + filename
-    if re.search("\.yml$", filepath):
-        yaml_file = open(filepath, 'r')
-        document = yaml.load(yaml_file)
-        if still_supported(document) and interesting_for_replicant(document):
-            store_infos(results, document)
+def find_devices(path):
+    for filename in os.listdir(path + os.sep + basedir):
+        filepath = path + os.sep + basedir + os.sep + filename
+        if re.search("\.yml$", filepath):
+            yaml_file = open(filepath, 'r')
+            document = yaml.load(yaml_file)
+            if still_supported(document) and interesting_for_replicant(document):
+                store_infos(results, document)
+    print_results(results)
+
+def usage(argv0):
+    progname = os.path.basename(argv0)
+    print("{} [path/to/lineage_wiki]".format(progname))
+    sys.exit(1)
+
+if len(sys.argv) != 2:
+    usage(sys.argv[0])
+
+find_devices(sys.argv[1])
 
-print_results(results)
-- 
2.24.1



More information about the Replicant mailing list