Beispiel #1
0
def get_authors_info(project_id, tel=None):
    project_id = clean_project_id(project_id)
    info = get_missing_author(project_id)
    if not info:
        info = authors.parse('author/%s.xml' % project_id)
    # print >>sys.stderr, info
    return info
Beispiel #2
0
def build(filenames):
    """Build a dict of dicts given filenames of xml files from PST.

    Assume: coversheet/ and author/ are local directories w/file named filename
    """
    need0_re = re.compile('^([A|B][A-Z])(\d\d\d)$')
    megadict = {}
    for filename in filenames:
        try:
            coversheet_info = coversheet.parse('coversheet/' + filename)[0]
        except:
            continue
        try:
            authors_info = authors.parse('author/' + filename)
        except:
            continue

        relevant = {}
        for key in relevant_coversheet_keys:
            relevant[rename(key)] = coversheet_info[key]

        pi = None
        pi_id = coversheet_info.get('pi', '-1')
        maybe_pi = [author for author in authors_info
                    if author.get('astronomer_id', '-2') == pi_id]
        if len(maybe_pi) > 0:
            pi = maybe_pi[0]

        investigators = []
        investigator_details = []

        for author_info in authors_info:
            author_relevant = {}
            for key in relevant_author_keys:
                author_relevant[rename(key)] = author_info[key]
            investigator_details.append(author_relevant)
            investigators.append('%s, %s (%s)' %
                                 (author_relevant['last_name'],
                                  author_relevant['first_name'],
                                  author_relevant['affiliation'],
                                  ))
            if author_info == pi:
                relevant['pi_details'] = author_relevant
        relevant['investigators'] = sorted(investigators)
        relevant['investigator_details'] = sorted(investigator_details)

        alt_id = relevant['proposal_id'].replace('/', '').replace('-', '_')
        megadict[relevant['proposal_id']] = relevant
        megadict[relevant['legacy_id']] = relevant
        megadict[alt_id] = relevant

        megadict[filename.replace('.xml', '')] = relevant

        if relevant['proposal_id'].startswith('GBT'):
            print relevant['proposal_id']
        else:
            leg_id = relevant['legacy_id']
            need0_match = need0_re.match(leg_id)
            if need0_match is not None:
                leg_id = '0'.join(need0_match.groups())
                megadict[leg_id] = relevant
            print leg_id

    return megadict