X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=juju%2Fconstraints.py;h=998862d02508499dd28d0f20983e1f5858498213;hb=a09dd5038d226fbcda54a79bdddc995054857198;hp=97529e46ad5accd7dc5d6d45e3d7e01d9347e639;hpb=0d70179f2088da28e47bcad569366fb3dddd6e6d;p=osm%2FN2VC.git diff --git a/juju/constraints.py b/juju/constraints.py index 97529e4..998862d 100644 --- a/juju/constraints.py +++ b/juju/constraints.py @@ -21,6 +21,7 @@ import re MEM = re.compile('^[1-9][0-9]*[MGTP]$') # Multiplication factors to get Megabytes +# https://github.com/juju/juju/blob/master/constraints/constraints.go#L666 FACTORS = { "M": 1, "G": 1024, @@ -31,16 +32,14 @@ FACTORS = { SNAKE1 = re.compile(r'(.)([A-Z][a-z]+)') SNAKE2 = re.compile('([a-z0-9])([A-Z])') + def parse(constraints): """ Constraints must be expressed as a string containing only spaces and key value pairs joined by an '='. """ - if constraints is None: - return None - - if constraints == "": + if not constraints: return None if type(constraints) is dict: