aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass2020-11-08 20:36:20 -0700
committerSimon Glass2020-12-13 07:58:17 -0700
commit479dd30f4ac3a8ef417a9aafed24c0cad8a866be (patch)
tree005d729338886353043d0678e999f32e6f0037e4
parent6a4ccad8e0cb42d53ff7016c1d9cd53b87e4347a (diff)
patman: Drop tools.ToChar() and ToChars()
This is useful anymore, since we always want to call chr() in Python 3. Drop it and adjust callers to use chr(). Also drop ToChars() which is no-longer used. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--tools/dtoc/fdt.py8
-rwxr-xr-xtools/dtoc/test_fdt.py2
-rw-r--r--tools/patman/tools.py23
3 files changed, 5 insertions, 28 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index cb365ca094a..4a78c737252 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -87,9 +87,9 @@ def BytesToValue(data):
return Type.STRING, [s.decode() for s in strings[:-1]]
if size % 4:
if size == 1:
- return Type.BYTE, tools.ToChar(data[0])
+ return Type.BYTE, chr(data[0])
else:
- return Type.BYTE, [tools.ToChar(ch) for ch in list(data)]
+ return Type.BYTE, [chr(ch) for ch in list(data)]
val = []
for i in range(0, size, 4):
val.append(data[i:i + 4])
@@ -152,9 +152,9 @@ class Prop:
if type(self.value) == list:
new_value = []
for val in self.value:
- new_value += [tools.ToChar(by) for by in val]
+ new_value += [chr(by) for by in val]
else:
- new_value = [tools.ToChar(by) for by in self.value]
+ new_value = [chr(by) for by in self.value]
self.value = new_value
self.type = newprop.type
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 10e7f33a595..dc6943f7337 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -46,7 +46,7 @@ def _GetPropertyValue(dtb, node, prop_name):
# Add 12, which is sizeof(struct fdt_property), to get to start of data
offset = prop.GetOffset() + 12
data = dtb.GetContents()[offset:offset + len(prop.value)]
- return prop, [tools.ToChar(x) for x in data]
+ return prop, [chr(x) for x in data]
class TestFdt(unittest.TestCase):
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 7cd58031e78..00c7013924d 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -423,29 +423,6 @@ def GetBytes(byte, size):
"""
return bytes([byte]) * size
-def ToChar(byte):
- """Convert a byte to a character
-
- This is useful because in Python 2 bytes is an alias for str, but in
- Python 3 they are separate types. This function converts an ASCII value to
- a value with the appropriate type in either case.
-
- Args:
- byte: A byte or str value
- """
- return chr(byte) if type(byte) != str else byte
-
-def ToChars(byte_list):
- """Convert a list of bytes to a str/bytes type
-
- Args:
- byte_list: List of ASCII values representing the string
-
- Returns:
- string made by concatenating all the ASCII values
- """
- return ''.join([chr(byte) for byte in byte_list])
-
def ToBytes(string):
"""Convert a str type into a bytes type