1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2018 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
5 # Entry-type module for a blob where the filename comes from a property in the
6 # node or an entry argument. The property is called '<blob_fname>-path' where
7 # <blob_fname> is provided by the subclass using this entry type.
9 from collections import OrderedDict
11 from blob import Entry_blob
12 from entry import EntryArg
15 class Entry_blob_named_by_arg(Entry_blob):
16 """A blob entry which gets its filename property from its subclass
18 Properties / Entry arguments:
19 - <xxx>-path: Filename containing the contents of this entry (optional,
22 where <xxx> is the blob_fname argument to the constructor.
24 This entry cannot be used directly. Instead, it is used as a parent class
25 for another entry, which defined blob_fname. This parameter is used to
26 set the entry-arg or property containing the filename. The entry-arg or
27 property is in turn used to set the actual filename.
29 See cros_ec_rw for an example of this.
31 def __init__(self, section, etype, node, blob_fname):
32 Entry_blob.__init__(self, section, etype, node)
33 self._filename, = self.GetEntryArgsOrProps(
34 [EntryArg('%s-path' % blob_fname, str)])