2025-11-16 11:39:27 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
from argparse import Namespace, ArgumentParser
|
|
|
|
|
|
2026-01-25 15:18:27 +01:00
|
|
|
from ...lib.log import *
|
2025-11-16 11:39:27 +01:00
|
|
|
from ..Cmd import Cmd
|
|
|
|
|
|
|
|
|
|
class CmdModules(Cmd): # export
|
|
|
|
|
|
|
|
|
|
def __init__(self) -> None:
|
|
|
|
|
super().__init__('modules', help='Query existing janware packages')
|
|
|
|
|
|
|
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
|
|
|
|
super().add_arguments(parser)
|
|
|
|
|
parser.add_argument('-F', '--filter', nargs='?', default=None, help='Key-value pairs, seperated by commas, to be searched for in project.conf')
|
|
|
|
|
|
|
|
|
|
def _run(self, args: Namespace) -> None:
|
|
|
|
|
import pathlib
|
|
|
|
|
proj_root = self.app.projs_root
|
2026-01-25 15:18:27 +01:00
|
|
|
log(DEBUG, "proj_root = " + proj_root)
|
2025-11-16 11:39:27 +01:00
|
|
|
path = pathlib.Path(self.app.projs_root)
|
|
|
|
|
modules = [p.parents[1].name for p in path.glob('*/make/project.conf')]
|
2026-01-25 15:18:27 +01:00
|
|
|
log(DEBUG, "modules = ", modules)
|
2025-11-16 11:39:27 +01:00
|
|
|
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.app.get_value(m, sec, key)
|
2026-01-25 15:18:27 +01:00
|
|
|
log(DEBUG, 'Checking in {} if {}="{}", is "{}"'.format(m, f[0], f[1], val))
|
2025-11-16 11:39:27 +01:00
|
|
|
if val and val == f[1]:
|
|
|
|
|
out.append(m)
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
out.append(m)
|
|
|
|
|
print(' '.join(out))
|