cubicweb/migration.py
changeset 12629 6b314fc558ed
parent 12567 26744ad37953
child 12744 19aef4729d45
--- a/cubicweb/migration.py	Fri May 24 17:09:10 2019 +0200
+++ b/cubicweb/migration.py	Tue May 28 12:35:34 2019 +0200
@@ -19,8 +19,10 @@
 
 import sys
 import os
+import string
 import logging
 import tempfile
+import itertools
 from os.path import exists, join, basename, splitext
 from itertools import chain
 
@@ -466,6 +468,14 @@
 def max_version(a, b):
     return str(max(Version(a), Version(b)))
 
+
+def split_constraint(constraint):
+    oper = itertools.takewhile(lambda x: x in "<>=", constraint)
+    version = itertools.dropwhile(lambda x: x not in string.digits + ".", constraint)
+
+    return "".join(oper), "".join(version)
+
+
 class ConfigurationProblem(object):
     """Each cube has its own list of dependencies on other cubes/versions.
 
@@ -499,7 +509,7 @@
                 self.reverse_dependencies.setdefault(name,set())
                 if constraint:
                     try:
-                        oper, version = constraint.split()
+                        oper, version = split_constraint(constraint)
                         self.reverse_dependencies[name].add( (oper, version, cube) )
                     except Exception:
                         self.warnings.append(