mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2024-10-26 07:55:06 +03:00
generator: Skip exporting only sentinels
When enum type has '_LAST' in its name, but is not the last type in that enum, it's skipped even though it shouldn't be. Currently, this is the case for only VIR_NETWORK_UPDATE_COMMAND_ADD_LAST inside an enum virNetworkUpdateCommand. Also, since _LAST types can have other enums instead of values, that needs to be filtered out using a try-except when converting the value. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
bde9d463f3
commit
014d9bbaf3
19
generator.py
19
generator.py
@ -227,10 +227,9 @@ def enum(type, name, value):
|
||||
value = 1
|
||||
elif value == 'VIR_DOMAIN_AFFECT_CONFIG':
|
||||
value = 2
|
||||
if name[-5:] != '_LAST':
|
||||
if onlyOverrides and name not in enums[type]:
|
||||
return
|
||||
enums[type][name] = value
|
||||
if onlyOverrides and name not in enums[type]:
|
||||
return
|
||||
enums[type][name] = value
|
||||
|
||||
def lxc_enum(type, name, value):
|
||||
if type not in lxc_enums:
|
||||
@ -1765,13 +1764,23 @@ def buildWrappers(module):
|
||||
#
|
||||
# Generate enum constants
|
||||
#
|
||||
def enumsSortKey(data):
|
||||
value = data[1]
|
||||
try:
|
||||
value = int(value)
|
||||
except ValueError:
|
||||
value = float('inf')
|
||||
return value
|
||||
|
||||
enumvals = list(enums.items())
|
||||
if enumvals is not None:
|
||||
enumvals.sort(key=lambda x: x[0])
|
||||
for type,enum in enumvals:
|
||||
classes.write("# %s\n" % type)
|
||||
items = list(enum.items())
|
||||
items.sort(key=lambda i: int(i[1]))
|
||||
items.sort(key=enumsSortKey)
|
||||
if items[-1][0].endswith('_LAST'):
|
||||
del items[-1]
|
||||
for name,value in items:
|
||||
classes.write("%s = %s\n" % (name,value))
|
||||
classes.write("\n")
|
||||
|
Loading…
Reference in New Issue
Block a user