blob_named_by_arg.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # SPDX-License-Identifier: GPL-2.0+
  2. # Copyright (c) 2018 Google, Inc
  3. # Written by Simon Glass <sjg@chromium.org>
  4. #
  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.
  8. from collections import OrderedDict
  9. from binman.etype.blob import Entry_blob
  10. from binman.entry import EntryArg
  11. class Entry_blob_named_by_arg(Entry_blob):
  12. """A blob entry which gets its filename property from its subclass
  13. Properties / Entry arguments:
  14. - <xxx>-path: Filename containing the contents of this entry (optional,
  15. defaults to None)
  16. where <xxx> is the blob_fname argument to the constructor.
  17. This entry cannot be used directly. Instead, it is used as a parent class
  18. for another entry, which defined blob_fname. This parameter is used to
  19. set the entry-arg or property containing the filename. The entry-arg or
  20. property is in turn used to set the actual filename.
  21. See cros_ec_rw for an example of this.
  22. """
  23. def __init__(self, section, etype, node, blob_fname, required=False):
  24. super().__init__(section, etype, node)
  25. filename, = self.GetEntryArgsOrProps(
  26. [EntryArg('%s-path' % blob_fname, str)], required=required)
  27. if filename:
  28. self._filename = filename