Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
1ef89c74
Commit
1ef89c74
authored
Apr 09, 2015
by
MEESSEN Christophe
Browse files
Move xml as PublicationTools constructor argument
parent
0789b0b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
18 deletions
+27
-18
controllers/harvest.py
controllers/harvest.py
+2
-1
modules/harvest_tools.py
modules/harvest_tools.py
+25
-17
No files found.
controllers/harvest.py
View file @
1ef89c74
...
...
@@ -224,11 +224,12 @@ def insert_marcxml():
selector
.
id_projects
,
selector
.
controller
,
selector
.
id_categories
,
xml
=
selector
.
xml
,
year_start
=
selector
.
year_start
,
year_end
=
selector
.
year_end
,
dry_run
=
(
selector
.
mode
==
DRY_RUN
),
debug
=
False
)
tool
(
selector
.
xml
)
tool
()
except
ToolException
,
e
:
return
T
(
str
(
e
))
...
...
modules/harvest_tools.py
View file @
1ef89c74
...
...
@@ -408,7 +408,7 @@ class PublicationsTool(object):
"""
def
__init__
(
self
,
db
,
id_team
,
id_project
,
controller
,
id_category
,
host
=
None
,
collections
=
None
,
year_start
=
None
,
year_end
=
None
,
dry_run
=
True
,
debug
=
False
):
xml
=
None
,
year_start
=
None
,
year_end
=
None
,
dry_run
=
True
,
debug
=
False
):
"""
@type db: gluon.dal.DAL
...
...
@@ -432,6 +432,9 @@ class PublicationsTool(object):
@type collections: unicode
@keyword collections: Request string to send to the host to get the publications
@type xml: unicode
@keyword xml: marc12 xml encoding of the publication record
@type year_start: int
@keyword year_start: Start year of search (i.e. '2014')
...
...
@@ -444,6 +447,8 @@ class PublicationsTool(object):
@type debug: bool
@param debug: activate the debug mode
The constructor expect that host and collections is provided or xml is provided instead.
"""
self
.
collection_logs
=
[]
self
.
db
=
db
...
...
@@ -453,17 +458,31 @@ class PublicationsTool(object):
self
.
id_category
=
id_category
self
.
host
=
host
self
.
collections
=
collections
self
.
xml
=
xml
self
.
year_start
=
year_start
self
.
year_end
=
year_end
self
.
dbg
=
debug
self
.
harvester
=
None
self
.
logs
=
[]
self
.
check
=
CheckAndFix
()
self
.
marc12
=
Marc12
()
# check parameters
# protection team, project and/or category have to be defined
if
not
self
.
id_team
:
raise
ToolException
(
MSG_NO_TEAM
)
# Construct harvester Storage needed for the log
if
not
self
.
id_project
:
raise
ToolException
(
MSG_NO_PROJECT
)
if
not
self
.
id_category
:
raise
ToolException
(
MSG_NO_CAT
)
# xml or (host and collections) keyargs must be provided
if
not
((
xml
and
not
host
and
not
collections
)
or
(
not
xml
and
host
and
collections
)):
raise
ToolException
(
MSG_MISSING_PARAMETER
)
# Construct harvester Storage needed for the log
if
host
and
collections
:
self
.
harvester
=
Storage
(
id_teams
=
self
.
id_team
,
id_projects
=
self
.
id_project
,
...
...
@@ -917,26 +936,15 @@ class PublicationsTool(object):
if
self
.
dbg
:
print
"start processing"
,
self
.
__class__
.
__name__
print
"decode request"
# protection team, project and/or category have to be defined
if
not
self
.
id_project
:
raise
ToolException
(
MSG_NO_PROJECT
)
if
not
self
.
id_team
:
raise
ToolException
(
MSG_NO_TEAM
)
if
self
.
dbg
:
print
"get harvest parameters"
# process an XML request
if
xml
:
if
not
self
.
id_category
:
raise
ToolException
(
MSG_NO_CAT
)
self
.
xml
=
xml
if
self
.
xml
:
self
.
collection_logs
.
append
(
MsgCollection
(
found
=
1
))
self
.
process_xml
(
xml
)
self
.
process_xml
(
self
.
xml
)
return
# retrieve the harvester parameter in the database
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment