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
8878da32
Commit
8878da32
authored
Oct 06, 2017
by
LE GAC Renaud
Browse files
Add the script fix_harvesters_collections.py.
parent
d1f24520
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
scripts/fix_harvesters_collections.py
scripts/fix_harvesters_collections.py
+62
-0
No files found.
scripts/fix_harvesters_collections.py
0 → 100644
View file @
8878da32
# -*- coding: utf-8 -*-
""" NAME
fix_harvesters_collections
SYNOPSIS
fix_harvesters_collections [options]
DESCRIPTION
Up to version 0.9.6.5, the field collections can contains a list
of collection separated by a comma. This rule is in conflict when
defining a collection using author name since author name can contain
also comma.
In version 0.9.6.6, it has been decided that the collection field
contains the definition for only one collection.
This script allow to migrate from 0.9.6.5 to 0.9.6.6 approach.
OPTIONS
EXAMPLE
> cd ...limbra/scripts
> run -S test_limbra script fix_harvesters_collections.py
> run loop fix_harvesters_collections.py
> ...
AUTHOR
R. Le Gac -- Oct 2017
"""
if
__name__
==
"__main__"
:
import
sys
# scan the harvesters table
for
row
in
db
(
db
.
harvesters
).
iterselect
():
collections
=
row
.
collections
if
row
.
host
==
"cds.cern.ch"
and
","
in
collections
:
print
"
\n\t
split:"
,
collections
data
=
row
.
as_dict
()
del
data
[
"id"
]
# insert new harvesters
for
elt
in
collections
.
split
(
","
):
print
"
\t\t
insert →"
,
elt
.
strip
()
data
[
"collections"
]
=
elt
.
strip
()
db
.
harvesters
.
insert
(
**
data
)
# delete old harvesters
print
"
\t\t
delete →"
,
row
.
id
del
db
.
harvesters
[
row
.
id
]
# commit change
rep
=
raw_input
(
"Commit database changes [y/N]: "
)
if
rep
==
'y'
:
db
.
commit
()
# exit gently
sys
.
exit
(
0
)
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