def __init__(self, query, user_email):
        """
        Upon init: set email as required by API, determine whether query
        is PubMed ID or PubMed URL and retrieve PubMed record accordingly.
        """
        Entrez.email = user_email

        pmid_pattern = r'^\d+$'
        pmurl_pattern = r'^https?://www\.ncbi\.nlm\.nih\.gov/pubmed/\d+$'
        if re.match(pmid_pattern, str(query)):
            pmid = query
        elif re.match(pmurl_pattern, query):
            pmid = self.parse_pubmed_url(query)
        else:
            raise RuntimeError(
                "Query ({}) doesn't appear to be a PubMed ID or PubMed URL"
                .format(query))

        self.record = self.get_pubmed_record(pmid)[0]
def __init__ ( self , query , user_email ) : Entrez . email = user_email pmid_pattern = r'^\d+$' pmurl_pattern = r'^https?://www\.ncbi\.nlm\.nih\.gov/pubmed/\d+$' if re . match ( pmid_pattern , str ( query ) ) : pmid = query elif re . match ( pmurl_pattern , query ) : pmid = self . parse_pubmed_url ( query ) else : raise RuntimeError ( "Query ({}) doesn't appear to be a PubMed ID or PubMed URL" . format ( query ) ) self . record = self . get_pubmed_record ( pmid ) [ 0 ]
Upon init: set email as required by API, determine whether query
        is PubMed ID or PubMed URL and retrieve PubMed record accordingly.