当前位置: 首页>>代码示例>>Python>>正文


Python Paper.from_bare方法代码示例

本文整理汇总了Python中papers.models.Paper.from_bare方法的典型用法代码示例。如果您正苦于以下问题:Python Paper.from_bare方法的具体用法?Python Paper.from_bare怎么用?Python Paper.from_bare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在papers.models.Paper的用法示例。


在下文中一共展示了Paper.from_bare方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_and_save_new_records

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
    def fetch_and_save_new_records(self, starting_cursor='*', batch_time=datetime.timedelta(days=1)):
        """
        Fetches and stores all new Crossref records updated since the
        last update time of the associated OaiSource.
        """
        source = OaiSource.objects.get(identifier='crossref')

        # We substract one day to 'until-update-date' parameter as it is inclusive
        one_day = datetime.timedelta(days=1)

        while source.last_update + batch_time < timezone.now():
            last_updated = source.last_update

            until_date = (last_updated + batch_time - one_day).date()

            to_update = self.fetch_all_records(
                filters={'from-update-date':last_updated.date().isoformat(),
                         'until-update-date':until_date.isoformat()},
                    cursor=starting_cursor)
            for record in to_update:
                try:
                    bare_paper = self.save_doi_metadata(record)
                    p = Paper.from_bare(bare_paper)
                    p.update_index()
                except ValueError as e:
                    logger.info(record.get('DOI', 'unkown DOI') + ': %s' % e)

            logger.info("Updated up to" + until_date.isoformat())
            source.last_update += batch_time
            source.save()
开发者ID:Phyks,项目名称:dissemin,代码行数:32,代码来源:crossref.py

示例2: fetch_and_save

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
    def fetch_and_save(self, researcher, incremental=False):
        """
        Fetch papers and save them to the database.

        :param incremental: When set to true, papers are clustered
            and commited one after the other. This is useful when
            papers are fetched on the fly for an user.
        """
        if self.ccf is None:
            raise ValueError('Clustering context factory not provided')

        for p in self.fetch_bare(researcher):        
            # Save the paper as non-bare
            p = Paper.from_bare(p)

            # If clustering happens incrementally, cluster the researcher
            if incremental:
                self.ccf.clusterPendingAuthorsForResearcher(researcher)
                researcher.update_stats()

            # Check whether this paper is associated with an ORCID id
            # for the target researcher
            if researcher.orcid:
                matches = filter(lambda a: a.orcid == researcher.orcid, p.authors)
                if matches:
                    self.update_empty_orcid(researcher, False)

           
            if self.max_results is not None and count >= self.max_results:
                break
开发者ID:jilljenn,项目名称:dissemin,代码行数:32,代码来源:papersource.py

示例3: test_fetch

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
 def test_fetch(self):
     profile = OrcidProfileStub('0000-0002-8612-8827', instance='orcid.org')
     papers = list(self.source.fetch_papers(self.researcher, profile=profile))
     for paper in papers:
         paper = Paper.from_bare(paper)
     self.assertTrue(len(papers) > 1)
     self.check_papers(papers)
开发者ID:Phyks,项目名称:dissemin,代码行数:9,代码来源:test_orcid.py

示例4: test_update_paper_statuses

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
 def test_update_paper_statuses(self):
     p = self.cr_api.create_paper_by_doi("10.1016/j.bmc.2005.06.035")
     p = Paper.from_bare(p)
     self.assertEqual(p.pdf_url, None)
     pdf_url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
     OaiRecord.new(source=self.arxiv,
                   identifier='oai:arXiv.org:aunrisste',
                   about=p,
                   splash_url='http://www.perdu.com/',
                   pdf_url=pdf_url)
     update_paper_statuses()
     self.assertEqual(Paper.objects.get(pk=p.pk).pdf_url, pdf_url)
开发者ID:Phyks,项目名称:dissemin,代码行数:14,代码来源:test_maintenance.py

示例5: save_paper

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
    def save_paper(self, bare_paper, researcher, incremental=False):
        # Save the paper as non-bare
        p = Paper.from_bare(bare_paper)

        # If clustering happens incrementally, cluster the researcher
        if incremental:
            self.ccf.clusterPendingAuthorsForResearcher(researcher)
            researcher.update_stats()

        # Check whether this paper is associated with an ORCID id
        # for the target researcher
        if researcher.orcid:
            matches = filter(lambda a: a.orcid == researcher.orcid, p.authors)
            if matches:
                self.update_empty_orcid(researcher, False)

        return p
开发者ID:Lysxia,项目名称:dissemin,代码行数:19,代码来源:papersource.py

示例6: process_record

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
    def process_record(self, header, metadata, format):
        """
        Saves the record given by the header and metadata (as returned by
        pyoai) into a Paper, or None if anything failed.
        """
        translator = self.translators.get(format)
        if translator is None:
            logger.warning("Unknown metadata format %s, skipping" % header.format())
            return

        paper = translator.translate(header, metadata)
        if paper is not None:
            try:
                with transaction.atomic():
                    saved = Paper.from_bare(paper)
                return saved
            except ValueError:
                logger.exception("Ignoring invalid paper with header %s" % header.identifier())
开发者ID:Phyks,项目名称:dissemin,代码行数:20,代码来源:oai.py

示例7: save_paper

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
    def save_paper(self, bare_paper, researcher):
        # Save the paper as non-bare
        p = Paper.from_bare(bare_paper)

        # Associate known ORCIDs to the corresponding researchers
        for idx, author in enumerate(p.authors_list):
            if author['orcid']:
                try:
                    researcher = Researcher.objects.get(orcid=author['orcid'])
                    p.set_researcher(idx, researcher.id)
                except Researcher.DoesNotExist:
                    p.set_researcher(idx, None)
            else:
                p.set_researcher(idx, None)

        p.save()
        p.update_index()

        return p
开发者ID:Phyks,项目名称:dissemin,代码行数:21,代码来源:papersource.py

示例8: ingest_dump

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
    def ingest_dump(self, filename, start_doi=None, update_index=True):
        """
        Imports a dump of Crossref metadata records stored as a bz2'ed
        file where each line is a JSON record.
        """
        for record in self.read_dump(filename, start_doi=start_doi):
            bare_paper = self.save_doi_metadata(record)
            p = Paper.from_bare(bare_paper)

            if not update_index:
                continue

            for i in range(3):
                try:
                    p.update_index()
                    break
                except ConnectionTimeout as e:
                    logger.warning(e)
                    sleep(10*i)
                except (MetadataSourceException, ValueError):
                    logger.info((record.get('DOI') or 'unknown DOI'))
开发者ID:Phyks,项目名称:dissemin,代码行数:23,代码来源:crossref.py

示例9: test_fetch

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import from_bare [as 别名]
 def test_fetch(self):
     papers = list(self.source.fetch_papers(self.researcher))
     for paper in papers:
         paper = Paper.from_bare(paper)
     self.assertTrue(len(papers) > 1)
     self.check_papers(papers)
开发者ID:Phyks,项目名称:dissemin,代码行数:8,代码来源:test_generic.py


注:本文中的papers.models.Paper.from_bare方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。