def search_pubs(query, num_pubs=50): f = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'queryresults', query + '.txt') logfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'queryresults', query + '_log' + '.txt') query_pubmed(query, f, logfile) contents = PubMedParser.read_contents(f, num_pubs) pub_counts = read_counts(logfile) pub_counts['showing_count'] = num_pubs return {'contents': contents, 'log': pub_counts}