Commit 26fce8df authored by Iustin Pop's avatar Iustin Pop
Browse files

Add support for RE patterns to convert constants

This is a trivial conversion.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarRené Nussbaumer <>
parent cf57f778
......@@ -27,8 +27,12 @@ import re
from ganeti import constants
from ganeti import compat
#: Constant name regex
CONSTANT_RE = re.compile("^[A-Z][A-Z0-9_-]+$")
#: The type of regex objects
def NameRules(name):
"""Converts the upper-cased Python name to Haskell camelCase.
......@@ -129,6 +133,12 @@ def ConvertVariable(name, value):
lines.append("-- | Skipped list/set %s, is not homogeneous" % name)
lines.append("-- | Skipped list/set %s, cannot convert all elems" % name)
elif isinstance(value, RE_TYPE):
tvs = HaskellTypeVal(value.pattern)
assert tvs is not None
lines.append("-- | Converted from Python RE object %s" % name)
lines.append("%s :: %s" % (hs_name, tvs[0]))
lines.append("%s = %s" % (hs_name, tvs[1]))
lines.append("-- Skipped %s, %s not handled" % (name, type(value)))
return lines
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment