Revision 26fce8df
b/autotools/convert-constants | ||
---|---|---|
27 | 27 |
from ganeti import constants |
28 | 28 |
from ganeti import compat |
29 | 29 |
|
30 |
#: Constant name regex |
|
30 | 31 |
CONSTANT_RE = re.compile("^[A-Z][A-Z0-9_-]+$") |
31 | 32 |
|
33 |
#: The type of regex objects |
|
34 |
RE_TYPE = type(CONSTANT_RE) |
|
35 |
|
|
32 | 36 |
|
33 | 37 |
def NameRules(name): |
34 | 38 |
"""Converts the upper-cased Python name to Haskell camelCase. |
... | ... | |
129 | 133 |
lines.append("-- | Skipped list/set %s, is not homogeneous" % name) |
130 | 134 |
else: |
131 | 135 |
lines.append("-- | Skipped list/set %s, cannot convert all elems" % name) |
136 |
elif isinstance(value, RE_TYPE): |
|
137 |
tvs = HaskellTypeVal(value.pattern) |
|
138 |
assert tvs is not None |
|
139 |
lines.append("-- | Converted from Python RE object %s" % name) |
|
140 |
lines.append("%s :: %s" % (hs_name, tvs[0])) |
|
141 |
lines.append("%s = %s" % (hs_name, tvs[1])) |
|
132 | 142 |
else: |
133 | 143 |
lines.append("-- Skipped %s, %s not handled" % (name, type(value))) |
134 | 144 |
return lines |
Also available in: Unified diff