-
-
Save cottsay/47a33dde4520e6fc7178af5f4e628d63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 Scott K Logan | |
# Licensed under the Apache License, Version 2.0 | |
import argparse | |
import logging | |
from pathlib import Path | |
from colcon_core.location import set_default_config_path | |
from colcon_core.logging import colcon_logger | |
from colcon_core.package_discovery import add_package_discovery_arguments | |
from colcon_core.package_discovery import discover_packages | |
from colcon_core.package_identification import get_package_identification_extensions | |
# colcon global setup | |
colcon_logger.setLevel(logging.WARNING) | |
set_default_config_path( | |
path=(Path('~') / f'.colcon').expanduser()) | |
identification_extensions = get_package_identification_extensions() | |
# These discovery arguments could be added to the calling tool's command line | |
# or customized implicitly. Either way, the arguments should still be "parsed" | |
# because the code expects the default values to be populated. | |
parser = argparse.ArgumentParser() | |
add_package_discovery_arguments(parser) | |
args = parser.parse_args() | |
packages = discover_packages(args, identification_extensions) | |
for pkg in packages: | |
print(f'{pkg.name} ({pkg.type}): {pkg.path}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment