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


Python models.Deposition类代码示例

本文整理汇总了Python中invenio_deposit.models.Deposition的典型用法代码示例。如果您正苦于以下问题:Python Deposition类的具体用法?Python Deposition怎么用?Python Deposition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _classify_paper_with_deposit

    def _classify_paper_with_deposit(obj, eng):
        from invenio_deposit.models import Deposition
        deposition = Deposition(obj)
        data = None
        if not fast_mode:
            for f in deposition.files:
                if f.name and ".pdf" in f.name.lower():
                    data = f.get_syspath()
                    break
            callback = get_keywords_from_local_file
        if not data:
            try:
                metadata = deposition.get_latest_sip().metadata
            except AttributeError as err:
                obj.log.error("Error getting data: {0}".format(err))

            data = [metadata.get("titles", {}).get("title", ""),
                    metadata.get("abstracts", {}).get("value", "")]
            callback = get_keywords_from_text

        classify_paper(obj, eng, callback, data,
                       taxonomy, rebuild_cache,
                       no_cache, output_limit,
                       spires, match_mode, with_author_keywords,
                       extract_acronyms, only_core_tags, fast_mode)
开发者ID:jma,项目名称:inspire-next,代码行数:25,代码来源:classifier.py

示例2: arxiv_fft_get

def arxiv_fft_get(obj, eng):
    """Get FFT from arXiv, if arXiv ID is provided."""
    deposition = Deposition(obj)
    sip = deposition.get_latest_sip(sealed=False)
    metadata = sip.metadata

    if 'arxiv_id' in metadata and metadata['arxiv_id']:
        arxiv_pdf_url = cfg.get("ARXIV_PDF_URL", "http://arxiv.org/pdf/") + \
            "{0}.{1}"

        from invenio.config import CFG_TMPSHAREDDIR
        arxiv_file, arxiv_file_path = mkstemp(
            prefix="%s_" % (metadata['arxiv_id'].replace("/", "_")),
            suffix='.pdf',
            dir=CFG_TMPSHAREDDIR,
        )
        os.close(arxiv_file)

        download_url(url=arxiv_pdf_url.format(metadata['arxiv_id'], "pdf"),
                     content_type="pdf",
                     download_to_file=arxiv_file_path)

        # To get 1111.2222.pdf as filename.
        filename = "{0}.pdf".format(metadata['arxiv_id'].replace("/", "_"))

        try:
            try:
                save_deposition_file(deposition,
                                     filename,
                                     arxiv_file_path)
            except FilenameAlreadyExists:
                obj.log.error("PDF file not saved: filename already exists.")
        except Exception as e:
            obj.log.error("PDF file not saved: {}.".format(e.message))
开发者ID:jma,项目名称:inspire-next,代码行数:34,代码来源:tasks.py

示例3: add_note_entry

def add_note_entry(obj, eng):
    """Add note entry to sip metadata on approval."""
    entry = {'value': '*Temporary entry*'} if obj.extra_data.get("core") \
        else {'value': '*Brief entry*'}
    deposition = Deposition(obj)
    metadata = deposition.get_latest_sip(sealed=True).metadata
    if metadata.get('public_notes') is None or not isinstance(metadata.get("public_notes"), list):
        metadata['public_notes'] = [entry]
    else:
        metadata['public_notes'].append(entry)
    deposition.update()
开发者ID:jma,项目名称:inspire-next,代码行数:11,代码来源:submission.py

示例4: get_description

    def get_description(bwo):
        """Return description of object."""
        from invenio_access.control import acc_get_user_email

        results = bwo.get_tasks_results()
        try:
            deposit_object = Deposition(bwo)
        except InvalidDepositionType:
            return "This submission is disabled: {0}.".format(bwo.workflow.name)

        id_user = deposit_object.workflow_object.id_user
        user_email = acc_get_user_email(id_user)

        sip = deposit_object.get_latest_sip()
        if sip:
            record = Record(sip.metadata)
            identifiers = []
            report_numbers = record.get("report_numbers", [])
            dois = record.get("dois.value", [])
            if report_numbers:
                for report_number in report_numbers:
                    number = report_number.get("value", "")
                    if number:
                        identifiers.append(number)
            if dois:
                identifiers.extend(["doi:{0}".format(d) for d in dois])

            categories = []
            subjects = record.get("subject_terms", [])
            if subjects:
                for subject in subjects:
                    if isinstance(subject, string_types):
                        categories.append(subject)
                    elif isinstance(subject, dict):
                        if subject.get("term"):
                            categories.append(subject.get("term"))
            categories = [record.get("type_of_doc", "")] + categories

            authors = []
            authors += [record.get("_first_author", {})]
            authors += record.get("_additional_authors", [])
            return render_template(
                "workflows/styles/submission_record.html",
                categories=categories,
                authors=authors,
                identifiers=identifiers,
                results=results,
                user_email=user_email,
                object=bwo,
                record=record,
            )
        else:
            return "Submitter: {0}".format(user_email)
