Revision 2325bfcf autotools/convert-constants
b/autotools/convert-constants | ||
---|---|---|
25 | 25 |
import re |
26 | 26 |
|
27 | 27 |
from ganeti import constants |
28 |
from ganeti import compat |
|
28 | 29 |
|
29 | 30 |
CONSTANT_RE = re.compile("^[A-Z][A-Z0-9_-]+$") |
30 | 31 |
|
... | ... | |
98 | 99 |
lines.append("-- Following lines come from dictionary %s" % name) |
99 | 100 |
for k in sorted(value.keys()): |
100 | 101 |
lines.extend(ConvertVariable(DictKeyName(name, k), value[k])) |
102 |
elif isinstance(value, tuple): |
|
103 |
tvs = [HaskellTypeVal(elem) for elem in value] |
|
104 |
if compat.all(e is not None for e in tvs): |
|
105 |
ttypes = ", ".join(e[0] for e in tvs) |
|
106 |
tvals = ", ".join(e[1] for e in tvs) |
|
107 |
lines.append("-- | Converted from Python tuple %s" % name) |
|
108 |
lines.append("%s :: (%s)" % (hs_name, ttypes)) |
|
109 |
lines.append("%s = (%s)" % (hs_name, tvals)) |
|
110 |
else: |
|
111 |
lines.append("-- Skipped tuple %s, cannot convert all elements" % name) |
|
101 | 112 |
else: |
102 | 113 |
lines.append("-- Skipped %s, %s not handled" % (name, type(value))) |
103 | 114 |
return lines |
Also available in: Unified diff