aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/entry.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-07-08 14:25:43 -0600
committerSimon Glass <sjg@chromium.org>2019-07-24 12:54:08 -0700
commit41b8ba090ced0bb54733dc3dd32e945e7e332801 (patch)
treeba39478dfacd366f90de71001734414e5efc627f /tools/binman/entry.py
parent8a1ad068deef6228fd501992bdb347ecad9da067 (diff)
downloadu-boot-41b8ba090ced0bb54733dc3dd32e945e7e332801.zip
u-boot-41b8ba090ced0bb54733dc3dd32e945e7e332801.tar.gz
u-boot-41b8ba090ced0bb54733dc3dd32e945e7e332801.tar.bz2
binman: Allow listing the entries in an image
It is useful to be able to summarise all the entries in an image, e.g. to display this to this user. Add a new ListEntries() method to Entry, and set up a way to call it through the Image class. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/entry.py')
-rw-r--r--tools/binman/entry.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/binman/entry.py b/tools/binman/entry.py
index e38cb71..ee63d18 100644
--- a/tools/binman/entry.py
+++ b/tools/binman/entry.py
@@ -33,6 +33,10 @@ our_path = os.path.dirname(os.path.realpath(__file__))
# device-tree properties.
EntryArg = namedtuple('EntryArg', ['name', 'datatype'])
+# Information about an entry for use when displaying summaries
+EntryInfo = namedtuple('EntryInfo', ['indent', 'name', 'etype', 'size',
+ 'image_pos', 'uncomp_size', 'offset',
+ 'entry'])
class Entry(object):
"""An Entry in the section
@@ -617,3 +621,35 @@ features to produce new behaviours.
if not self.HasSibling(name):
return False
return self.section.GetEntries()[name].image_pos
+
+ @staticmethod
+ def AddEntryInfo(entries, indent, name, etype, size, image_pos,
+ uncomp_size, offset, entry):
+ """Add a new entry to the entries list
+
+ Args:
+ entries: List (of EntryInfo objects) to add to
+ indent: Current indent level to add to list
+ name: Entry name (string)
+ etype: Entry type (string)
+ size: Entry size in bytes (int)
+ image_pos: Position within image in bytes (int)
+ uncomp_size: Uncompressed size if the entry uses compression, else
+ None
+ offset: Entry offset within parent in bytes (int)
+ entry: Entry object
+ """
+ entries.append(EntryInfo(indent, name, etype, size, image_pos,
+ uncomp_size, offset, entry))
+
+ def ListEntries(self, entries, indent):
+ """Add files in this entry to the list of entries
+
+ This can be overridden by subclasses which need different behaviour.
+
+ Args:
+ entries: List (of EntryInfo objects) to add to
+ indent: Current indent level to add to list
+ """
+ self.AddEntryInfo(entries, indent, self.name, self.etype, self.size,
+ self.image_pos, self.uncomp_size, self.offset, self)