def handle_CR(self, value):
        """
        Parses cited references.
        """
        citation = self.entry_class()

        value = strip_tags(value)

        # First-author name and publication date.
        ptn = '([\w\s\W]+),\s([0-9]{4}),\s([\w\s]+)'
        ny_match = re.match(ptn, value, flags=re.U)
        nj_match = re.match('([\w\s\W]+),\s([\w\s]+)',
                            value, flags=re.U)
        if ny_match is not None:
            name_raw, date, journal = ny_match.groups()
        elif nj_match is not None:
            name_raw, journal = nj_match.groups()
            date = None
        else:
            return

        datematch = re.match('([0-9]{4})', value)
        if datematch:
            date = datematch.group(1)
            name_raw = None

        if name_raw:
            name_tokens = [t.replace('.', '') for t in name_raw.split(' ')]
            if len(name_tokens) > 4 or value.startswith('*'):    # Probably not a person.
                proc = lambda x: _strip_punctuation(x)
                aulast = ' '.join([proc(n) for n in name_tokens]).upper()
                auinit = ''
            elif len(name_tokens) > 0:
                aulast = name_tokens[0].upper()
                proc = lambda x: _space_sep(_strip_punctuation(x))
                auinit = ' '.join([proc(n) for n in name_tokens[1:]]).upper()
            else:
                aulast = name_tokens[0].upper()
                auinit = ''

            setattr(citation, 'authors_init', [(aulast, auinit)])

        if date:
            date = int(date)
        setattr(citation, 'date', date)
        setattr(citation, 'journal', journal)

        # Volume.
        v_match = re.search('\,\s+V([0-9A-Za-z]+)', value)
        if v_match is not None:
            volume = v_match.group(1)
        else:
            volume = None
        setattr(citation, 'volume', volume)

        # Start page.
        p_match = re.search('\,\s+[Pp]([0-9A-Za-z]+)', value)
        if p_match is not None:
            page = p_match.group(1)
        else:
            page = None
        setattr(citation, 'pageStart', page)

        # DOI.
        doi_match = re.search('DOI\s(.*)', value)
        if doi_match is not None:
            doi = doi_match.group(1)
        else:
            doi = None
        setattr(citation, 'doi', doi)
        return citation
def handle_CR ( self , value ) : citation = self . entry_class ( ) value = strip_tags ( value ) ptn = '([\w\s\W]+),\s([0-9]{4}),\s([\w\s]+)' ny_match = re . match ( ptn , value , flags = re . U ) nj_match = re . match ( '([\w\s\W]+),\s([\w\s]+)' , value , flags = re . U ) if ny_match is not None : name_raw , date , journal = ny_match . groups ( ) elif nj_match is not None : name_raw , journal = nj_match . groups ( ) date = None else : return datematch = re . match ( '([0-9]{4})' , value ) if datematch : date = datematch . group ( 1 ) name_raw = None if name_raw : name_tokens = [ t . replace ( '.' , '' ) for t in name_raw . split ( ' ' ) ] if len ( name_tokens ) > 4 or value . startswith ( '*' ) : proc = lambda x : _strip_punctuation ( x ) aulast = ' ' . join ( [ proc ( n ) for n in name_tokens ] ) . upper ( ) auinit = '' elif len ( name_tokens ) > 0 : aulast = name_tokens [ 0 ] . upper ( ) proc = lambda x : _space_sep ( _strip_punctuation ( x ) ) auinit = ' ' . join ( [ proc ( n ) for n in name_tokens [ 1 : ] ] ) . upper ( ) else : aulast = name_tokens [ 0 ] . upper ( ) auinit = '' setattr ( citation , 'authors_init' , [ ( aulast , auinit ) ] ) if date : date = int ( date ) setattr ( citation , 'date' , date ) setattr ( citation , 'journal' , journal ) v_match = re . search ( '\,\s+V([0-9A-Za-z]+)' , value ) if v_match is not None : volume = v_match . group ( 1 ) else : volume = None setattr ( citation , 'volume' , volume ) p_match = re . search ( '\,\s+[Pp]([0-9A-Za-z]+)' , value ) if p_match is not None : page = p_match . group ( 1 ) else : page = None setattr ( citation , 'pageStart' , page ) doi_match = re . search ( 'DOI\s(.*)' , value ) if doi_match is not None : doi = doi_match . group ( 1 ) else : doi = None setattr ( citation , 'doi' , doi ) return citation
Parses cited references.