Commit 2222df71 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the function get_harvester_tool in harvester module and use it.

parent 27c22111
......@@ -3,15 +3,7 @@
"""
import traceback
from harvest_tools import (Articles,
Notes,
Preprints,
Proceedings,
Reports,
Talks,
ToolException,
Thesis)
from harvest_tools import get_harvester_tool, ToolException
from plugin_dbui import Selector
......@@ -22,28 +14,8 @@ def insert_marcxml():
try:
selector = Selector(virtdb.marc12_selector)
if selector.controller == 'articles':
Tool = Articles
elif selector.controller == 'notes':
Tool = Notes
elif selector.controller == 'preprints':
Tool = Preprints
elif selector.controller == 'proceedings':
Tool = Proceedings
elif selector.controller == 'reports':
Tool = Reports
elif selector.controller == 'talks':
Tool = Talks
elif selector.controller == 'theses':
Tool = Thesis
else:
Tool = get_harvester_tool(selector.controller)
if not Tool:
return T('Select a controller.')
tool = Tool(selector, debug=False)
......@@ -63,7 +35,9 @@ def insert_marcxml():
def run():
"""Scan the cds/invenio stores to find articles published during
"""Run an harvester.
Scan the cds/invenio stores to find articles published during
a given range of years and for a given team/project.
Insert them in the database if they don't exist.
......@@ -77,28 +51,8 @@ def run():
selector = Selector(virtdb.harvester_selector,
exclude_fields=('year_start', 'year_end'))
if selector.controller == 'articles':
Tool = Articles
elif selector.controller == 'notes':
Tool = Notes
elif selector.controller == 'preprints':
Tool = Preprints
elif selector.controller == 'proceedings':
Tool = Proceedings
elif selector.controller == 'reports':
Tool = Reports
elif selector.controller == 'talks':
Tool = Talks
elif selector.controller == 'theses':
Tool = Thesis
else:
Tool = get_harvester_tool(selector.controller)
if not Tool:
return T('Select an harvester.')
tool = Tool(selector, debug=False)
......
......@@ -285,6 +285,7 @@
'Save profile': 'Save profile',
'Scan %s': 'Scan %s',
'Scan between %s and %s': 'Scan between %s and %s',
'Scan from %s to %s': 'Scan de %s à %s',
'schema': 'schema',
'Section': 'Section',
'Sections': 'Sections',
......
......@@ -208,6 +208,38 @@ def get_conference_record(cds, marc12, record):
return MSG_NO_CONF % key
def get_harvester_tool(controller):
"""Return the harvester tool associate to the controller
or None if the controller correspond to nothing.
"""
if controller == 'articles':
Tool = Articles
elif controller == 'notes':
Tool = Notes
elif controller == 'preprints':
Tool = Preprints
elif controller == 'proceedings':
Tool = Proceedings
elif controller == 'reports':
Tool = Reports
elif controller == 'talks':
Tool = Talks
elif controller == 'theses':
Tool = Thesis
else:
Tool = None
return Tool
def is_published_paper(record):
"""Filter selecting published paper.
The paper should have a publisher and a volume numbers.
......
......@@ -59,7 +59,7 @@
if selector.year_start:
t1 = T("Scan %s") % selector.year_start
if selector.year_start and selector.year_end:
t1 = T("Scan between %s and %s") % (selector.year_start, selector.year_end)
t1 = T("Scan from %s to %s") % (selector.year_start, selector.year_end)
pass
ul.append(myli(t1))
pass
......
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