Commit 5707e6c7 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '73-harvest-hal-hidden' into 'master'

73 harvest hal hidden

* Update to harvest inspirehep collection, *e.g* `HAL Hidden`:

        find cc HAL Hidden ...

* Close #73 

See merge request !72
parents 956e8dff 1db1e932
......@@ -28,6 +28,10 @@ MSG_NSERT_FAIL = "Fail to insert the new record in the database."
MSG_NO_OAI = "Reject no OAI identifier"
MSG_WELL_FORM_OAI = "Reject OAI is not well formed"
# search collection when using inspirehep
# require for "Hal Hidden"
REG_COLLECTION = re.compile(r"cc([A-Za-z ]+)(and|$)")
class Automaton(object):
"""Base class to search and process publications:
......@@ -299,6 +303,15 @@ class Automaton(object):
sf='year', # sort by date
so='d') # descending order
# handle the cc keyword (true inspirehep collection)
match = REG_COLLECTION.search(query)
if match:
dic["cc"] = match.group(1).strip()
dic["p"] = REG_COLLECTION.sub("", query).strip()
dic["p"] = dic["p"].replace(" ", " ")
if dic["p"] == "find":
del dic["p"]
# CERN INVENIO store
else:
......
......@@ -73,7 +73,10 @@ class Record(dict):
val = []
for el in self[field]:
if subfield in el:
val.append(el[subfield])
if isinstance(el[subfield], list):
val.extend(el[subfield])
else:
val.append(el[subfield])
if force_list and not isinstance(val, list):
if val:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment