# HG changeset patch # User Laurent Peuch # Date 1559039734 -7200 # Node ID 6b314fc558ed33e09ff453053c6d0097e6232f95 # Parent 7b89cad574f8ada0c0a008ea0568ce769f5fc30e [fix] parse cube version number without space in them diff -r 7b89cad574f8 -r 6b314fc558ed cubicweb/migration.py --- 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( diff -r 7b89cad574f8 -r 6b314fc558ed cubicweb/test/unittest_migration.py --- a/cubicweb/test/unittest_migration.py Fri May 24 17:09:10 2019 +0200 +++ b/cubicweb/test/unittest_migration.py Tue May 28 12:35:34 2019 +0200 @@ -22,7 +22,11 @@ from cubicweb import devtools from cubicweb.cwconfig import CubicWebConfiguration -from cubicweb.migration import filter_scripts, version_strictly_lower +from cubicweb.migration import ( + filter_scripts, + split_constraint, + version_strictly_lower, +) class Schema(dict): @@ -113,5 +117,16 @@ [['activated']]) repo.shutdown() +def test_split_constraint(): + assert split_constraint(">=0.1.0") == (">=", "0.1.0") + assert split_constraint(">= 0.1.0") == (">=", "0.1.0") + assert split_constraint(">0.1.1") == (">", "0.1.1") + assert split_constraint("> 0.1.1") == (">", "0.1.1") + assert split_constraint("<0.2.0") == ("<", "0.2.0") + assert split_constraint("< 0.2.0") == ("<", "0.2.0") + assert split_constraint("<=42.1.0") == ("<=", "42.1.0") + assert split_constraint("<= 42.1.0") == ("<=", "42.1.0") + + if __name__ == '__main__': unittest_main()