def augment_package( # noqa: D102 self, desc, *, additional_argument_names=None): # deliberately ignore the package type # since this extension can contribute meta information to any package if 'vcs_type' not in desc.metadata: data = {'vcs_type': VCS_TYPE} update_descriptor(desc, data, additional_argument_names=['*'])
def augment_package( # noqa: D102 self, desc, *, additional_argument_names): data = self._get_colcon_pkg_data(desc.path) if not data: return logger.info("Updating descriptor of package '%s' from colcon.pkg: %s", desc.path, data) update_descriptor(desc, data, additional_argument_names=additional_argument_names)
def augment_package( # noqa: D102 self, desc, *, additional_argument_names=None): # deliberately ignore the package type # since this extension can contribute meta information to any package try: repo = Repo(desc.path, search_parent_directories=True) except InvalidGitRepositoryError: repo = None if repo: data = {'vcs_type': VCS_TYPE} update_descriptor(desc, data, additional_argument_names=['*'])
def augment_package( # noqa: D102 self, desc, *, additional_argument_names): # deliberatively ignore the package type # since this extension can contribute meta information to any package if desc.name in metadata_by_name: update_descriptor( desc, metadata_by_name[desc.name], additional_argument_names=additional_argument_names) if os.path.realpath(str(desc.path)) in metadata_by_path: update_descriptor( desc, metadata_by_path[os.path.realpath(str(desc.path))], additional_argument_names=additional_argument_names)
def test_update_descriptor(): desc = PackageDescriptor('/some/path') assert len(desc.dependencies) == 0 assert len(desc.hooks) == 0 assert len(desc.metadata) == 0 data = { 'build-dependencies': {'b1', 'b2'}, 'test-dependencies': {'t1'}, } update_descriptor(desc, data) assert len(desc.dependencies) == 2 assert 'build' in desc.dependencies.keys() assert desc.dependencies['build'] == {'b1', 'b2'} assert 'test' in desc.dependencies.keys() assert desc.dependencies['test'] == {'t1'} data = { 'dependencies': {'d1'}, 'hooks': ['hook1', 'hook2'], 'key': 'value', } update_descriptor(desc, data, additional_argument_names=['*']) assert len(desc.dependencies) == 3 assert 'build' in desc.dependencies.keys() assert desc.dependencies['build'] == {'d1', 'b1', 'b2'} assert 'run' in desc.dependencies.keys() assert desc.dependencies['run'] == {'d1'} assert 'test' in desc.dependencies.keys() assert desc.dependencies['test'] == {'d1', 't1'} assert len(desc.hooks) == 2 assert desc.hooks == ['hook1', 'hook2'] assert len(desc.metadata) == 1 assert 'key' in desc.metadata assert desc.metadata['key'] == 'value' data = { 'other': 'value', 'some': 'value', } update_descriptor( desc, data, additional_argument_names=['some', 'unknown']) assert len(desc.metadata) == 2 assert 'other' not in desc.metadata assert 'some' in desc.metadata assert desc.metadata['some'] == 'value' data = { 'name': 'foo', 'type': 'cmake', } update_descriptor(desc, data) assert desc.name == 'foo' assert desc.type == 'cmake'