def _get_links(document): """ Return a list of (operation_id, link, [tags]) """ # Extract all the links from the first or second level of the document. links = [] for keys, link, tags in get_links_from_document(document): tags = list(set(tags)) if len(keys) > 1: operation_id = '_'.join(keys[1:]) tags.append(keys[0]) else: operation_id = keys[0] links.append((operation_id, link, tags)) # Determine if the operation ids each have unique names or not. operation_ids = [item[0] for item in links] unique = len(set(operation_ids)) == len(links) # If the operation ids are not unique, then prefix them with the tag. if not unique: return [_add_tag_prefix(item) for item in links] return links
def _get_links(document): """ Return a list of (operation_id, link, [tags]) """ # Extract all the links from the first or second level of the document. links = [] for keys, link in get_links_from_document(document): if len(keys) > 1: operation_id = '_'.join(keys[1:]) tags = [keys[0]] else: operation_id = keys[0] tags = [] links.append((operation_id, link, tags)) # Determine if the operation ids each have unique names or not. operation_ids = [item[0] for item in links] unique = len(set(operation_ids)) == len(links) # If the operation ids are not unique, then prefix them with the tag. if not unique: return [_add_tag_prefix(item) for item in links] return links