From 3f5a3d004ab025ebd792fb6242b8a13b5cc1da2a Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 30 Apr 2024 08:00:39 +0000 Subject: [PATCH] projects.py: Add command modules projects.py modules shows either all modules, or modules which have one of the key-value pairs requested for filtering via the -F option. Signed-off-by: Jan Lindemann --- scripts/projects.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/scripts/projects.py b/scripts/projects.py index 23537be1..81199728 100644 --- a/scripts/projects.py +++ b/scripts/projects.py @@ -10,6 +10,7 @@ import sys import argparse import pwd import time +import pathlib from os.path import isfile from os.path import isdir from os.path import expanduser @@ -483,6 +484,38 @@ class Projects(object): def cmd_commands(self, args_): print(self.commands()) + def cmd_modules(self, args_): + proj_root = self.projs_root + self.debug("proj_root = " + proj_root) + path = pathlib.Path(self.projs_root) + + parser = argparse.ArgumentParser(description='Query existing janware packages') + + parser.add_argument('-F', '--filter', nargs='?', default=None, help='Key-value pairs, seperated by commas, to be searched for in project.conf') + args = parser.parse_args(args_) + modules = [p.parents[1].name for p in path.glob('*/make/project.conf')] + self.debug("modules = ", modules) + out = [] + filters = None if args.filter is None else [re.split("=", f) for f in re.split(",", args.filter)] + for m in modules: + if filters: + for f in filters: + path = f[0].rsplit('.') + if len(path) > 1: + sec = path[0] + key = path[1] + else: + sec = None + key = path[0] + val = self.get_value(m, sec, key) + self.debug('Checking in {} if {}="{}", is "{}"'.format(m, f[0], f[1], val)) + if val and val == f[1]: + out.append(m) + break + else: + out.append(m) + print(' '.join(out)) + def cmd_build(self, args_): def read_deps(cur, prereq_type):