cros_bundle_firmware: Handle hex numbers when decoding strings
In a future CL I'd like to specify an integer using the "0x" format.
Detect this and handle it by adding "base 0" to the integer
conversion.
BUG=chrome-os-partner:20172
TEST=Next CL doens't yell about 0x anymore when no pin is defined.
Change-Id: I98711b9b6b31f3d1a10da69ade3115be29b289b3
Reviewed-on: https://gerrit.chromium.org/gerrit/58876
Commit-Queue: Doug Anderson <dianders@chromium.org>
Tested-by: Doug Anderson <dianders@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
diff --git a/host/lib/fdt.py b/host/lib/fdt.py
index 0ce0301..65a3105 100644
--- a/host/lib/fdt.py
+++ b/host/lib/fdt.py
@@ -110,6 +110,9 @@
>>> fdt.DecodeIntList('/', 'galveston', '1 2 3 4', 4)
[1, 2, 3, 4]
+ >>> fdt.DecodeIntList('/', 'galveston', '0xff', 1)
+ [255]
+
>>> fdt.DecodeIntList('/', 'galveston', '1 2 3 4', 3)
Traceback (most recent call last):
...
@@ -137,7 +140,7 @@
raise ValueError, ("GetIntList of node '%s' prop '%s' returns '%s'"
", which has %d elements, but %d expected" %
(node, prop, list, len(int_list), num_values))
- return [int(item) for item in int_list]
+ return [int(item, 0) for item in int_list]
def GetIntList(self, node, prop, num_values=None, default=None):
"""Read a property and decode it into a list of integers.