ifsfsandsfs2:# this is a regular key-value data qualifeir
cur_qual="%s : %s"%(sfs[0],sfs2[0])
# read columns
columns=[]
sfs=bibrecord.field_get_subfield_values(f,"c")
forsfinsfs:
ifint(sf)>=ds.num_columns:
hepdata_log("reconstruction","Data qualifiers occuly more columns that exist in a dataset. Qualifier %s in column %s ... ignoring exceed. rec: %s"%(cur_qual,str(sf),str(rec),))
"""Retrieves raw data corresponding to a HEPData record.
@param recid: Identifier of the record representing a dataset
@type recid: Integer
@returns: a tuple consisting of a record (bibrecord representation) and string of data
@rtype: (Record, String, String)
"""
rec=search_engine.get_record(recid)
# retrieving the data string (content of an attachment)
data_str=cPickle.dumps([])
data_plain=""
frominvenioimportbibdocfile
brd=bibdocfile.BibRecDocs(recid)
ifbrd.has_docname_p("Data"):
bd=brd.get_bibdoc("Data")
try:
data_file=bd.get_file(".data")
ifdata_file:
data_str=data_file.get_content()
except:
#TODO: The document exists but does not have one of required formats ... we might want to record this in some type of log or even notify someone behind the scenes ?
pass
try:
data_file=bd.get_file(".txt")
ifdata_file:
data_plain=data_file.get_content()
except:
#TODO: The document exists but does not have one of required formats ... we might want to record this in some type of log or even notify someone behind the scenes ?
pass
return(rec,data_str,data_plain)
defget_hepdata_by_recid(parent_recid,recid):
"""Retrieve a dataset encoded in a given record
@param parent_recid: record identifier of the publication attaching the dataset
@type parent_recid: Integer
@param recid: Identifier of te record identifying the dataset
@type recid: Integer
@rtype: Dataset
@returns: A dataset represented by a record of a given number
write_message("Retrieved data for record %s: %i record added, %i records deleted, %i records modified"%(str(recid),num_added,num_deleted,num_modified))
exceptException,e:
write_message("Error: merging HepData for record %s failed: %s" \
%(str(recid),str(e)))
failed_ids.put_nowait((str(recid),"Failed during the merging phase: %s"%(str(e),)))
exceptException,e:
write_message("Error: retrieving HEPData for record %s failed: %s" \
%(str(recid),str(e)))
failed_ids.put_nowait((str(recid),"Failed during the retrieval phase: %s"%(str(e),)))