Bibliographic entry in BibTeX format.

        Returns
        -------
        bibtex : str
            A string representing a bibtex entry for the item.

        Raises
        ------
        ValueError : If the item's aggregationType is not Journal.
968158
def bibtex(self):
        
        if self.aggregationType != 'Journal':
            raise ValueError('Only Journal articles supported.')
        template = u'''@article{{{key},
  author = {{{author}}},
  title = {{{title}}},
  journal = {{{journal}}},
  year = {{{year}}},
  volume = {{{volume}}},
  number = {{{number}}},
  pages = {{{pages}}},
  doi = {{{doi}}}
}}

'''
        if self.pageRange:
            pages = self.pageRange
        elif self.startingPage:
            pages = self.startingPage
        elif self.article_number:
            pages = self.article_number
        else:
            pages = 'no pages found'
        year = self.coverDate[0:4]
        first = self.title.split()[0].title()
        last = self.title.split()[-1].title()
        key = ''.join([self.authors[0].surname, year, first, last])
        authors = ' and '.join(["{} {}".format(a.given_name, a.surname)
                                for a in self.authors])
        bibtex = template.format(
            key=key, author=authors, title=self.title,
            journal=self.publicationName, year=year, volume=self.volume,
            number=self.issueIdentifier, pages=pages, doi=self.doi)
        return bibtex
431857
def references(self):
        
        refs = self.items.find('bibrecord/tail/bibliography', ns)
        if refs is not None:
            eids = [r.find("ref-info/refd-itemidlist/itemid", ns).text for r
                    in refs.findall("reference", ns)]
            return ["2-s2.0-" + eid for eid in eids]
        else:
            return None
222770
def bib_keys(self):
        """"""
        bib_keys = []
        # Get bib keys in this document
        for match in texutils.cite_pattern.finditer(self.text):
            keys = match.group(5).split(',')
            bib_keys += keys

        # Recursion
        for path, document in self._children.iteritems():
            bib_keys += document.bib_keys
        bib_keys = list(set(bib_keys))

        return bib_keys
1357775
def record(self):
        # type: () -> bytes
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('ST record not yet initialized!')

        return b'ST' + struct.pack('=BB', RRSTRecord.length(), SU_ENTRY_VERSION)
950712
def to_dict(self):
        ''''''

        author_list = []
        for author in self.authors:
            author_list.append(
                dict(
                    AuthorOrder = author['AuthorOrder'] + 1, # we should always use 1-based indexing but since this is shared code, I do not want to change the logic above without checking to make sure I don't break dependencies
                    FirstName = author['FirstName'],
                    MiddleNames = ' '.join(author['MiddleNames']), # this is the main difference with the code above - the database expects a string, we maintain a list
                    Surname = author['Surname']
                )
            )

        pub_url = None
        if self.url or self.doi:
            pub_url = self.url or ('http://dx.doi.org/%s' % self.doi)

        return dict(
            Title = self.title,
            PublicationName = self.journal,
            Volume = self.volume,
            Issue = self.issue,
            StartPage = self.startpage,
            EndPage = self.endpage,
            PublicationYear = self.year,
            PublicationDate = self.date,
            RIS = self.RIS,
            DOI = self.doi,
            PubMedID = None,
            URL = pub_url,
            ISSN = None, # eight-digit number
            authors = author_list,
            #
            RecordType = RISEntry.record_types.get(self.publication_type)
        )
665769
def publication_info2marc(self, key, values):
    
    result_773 = self.get('773', [])
    result_7731 = self.get('7731', [])

    for value in force_list(convert_new_publication_info_to_old(values)):
        page_artid = []
        if value.get('page_start') and value.get('page_end'):
            page_artid.append(u'{page_start}-{page_end}'.format(**value))
        elif value.get('page_start'):
            page_artid.append(u'{page_start}'.format(**value))
        elif value.get('artid'):
            page_artid.append(u'{artid}'.format(**value))

        result = {
            '0': get_recid_from_ref(value.get('parent_record')),
            'c': page_artid,
            'm': value.get('material'),
            'n': value.get('journal_issue'),
            'p': value.get('journal_title'),
            'q': value.get('conf_acronym'),
            'r': value.get('parent_report_number'),
            'v': value.get('journal_volume'),
            'w': value.get('cnum'),
            'x': value.get('pubinfo_freetext'),
            'y': value.get('year'),
            'z': value.get('parent_isbn'),
        }

        if value.get('hidden'):
            result_7731.append(result)
        else:
            result_773.append(result)

    self['7731'] = result_7731
    return result_773
