tools/osbuild-mpp: handle corner case in mpp-format-int
If you do math in mpp-format-int it could end up getting converted
to a float. Of course if you end up with a decimal value that isn't
`.0` that's a problem for an int, but if it is `.0` let's handle it
gracefully.
For example, math like this could end up with a value with `.0`:
mpp-format-int: "{bios_boot_size_mb * 1024 * 1024 / sector_size_bytes}"
This commit is contained in:
parent
0770eb0090
commit
5207e92cab
1 changed files with 5 additions and 0 deletions
|
|
@ -1259,6 +1259,11 @@ class ManifestFile:
|
|||
sys.exit(1)
|
||||
|
||||
if res_type == "int":
|
||||
# If the value ends with '.0' it could be because of
|
||||
# some math that ended up converting the value to a
|
||||
# float. Just trim it off in that case.
|
||||
if res.endswith('.0'):
|
||||
res = res.strip('.0')
|
||||
res = int(res)
|
||||
elif res_type == "json":
|
||||
res = json.loads(res)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue