[PATCH 1 of 2 seda] [migration] Add migration script to update language vocabulary

Sylvain Thenault sylvain.thenault at logilab.fr
Wed Oct 11 11:01:31 CEST 2017

# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1507640461 -7200
#      Tue Oct 10 15:01:01 2017 +0200
# Node ID db7d6c475c6823a659f60518122f1b8d839b3e67
# Parent  ba6a36fa1ce7e3c3c4cd5e14de7a84e251798030
# Available At https://hg.logilab.org/review/cubes/seda
#              hg pull https://hg.logilab.org/review/cubes/seda -r db7d6c475c68
[migration] Add migration script to update language vocabulary

to keep existing migration in sync with change introduced in ba6a36fa1ce7.

Closes #17106805

diff --git a/cubicweb_seda/migration/0.11.0_Any.py b/cubicweb_seda/migration/0.11.0_Any.py
new file mode 100644
--- /dev/null
+++ b/cubicweb_seda/migration/0.11.0_Any.py
@@ -0,0 +1,43 @@
+from __future__ import print_function
+print('filtering language concepts, this will take a while')
+seda_02_langs = set((
+    'aa', 'ab', 'af', 'ak', 'am', 'ar', 'an', 'as', 'av', 'ae', 'ay', 'az',
+    'ba', 'bm', 'be', 'bn', 'bh', 'bi', 'bo', 'bs', 'br', 'bg',
+    'ca', 'cs', 'ch', 'ce', 'cu', 'cv', 'co', 'cr', 'cy',
+    'da', 'de', 'dv', 'dz',
+    'el', 'en', 'eo', 'et', 'ee', 'es', 'eu',
+    'fo', 'fa', 'fj', 'fi', 'fr', 'fy', 'ff',
+    'ga', 'gl', 'gv', 'gn', 'gu',
+    'ht', 'ha', 'he', 'hz', 'hi', 'ho', 'hr', 'hu', 'hy',
+    'ig', 'is', 'io', 'ii', 'iu', 'ie', 'ia', 'id', 'ik', 'it',
+    'jv', 'ja',
+    'ka', 'kl', 'kn', 'ks', 'kr', 'kk', 'km', 'ki', 'ky', 'kv', 'kg', 'ko', 'kj', 'ku', 'kw',
+    'lo', 'lv', 'li', 'ln', 'lt', 'lb', 'lu', 'lg',
+    'mk', 'mh', 'ml', 'mi', 'mr', 'ms', 'mg', 'mt', 'mn', 'my',
+    'na', 'nv', 'nr', 'nd', 'ng', 'ne', 'nn', 'nb', 'no', 'ny', 'nl',
+    'oc', 'oj', 'or', 'om', 'os',
+    'pa', 'pi', 'pl', 'pt', 'ps'
+    'qu',
+    'rm', 'ro', 'rn', 'ru', 'rw',
+    'sg', 'sa', 'si', 'sk', 'sl', 'se', 'sm', 'sn', 'sd', 'so', 'st', 'sc', 'sr', 'ss', 'su', 'sw', 'sv', 'sq',
+    'ty', 'ta', 'tt', 'te', 'tg', 'tl', 'th', 'ti', 'to', 'tn', 'ts', 'tk', 'tr', 'tw',
+    'ug', 'uk', 'ur', 'uz',
+    've', 'vi', 'vo',
+    'wa', 'wo',
+    'xh',
+    'yi', 'yo',
+    'za', 'zu', 'zh',
+rset = rql(
+    'Any X WHERE X in_scheme S, S title "Langues (ISO-639-3)", '
+    'L label_of X, L language_code "seda-02", NOT L label IN ({})'
+    .format(','.join(repr(code) for code in seda_02_langs)))
+print(len(rset), 'concepts to delete')
+for i, concept in enumerate(rset.entities()):
+    concept.cw_delete()
+    if i % 10:
+        cnx.commit()

More information about the saem-devel mailing list