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,
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: