1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2018 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
6 from collections import OrderedDict
8 from entry import Entry, EntryArg
13 class Entry_text(Entry):
14 """An entry which contains text
16 The text can be provided either in the node itself or by a command-line
17 argument. There is a level of indirection to allow multiple text strings
20 Properties / Entry arguments:
21 text-label: The value of this string indicates the property / entry-arg
22 that contains the string to place in the entry
23 <xxx> (actual name is the value of text-label): contains the string to
30 text-label = "message";
35 binman -amessage="this is my message"
37 and binman will insert that string into the entry.
39 It is also possible to put the string directly in the node:
43 text-label = "message";
44 message = "a message directly in the node"
47 The text is not itself nul-terminated. This can be achieved, if required,
48 by setting the size of the entry to something larger than the text.
50 def __init__(self, section, etype, node):
51 Entry.__init__(self, section, etype, node)
52 label, = self.GetEntryArgsOrProps([EntryArg('text-label', str)])
53 self.text_label = tools.ToStr(label) if type(label) != str else label
54 value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, str)])
55 value = tools.ToBytes(value) if value is not None else value
58 def ObtainContents(self):
60 self.Raise("No value provided for text label '%s'" %
62 self.SetContents(self.value)