2026-05-27 15:42:50 +02:00
|
|
|
from argparse import ArgumentParser, Namespace
|
2025-11-16 18:05:10 +01:00
|
|
|
|
2026-05-27 15:42:50 +02:00
|
|
|
from .Cmd import Cmd, Parent
|
|
|
|
|
from .lib.pkg_relations import VersionSyntax
|
|
|
|
|
from .lib.pkg_relations import pkg_relations as pkg_relations_list
|
2025-11-16 18:05:10 +01:00
|
|
|
|
|
|
|
|
class BaseCmdPkgRelations(Cmd):
|
|
|
|
|
|
2026-03-15 12:56:03 +01:00
|
|
|
def pkg_relations(self, rel_type: str, args: Namespace) -> str:
|
|
|
|
|
|
|
|
|
|
return args.delimiter.join(
|
2026-05-27 15:42:50 +02:00
|
|
|
pkg_relations_list(
|
|
|
|
|
self.app,
|
|
|
|
|
rel_type = rel_type,
|
2026-03-15 12:56:03 +01:00
|
|
|
flavours = args.flavours.split(','),
|
2026-04-06 13:49:34 +02:00
|
|
|
seed_pkgs = args.modules,
|
2026-05-27 15:42:50 +02:00
|
|
|
subsections = None
|
|
|
|
|
if args.subsections is None else args.subsections.split(','),
|
2026-03-15 12:56:03 +01:00
|
|
|
no_subpackages = args.no_subpackages,
|
|
|
|
|
dont_strip_revision = args.dont_strip_revision,
|
|
|
|
|
expand_semver_revision_range = args.expand_semver_revision_range,
|
2026-05-27 15:42:50 +02:00
|
|
|
syntax = VersionSyntax[args.syntax.replace('-', '_')],
|
2026-03-15 12:56:03 +01:00
|
|
|
recursive = args.recursive,
|
|
|
|
|
dont_expand_version_macros = args.dont_expand_version_macros,
|
|
|
|
|
ignore = set(args.ignore.split(',')),
|
2026-03-15 13:05:15 +01:00
|
|
|
quote = args.quote,
|
2026-03-15 14:19:32 +01:00
|
|
|
skip_excluded = args.skip_excluded,
|
2026-03-15 16:34:30 +01:00
|
|
|
hide_self = args.hide_self,
|
2026-04-06 13:57:20 +02:00
|
|
|
hide_jw_pkg = args.hide_jw_pkg,
|
2026-03-15 12:56:03 +01:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-15 12:31:21 +01:00
|
|
|
def print_pkg_relations(self, rel_type: str, args: Namespace) -> None:
|
|
|
|
|
print(self.pkg_relations(rel_type, args))
|
2025-11-16 18:05:10 +01:00
|
|
|
|
2026-05-27 15:42:50 +02:00
|
|
|
def __init__(self, parent: Parent, relation: str, help: str) -> None:
|
|
|
|
|
super().__init__(parent, 'pkg-' + relation, help = help)
|
2025-11-16 18:05:10 +01:00
|
|
|
self.relation = relation
|
|
|
|
|
|
|
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
|
|
|
|
super().add_arguments(parser)
|
2026-05-27 15:42:50 +02:00
|
|
|
parser.add_argument(
|
|
|
|
|
'-S',
|
|
|
|
|
'--subsections',
|
|
|
|
|
nargs = '?',
|
|
|
|
|
default = None,
|
|
|
|
|
help = 'Subsections to consider, comma-separated',
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-d',
|
|
|
|
|
'--delimiter',
|
|
|
|
|
nargs = '?',
|
|
|
|
|
default = ', ',
|
|
|
|
|
help = 'Output words delimiter'
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'flavours', help = 'Dependency flavours (run, build, devel, release)'
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument('modules', nargs = '*', help = 'Modules')
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-p',
|
|
|
|
|
'--no-subpackages',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = 'Cut -run and -devel from package names',
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--dont-strip-revision',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = 'Always treat VERSION macro as VERSION-REVISION',
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--expand-semver-revision-range',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = 'Always treat =VERSION macro as >= VERSION-0 and < (VERSION+1)-0',
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--syntax',
|
|
|
|
|
choices = ['semver', 'debian', 'names-only'],
|
|
|
|
|
default = 'semver',
|
|
|
|
|
help = 'Output syntax',
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--recursive',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = 'Find dependencies recursively',
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--dont-expand-version-macros',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = "Don't expand VERSION and REVISION macros",
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--ignore',
|
|
|
|
|
nargs = '?',
|
|
|
|
|
default = '',
|
|
|
|
|
help = 'Packages that should be ignored together with their dependencies',
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--skip-excluded',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = (
|
|
|
|
|
"Don't consider or output modules matching the os cascade in their "
|
|
|
|
|
"[build].exclude config"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--hide-self',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = "Don't include projects listed in <modules> in the output",
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--hide-jw-pkg',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = "Don't include packages from requires.jw in the output",
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'--quote',
|
|
|
|
|
action = 'store_true',
|
|
|
|
|
default = False,
|
|
|
|
|
help = 'Put double quotes around each listed dependency',
|
|
|
|
|
)
|
2025-11-16 18:05:10 +01:00
|
|
|
|
2026-01-27 14:31:25 +01:00
|
|
|
async def _run(self, args: Namespace) -> None:
|
2025-11-16 18:05:10 +01:00
|
|
|
return self.print_pkg_relations(self.relation, args)
|