Commit 2fb29b47 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Modify the script fix_country_0815 to generate the list of synonyms for countries.

parent 4d7dded5
# -*- coding: utf-8 -*-
""" NAME
fix-country-0815 -- Add synonyms for countries
fix_country_0815 -- Add synonyms for countries
SYNOPSIS
fix-country-0815
fix_country_0815
DESCRIPTION
Starting with version 0.8.8, the database is populated with
......@@ -22,8 +22,8 @@
EXAMPLE
> cd ... /track_publications/scripts
> ./run script fix-country-0815.py
> ./run script -S track_publications_cppm fix-country-0815.py
> ./run script fix_country_0815.py
> ./run script -S track_publications_cppm fix_country_0815.py
AUTHOR
R. Le Gac -- Oct 2015
......@@ -35,14 +35,18 @@ if __name__ == "__main__":
from plugin_dbui import get_id, UNDEF_ID
print "\nScanning countries in ", db._uri
for country, synonym in COUNTRIES:
for country, values in COUNTRIES:
idc = get_id(db.countries, country=country)
if idc is None:
print country, " is not in the database ?"
continue
db(db.countries.id==idc).update(synonyms=synonym)
# transform values in the list of synonyms
# remove duplicate entries
li = values.replace(' ', '').split(',')
synonyms = list(set(li))
db(db.countries.id==idc).update(synonyms=synonyms)
rep = raw_input("Commit database change [y/N]: ")
if rep == "y":
......
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