def breakup_desc(exp): """ Breaks up exp description into tuple containing brief desc, full description and list of links """ from tardis.apps.hpctardis.publish.rif_cs_profile.rif_cs_PublishProvider import paragraphs import re paras = paragraphs(str(exp.description)) output = [x for x in paras] if len(output): brief = output[0] else: return [] regex = re.compile("^([^\:]+)\:(.*)\n") links = [] full = [] for link_or_full_desc in output[1:]: logger.debug("link_or_full_desc=%s" % repr(link_or_full_desc)) link = regex.match(link_or_full_desc) if link: link_groups = link.groups() logger.debug("link_groups=%s" % repr(link_groups)) logger.debug("len(link_groups)=%s" % len(link_groups)) if len(link_groups) == 2: (link_type,url) = link_groups match_end = link.end() desc = link_or_full_desc[match_end:] logger.debug("desc=%s" % repr(desc)) links.append((link_type, url, desc)) continue full.append(link_or_full_desc) joined_full = "\n\n".join(full) res = ((brief, links, (joined_full,)),) return res