开发者ID:jalavik,项目名称:inspire-next,代码行数:53,代码来源:literature.py

示例5: get_title

 def get_title(bwo):
     """Return title of object."""
     try:
         deposit_object = Deposition(bwo)
     except InvalidDepositionType:
         return "This submission is disabled: {0}.".format(bwo.workflow.name)
     sip = deposit_object.get_latest_sip()
     if sip:
         # Get the SmartJSON object
         record = Record(sip.metadata)
         return record.get("titles.title", ["No title"])[0]
     else:
         return "User submission in progress"
开发者ID:jmartinm,项目名称:inspire-next,代码行数:13,代码来源:literature.py

示例6: user_pdf_get

def user_pdf_get(obj, eng):
    """Upload user PDF file, if requested."""
    if obj.extra_data.get('pdf_upload', False):
        fft = {'url': obj.extra_data.get('submission_data').get('pdf'),
               'docfile_type': 'INSPIRE-PUBLIC'}
        deposition = Deposition(obj)
        metadata = deposition.get_latest_sip(sealed=True).metadata
        if metadata.get('fft'):
            metadata['fft'].append(fft)
        else:
            metadata['fft'] = [fft]
        deposition.update()
        obj.log.info("PDF file added to FFT.")
开发者ID:jma,项目名称:inspire-next,代码行数:13,代码来源:submission.py

示例7: formatter

    def formatter(bwo, **kwargs):
        """Return formatted data of object."""
        try:
            deposit_object = Deposition(bwo)
        except InvalidDepositionType:
            return "This submission is disabled: {0}.".format(bwo.workflow.name)

        submission_data = deposit_object.get_latest_sip(deposit_object.submitted)
        record = submission_data.metadata

        return render_template(
            'format/record/Holding_Pen_HTML_detailed.tpl',
            record=Record(record)
        )
开发者ID:jma,项目名称:inspire-next,代码行数:14,代码来源:literature.py

示例8: add_submission_extra_data

def add_submission_extra_data(obj, eng):
    """ Add extra data to workflow object. """
    deposition = Deposition(obj)
    sip = deposition.get_latest_sip(sealed=True)
    metadata = sip.metadata
    submission_data = {}
    if "references" in metadata:
        submission_data["references"] = metadata["references"]
        del metadata["references"]
    if "extra_comments" in metadata:
        submission_data["extra_comments"] = metadata["extra_comments"]
        del metadata["extra_comments"]
    if "pdf" in metadata:
        submission_data["pdf"] = metadata["pdf"]
        del metadata["pdf"]
    obj.extra_data["submission_data"] = submission_data
    deposition.save()
开发者ID:jma,项目名称:inspire-next,代码行数:17,代码来源:tasks.py

示例9: _create_ticket

    def _create_ticket(obj, eng):
        from invenio_access.control import acc_get_user_email

        deposition = Deposition(obj)
        requestors = acc_get_user_email(obj.id_user)

        subject, body = get_ticket_body(template,
                                        deposition,
                                        deposition.get_latest_sip(sealed=True).metadata,
                                        requestors,
                                        obj)
        submit_rt_ticket(obj,
                         queue,
                         subject,
                         body,
                         requestors,
                         ticket_id_key)
开发者ID:jma,项目名称:inspire-next,代码行数:17,代码来源:submission.py

示例10: _create_curation_ticket

    def _create_curation_ticket(obj, eng):
        from invenio_access.control import acc_get_user_email

        deposition = Deposition(obj)
        requestors = acc_get_user_email(obj.id_user)
        metadata = deposition.get_latest_sip(sealed=True).metadata

        if obj.extra_data.get("core"):
            subject, body = get_curation_body(template,
                                              metadata,
                                              requestors,
                                              obj.extra_data)
            submit_rt_ticket(obj,
                             queue,
                             subject,
                             body,
                             requestors,
                             ticket_id_key)
开发者ID:jma,项目名称:inspire-next,代码行数:18,代码来源:submission.py

示例11: migrate_workflow_object

