def get_components(dci_context, url, topic_id): """Add the missing candidates in the components database""" rcs = [] dci_candidate_components = [] candidates = requests.get('%s/index.json' % url).json().keys() candidates.pop() # Remove the 'latest' component that is a link registered_components = component.list(dci_context, topic_id).json()['components'] for registered_component in registered_components: if registered_component['canonical_project_name'] == 'dci-candidate': rcs.append(registered_component['name'].replace( 'dci-candidate ', '') ) non_registered_candidates = list(set(candidates) - set(rcs)) for candidate in non_registered_candidates: dci_candidate_components.append({ 'type': component.SNAPSHOT, 'canonical_project_name': 'dci-candidate', 'name': 'dci-candidate %s' % candidate, 'url': '%s/%s' % (url, candidate), 'topic_id': topic_id }) return dci_candidate_components
def list(context): components = component.list(context).json() utils.format_output(components, context.format, component.RESOURCE, component.TABLE_HEADERS)