def rebuild_affiliation(aff, emails): """ Combines the affiliation and the emails. """ aff = unescape_csv(aff) emails = unescape_csv(emails) emails = create_email_string(emails) if aff and emails: return '%s %s' % (aff, emails) elif aff: return aff elif emails: return emails else: return ''
def rebuild_affiliation(aff, emails): """ Combines the affiliation and the emails. """ aff = unescape_csv(aff) emails = unescape_csv(emails) emails = create_email_string(emails) if aff and emails: return "%s %s" % (aff, emails) elif aff: return aff elif emails: return emails else: return ""
def create_email_string(email_field): if not email_field: return "" elif email_field == "[]": return "" else: emails = unescape_csv(email_field) try: emails = eval(emails) except SyntaxError: raise Exception("ERROR: Email field is not well formatted: '%s'." % emails) return "<EMAIL>%s</EMAIL>" % "</EMAIL> <EMAIL>".join(emails)
def create_email_string(email_field): if not email_field: return '' elif email_field == '[]': return '' else: emails = unescape_csv(email_field) try: emails = eval(emails) except SyntaxError: raise Exception("ERROR: Email field is not well formatted: '%s'." % emails) return '<EMAIL>%s</EMAIL>' % '</EMAIL> <EMAIL>'.join(emails)