]> www.infradead.org Git - users/sagi/libnvme.git/commit
Python: make NBFT data more pythonic
authorMartin Belanger <martin.belanger@dell.com>
Tue, 18 Apr 2023 13:19:32 +0000 (09:19 -0400)
committerDaniel Wagner <wagi@monom.org>
Tue, 18 Apr 2023 14:20:33 +0000 (16:20 +0200)
commit1baa0757567d8951e483ebedf2c7d81882ad829f
tree01b534ec8597c3ef78f1de3057302d69be7b0409
parentef27cf88b1aeed3ba778740f5f71dbd98a79073d
Python: make NBFT data more pythonic

I made the nfollowing changes so that the data is more Pythonic.

1) For boolean values, set them to True/False instead of 1/0.

2) NBFT data contains ordered lists. In the raw NBFT data the
position of each element in the list is indicated by a 1-based
index. When converting to Python lists, make sure that each
element is inserted in the list at the right position. This is
done by converting the 1-based index to a 0-based index.

3) For objects that contain index variables that refer to items in
a list, make sure to convert the 1-based index to 0-based so that
it can be used directly to access the python lists (e.g. list[index]).

4) Since Python lists are ordered (per 2 above), there is no
need to keep an explicit 1-based index in each of the list items.
Therefore those 1-based indexes were removed.

5) No need to keep explicit variables representing the length of
a list. In Python one need only use len(list) to get the length.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
libnvme/nvme.i
libnvme/tests/test-nbft.py