def migrate_workflow_object(obj_id):
    try:
        obj = BibWorkflowObject.query.get(obj_id)
        rename_object_action(obj)
        if obj.workflow.name == "process_record_arxiv":
            metadata = obj.get_data()
            if isinstance(metadata, string_types):
                # Ignore records that have string as data
                return
            if 'drafts' in metadata:
                # New data model detected, just save and exit
                obj.save()
                return
            if hasattr(metadata, 'dumps'):
                metadata = metadata.dumps(clean=True)
            obj.data = bibfield.do(metadata)
            payload = Payload.create(
                type=obj.workflow.name,
                workflow_object=obj
            )
            payload.save()
        elif obj.workflow.name == "literature":
            d = Deposition(obj)
            sip = d.get_latest_sip()
            if sip:
                sip.metadata = bibfield.do(sip.metadata)
                sip.package = legacy_export_as_marc(hep2marc.do(sip.metadata))
                d.save()
        elif obj.workflow.name in ("authornew", "authorupdate"):
            data = obj.get_data()
            obj.set_data(author_bibfield.do(data))
            obj.save()
        else:
            obj.save()  # To update and trigger indexing
        reset_workflow_object_states(obj)
    except Exception as err:
        current_app.logger.error("Problem migrating record {0}".format(obj_id))
        current_app.logger.exception(err)
        msg = "Error: %r\n%s" % \
              (err, traceback.format_exc())
        obj.set_error_message(msg)
        obj.save(version=ObjectVersion.ERROR)
        raise
开发者ID:gitter-badger,项目名称:inspire-next,代码行数:43,代码来源:tasks.py

示例12: halt_to_render

def halt_to_render(obj, eng):
    """Halt the workflow - waiting to be resumed."""
    deposition = Deposition(obj)
    sip = deposition.get_latest_sip(sealed=False)
    deposition.set_render_context(dict(
        template_name_or_list="deposit/completed.html",
        deposition=deposition,
        deposition_type=(
            None if deposition.type.is_default() else
            deposition.type.get_identifier()
        ),
        uuid=deposition.id,
        sip=sip,
        my_depositions=Deposition.get_depositions(
            current_user, type=deposition.type
        ),
        format_record=format_record,
    ))
    obj.last_task = "halt_to_render"
    eng.halt("User submission complete.")
开发者ID:jma,项目名称:inspire-next,代码行数:20,代码来源:submission.py

示例13: formatter

    def formatter(bwo, **kwargs):
        """Return formatted data of object."""
        try:
            deposit_object = Deposition(bwo)
        except InvalidDepositionType:
            return "This submission is disabled: {0}.".format(bwo.workflow.name)

        sip = deposit_object.get_latest_sip(deposit_object.submitted)
        record = sip.metadata

        if hasattr(sip, "package"):
            marcxml = sip.package
        else:
            return "No data found in submission (no package)."

        of = kwargs.get("of", "hd")
        if of == "xm":
            return marcxml
        else:
            return render_template("format/record/Holding_Pen_HTML_detailed.tpl", record=Record(record))
开发者ID:jalavik,项目名称:inspire-next,代码行数:20,代码来源:literature.py

示例14: test_agnostic_deposit

    def test_agnostic_deposit(self):
        """A deposition still has the same data model."""
        from invenio_deposit.models import Deposition
        from invenio.ext.login.legacy_user import UserInfo

        u = UserInfo(uid=1)
        d = Deposition.create(u, type='DepositModelTest')
        d.save()
        d.run_workflow()

        completed_object = d.engine.completed_objects[0]
        for l in ['files', 'sips', 'type', 'drafts', 'title']:
            self.assertIn(l, completed_object.data)
开发者ID:Dziolas,项目名称:inspire-next,代码行数:13,代码来源:test_workflows.py

示例15: test_create

    def test_create(self):
        """Test."""
        from invenio.ext.login.legacy_user import UserInfo
        from invenio_deposit.models import Deposition

        user = UserInfo(uid=1)
        d = Deposition.create(user)
        assert d.type == self.DefaultType
        assert Deposition.get(d.id).type == self.DefaultType
        d2 = Deposition.create(user, type=self.AnotherType)
        assert d2.type == self.AnotherType
        assert Deposition.get(d2.id).type == self.AnotherType

        # remove the records
        Deposition.delete(d)
        Deposition.delete(d2)
开发者ID:jirikuncar,项目名称:invenio-deposit,代码行数:16,代码来源:test_deposit_models.py


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