本文整理汇总了Python中invenio.modules.deposit.models.Deposition类的典型用法代码示例。如果您正苦于以下问题:Python Deposition类的具体用法?Python Deposition怎么用?Python Deposition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Deposition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
def create(obj, dummy_eng):
#FIXME change share tmp directory
from invenio.config import CFG_TMPSHAREDDIR
from invenio.legacy.bibsched.bibtask import task_low_level_submission, \
bibtask_allocate_sequenceid
d = Deposition(obj)
sip = d.get_latest_sip(sealed=False)
sip.seal()
tmp_file_fd, tmp_file_path = mkstemp(
prefix="webdeposit-%s-%s" % (d.id, sip.uuid),
suffix='.xml',
dir=CFG_TMPSHAREDDIR,
)
os.write(tmp_file_fd, sip.package)
os.close(tmp_file_fd)
# Trick to have access to task_sequence_id in subsequent tasks.
d.workflow_object.task_sequence_id = bibtask_allocate_sequenceid()
task_id = task_low_level_submission(
'bibupload', 'webdeposit',
'-r' if 'recid' in sip.metadata else '-i', tmp_file_path,
'-I', str(d.workflow_object.task_sequence_id)
)
sip.task_ids.append(task_id)
d.update()
示例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))
示例3: _run_tasks
def _run_tasks(obj, dummy_eng):
from invenio.legacy.bibsched.bibtask import task_low_level_submission
d = Deposition(obj)
sip = d.get_latest_sip(sealed=True)
recid = sip.metadata['recid']
common_args = []
sequenceid = getattr(d.workflow_object, 'task_sequence_id', None)
if sequenceid:
common_args += ['-I', str(sequenceid)]
if update:
tasklet_name = 'bst_openaire_update_upload'
else:
tasklet_name = 'bst_openaire_new_upload'
task_id = task_low_level_submission(
'bibtasklet', 'webdeposit', '-T', tasklet_name,
'--argument', 'recid=%s' % recid, *common_args
)
sip.task_ids.append(task_id)
d.update()
示例4: _prefill_draft
def _prefill_draft(obj, eng):
if not getattr(request, 'is_api_request', False):
draft_cache = DepositionDraftCacheManager.get()
if draft_cache.has_data():
d = Deposition(obj)
draft_cache.fill_draft(d, draft_id, clear=clear)
d.update()
示例5: edit_record_subject
def edit_record_subject(objectid):
"""Entrypoint for editing subjects from detailed pages."""
editable_obj = BibWorkflowObject.query.get(objectid)
data = editable_obj.get_data()
new_subjects_list = request.values.getlist('subjects[]') or []
subject_dict = []
# We need to check the type of the object due to differences
# Submission: dict / Harvest: SmartJson
if type(data) is dict:
deposition = Deposition(editable_obj)
sip = deposition.get_latest_sip()
metadata = sip.metadata
subject_dict.extend(metadata.get(SUBJECT_TERM))
edit_submission(deposition, metadata, sip,
new_subjects_list, subject_dict)
else:
subject_dict.extend(data.get(SUBJECT_TERM))
edit_harvest(editable_obj, data, new_subjects_list, subject_dict)
return jsonify({
"category": "success",
"message": "Edit on subjects was successful."
})
示例6: _classify_paper_with_deposit
def _classify_paper_with_deposit(obj, eng):
from invenio.modules.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 = bibclassify_exhaustive_call
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("title", {}).get("title", ""),
metadata.get("abstract", {}).get("summary", "")]
callback = bibclassify_exhaustive_call_text
classify_paper(obj, eng, callback, data,
taxonomy, rebuild_cache,
no_cache, output_mode, output_limit,
spires, match_mode, with_author_keywords,
extract_acronyms, only_core_tags, fast_mode)
示例7: _run_tasks
def _run_tasks(obj, dummy_eng):
d = Deposition(obj)
sip = d.get_latest_sip(sealed=True)
recid = sip.metadata['recid']
communities = sip.metadata.get('provisional_communities', [])
common_args = ['-P5', ]
sequenceid = getattr(d.workflow_object, 'task_sequence_id', None)
if sequenceid:
common_args += ['-I', str(sequenceid)]
if update:
tasklet_name = 'bst_openaire_update_upload'
else:
tasklet_name = 'bst_openaire_new_upload'
task_id = task_low_level_submission(
'bibtasklet', 'webdeposit', '-T', tasklet_name,
'--argument', 'recid=%s' % recid, *common_args
)
sip.task_ids.append(task_id)
for c in communities:
task_id = task_low_level_submission(
'webcoll', 'webdeposit', '-c', 'provisional-user-%s' % c,
*common_args
)
sip.task_ids.append(task_id)
d.update()
示例8: _mint_pid
def _mint_pid(obj, dummy_eng):
d = Deposition(obj)
recjson = d.get_latest_sip(sealed=False).metadata
if 'recid' not in recjson:
raise Exception("'recid' not found in sip metadata.")
pid_text = None
pid = recjson.get(pid_field, None)
if not pid:
# No pid found in recjson, so create new pid with user supplied
# function.
pid_text = recjson[pid_field] = pid_creator(recjson)
else:
# Pid found - check if it should be minted
if existing_pid_checker and existing_pid_checker(pid, recjson):
pid_text = pid
# Create an assign pid internally - actually registration will happen
# asynchronously later.
if pid_text:
current_app.logger.info("Registering pid %s" % pid_text)
pid_obj = PersistentIdentifier.create(pid_store_type, pid_text)
if pid_obj is None:
pid_obj = PersistentIdentifier.get(pid_store_type, pid_text)
try:
pid_obj.assign("rec", recjson['recid'])
except Exception:
register_exception(alert_admin=True)
d.update()
示例9: _finalize_sip
def _finalize_sip(obj, dummy_eng):
d = Deposition(obj)
sip = d.get_latest_sip(sealed=False)
sip.package = make_record(
sip.metadata, is_dump=is_dump
).legacy_export_as_marc()
d.update()
示例10: do_upgrade
def do_upgrade():
"""Implement your upgrades here."""
from invenio.modules.workflows.models import BibWorkflowObject
from invenio.modules.deposit.models import Deposition
q = BibWorkflowObject.query.filter(BibWorkflowObject.id_user != 0).all()
for b in q:
try:
d = Deposition(b)
except KeyError:
logger.info("Fixing data in {}".format(b.id))
b.set_data(dict(
type='upload',
title='Untitled',
files=[],
drafts={},
sips=[],
))
d = Deposition(b)
d.save()
s = _get_state(d)
c = str(b.get_extra_data().get('_task_counter'))
co = str(b.get_extra_data().get('task_counter'))
if s == 'inprogress-new':
if c == "[0, 0, 3, 1]":
b.save(task_counter=[0, 3, 1])
elif c == "[0, 0, 3, 2]":
b.save(task_counter=[0, 3, 2])
elif c == "None" and co == "[0, 0, 3, 1]":
b.save(task_counter=[0, 3, 1])
elif s == 'inprogress-edit':
if c == "[0, 0, 1, 0]":
b.save(task_counter=[0, 1, 0])
elif c == "[0, 0, 1, 1]":
b.save(task_counter=[0, 1, 1])
elif c == "[0, 4, 3, 0]":
b.save(task_counter=[4, 3, 0])
elif c == "None" and co == "[0, 0, 1, 1]":
b.save(task_counter=[0, 1, 1])
elif c == "None" and co == "[0, 0, 1, 0]":
b.save(task_counter=[0, 1, 0])
elif b.id == 2076:
b.save(task_counter=[4, 3, 0])
b.workflow.save(status=4)
elif s == 'error':
if c == "[0, 0, 1, 0]":
b.save(task_counter=[0, 1, 0])
elif c == "[0, 0, 1, 1]":
b.save(task_counter=[0, 1, 1])
elif c == "[0, 0, 3, 1]":
b.save(task_counter=[0, 3, 1])
elif c == "[0, 0, 3, 2]":
b.save(task_counter=[0, 3, 2])
elif c == "[0, 4, 3, 0]":
b.save(task_counter=[4, 3, 0])
elif c == "[0, 4, 3, 1]":
b.save(task_counter=[4, 3, 1])
示例11: add_core_deposit
def add_core_deposit(obj, eng):
"""Check if the record was approved as CORE."""
from invenio.modules.deposit.models import Deposition
if obj.extra_data.get("core"):
d = Deposition(obj)
sip = d.get_latest_sip(d.submitted)
sip.metadata = add_core(sip.metadata)
d.update()
示例12: _reserved_recid
def _reserved_recid(obj, dummy_eng):
d = Deposition(obj)
sip = d.get_latest_sip(sealed=False)
reserved_doi = sip.metadata.get('prereserve_doi', None)
if reserved_doi and reserved_doi['recid']:
sip.metadata['recid'] = reserved_doi['recid']
d.update()
示例13: _bibdocfile_update
def _bibdocfile_update(obj, eng):
if process:
d = Deposition(obj)
sip = d.get_latest_sip(sealed=False)
recid = sip.metadata.get('recid')
if recid:
brd = BibRecDocs(int(recid))
process(d, brd)
d.update()
示例14: create
def create(obj, dummy_eng):
#FIXME change share tmp directory
d = Deposition(obj)
sip = d.get_latest_sip(sealed=True)
sip.seal() #FIXME ???
create_record(data=sip.metadata)
d.update()
示例15: _process_sip
def _process_sip(obj, dummy_eng):
d = Deposition(obj)
metadata = d.get_latest_sip(sealed=False).metadata
if processor is not None:
processor(d, metadata)
elif processor is None and hasattr(d.type, 'process_sip_metadata'):
d.type.process_sip_metadata(d, metadata)
d.update()