214285
def handle_CR(self, value):
        
        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
582330
def ayjid(self):
        

        try:    # TODO: make this less terrible.
            return self._ayjid
        except:
            pass

        if hasattr(self, 'authors_init') and len(self.authors_init) > 0:
            al, ai = self.authors_init[0]
        elif hasattr(self, 'authors_full') and len(self.authors_full) > 0:
            al, af = self.authors_full[0]
            ai = u''.join([i[0] for i in af.split(' ')])
        else:
            al, ai = u'', u''
        if hasattr(self, 'date'):
            date = unicode(self.date)
        else:
            date = u''
        if hasattr(self, 'journal'):
            journal = self.journal
        else:
            journal = u''

        self._ayjid = u' '.join([al, ai.replace(' ', ''), date, journal]).strip().replace(' ', '_').upper()
        return self._ayjid
342576
def _summary(self, name=None):
        
        if len(self) > 0:
            head = self[0]
            if hasattr(head, 'format') and not isinstance(head, str):
                head = head.format()
            tail = self[-1]
            if hasattr(tail, 'format') and not isinstance(tail, str):
                tail = tail.format()
            index_summary = ', %s to %s' % (pprint_thing(head),
                                            pprint_thing(tail))
        else:
            index_summary = ''

        if name is None:
            name = type(self).__name__
        return '%s: %s entries%s' % (name, len(self), index_summary)
658028
def _get_published(self, entry):
        
        published = None
        if hasattr(entry, 'published_parsed'):
            if entry.published_parsed is not None:
                published = datetime.datetime.utcfromtimestamp(time.mktime(entry.published_parsed))
        elif hasattr(entry, 'created_parsed'):
            if entry.created_parsed is not None:
                published = datetime.datetime.utcfromtimestamp(time.mktime(entry.created_parsed))
        elif hasattr(entry, 'updated_parsed'):
            if entry.updated_parsed is not None:
                published = datetime.datetime.utcfromtimestamp(time.mktime(entry.updated_parsed))
        return published
434402
def noniso_bibitem(list, b, ordinal, bibliography)
      list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
        if bibliography
          id = docid_l10n(b.at(ns("./docidentifier")).text.gsub(/[\[\]]/, ""))
          prefix = b&.at(ns("./docidentifier/@type"))&.text
          ref_entry_code(r, ordinal, prefix, id)
        else
          r << "#{iso_bibitem_ref_code(b)}, "
        end
        reference_format(b, r)
      end
    end
565204
def get_journal_abstracts(self, refresh=True):
        """"""
        return [abstract for abstract in self.get_abstracts(refresh=refresh) if
                abstract.aggregationType == 'Journal']
988570
def get_author(self):
        
        author = self.commit.author

        out = ""
        if author.name is not None:
            out += author.name

        if author.email is not None:
            out += " (" + author.email + ")"

        return out
89765
def record_serializer(self):
        """"""
        imp = current_app.config['GITHUB_RECORD_SERIALIZER']
        if isinstance(imp, string_types):
            return import_string(imp)
        return imp
627768
def get_queryset(self):
        
        return self.model.published.annotate(
            count_entries_published=Count('entries')).annotate(
            last_update=Max('entries__last_update')).order_by(
            '-count_entries_published', '-last_update', '-pk')
147172
def get_aggregation(self):
        
        agg = A(self.agg_type, **self._params)
        if self._metric:
            agg.metric('metric', self._metric)
        return agg
1059523
def publication_history(self):
        
        pub_hist = self.xml.findall('author-profile/journal-history/')
        hist = []
        for pub in pub_hist:
            try:
                issn = pub.find("issn").text
            except AttributeError:
                issn = None
            try:
                abbr = pub.find("sourcetitle-abbrev").text
            except AttributeError:
                abbr = None
            hist.append((pub.find("sourcetitle").text, abbr, pub.get("type"), issn))
        return hist