Commit 8878da32 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the script

parent d1f24520
# -*- coding: utf-8 -*-
""" NAME
fix_harvesters_collections [options]
Up to version, 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, it has been decided that the collection field
contains the definition for only one collection.
This script allow to migrate from to approach.
> cd ...limbra/scripts
> run -S test_limbra script
> run loop
> ...
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 == "" and "," in collections:
print "\n\tsplit:", collections
data = row.as_dict()
del data["id"]
# insert new harvesters
for elt in collections.split(","):
print "\t\tinsert →", elt.strip()
data["collections"] = elt.strip()
# delete old harvesters
print "\t\tdelete →",
del db.harvesters[]
# commit change
rep = raw_input("Commit database changes [y/N]: ")
if rep == 'y':
# exit gently
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