summaryrefslogtreecommitdiffstats
path: root/tools/patman
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-11-08 20:36:18 -0700
committerSimon Glass <sjg@chromium.org>2020-12-13 07:58:17 -0700
commitfc0056e8d5ab62adc17455c99864d9a974633a46 (patch)
treebdb79ac7a36cc03636735f863c1ee53c9e36f488 /tools/patman
parent5ea9dccf02eb26d146dbc1fdb3106135612820ae (diff)
downloadu-boot-fc0056e8d5ab62adc17455c99864d9a974633a46.tar.gz
u-boot-fc0056e8d5ab62adc17455c99864d9a974633a46.tar.xz
u-boot-fc0056e8d5ab62adc17455c99864d9a974633a46.zip
patman: Drop unicode helper functions
We don't need these now that everything uses Python 3. Remove them and the extra code in GetBytes() and ToBytes() too. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman')
-rw-r--r--tools/patman/func_test.py13
-rw-r--r--tools/patman/gitutil.py3
-rw-r--r--tools/patman/series.py4
-rw-r--r--tools/patman/settings.py5
-rw-r--r--tools/patman/tools.py47
5 files changed, 13 insertions, 59 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 74a144dc2d..e7db36a85c 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -237,27 +237,26 @@ class TestFunctional(unittest.TestCase):
if 'Cc:' not in prev:
break
self.assertEqual('To: u-boot@lists.denx.de', prev)
- self.assertEqual('Cc: %s' % tools.FromUnicode(stefan), next(lines))
+ self.assertEqual('Cc: %s' % stefan, next(lines))
self.assertEqual('Version: 3', next(lines))
self.assertEqual('Prefix:\t RFC', next(lines))
self.assertEqual('Cover: 4 lines', next(lines))
self.assertEqual(' Cc: %s' % self.fred, next(lines))
- self.assertEqual(' Cc: %s' % tools.FromUnicode(self.leb),
+ self.assertEqual(' Cc: %s' % self.leb,
next(lines))
- self.assertEqual(' Cc: %s' % tools.FromUnicode(mel), next(lines))
+ self.assertEqual(' Cc: %s' % mel, next(lines))
self.assertEqual(' Cc: %s' % rick, next(lines))
expected = ('Git command: git send-email --annotate '
'--in-reply-to="%s" --to "u-boot@lists.denx.de" '
'--cc "%s" --cc-cmd "%s send --cc-cmd %s" %s %s'
% (in_reply_to, stefan, sys.argv[0], cc_file, cover_fname,
' '.join(args)))
- self.assertEqual(expected, tools.ToUnicode(next(lines)))
+ self.assertEqual(expected, next(lines))
- self.assertEqual(('%s %s\0%s' % (args[0], rick, stefan)),
- tools.ToUnicode(cc_lines[0]))
+ self.assertEqual(('%s %s\0%s' % (args[0], rick, stefan)), cc_lines[0])
self.assertEqual(
'%s %s\0%s\0%s\0%s' % (args[1], self.fred, self.leb, rick, stefan),
- tools.ToUnicode(cc_lines[1]))
+ cc_lines[1])
expected = '''
This is a test of how the cover
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index 31fb3b2829..6c4d2417a0 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -383,7 +383,6 @@ def BuildEmailList(in_list, tag=None, alias=None, raise_on_error=True):
raw += LookupEmail(item, alias, raise_on_error=raise_on_error)
result = []
for item in raw:
- item = tools.FromUnicode(item)
if not item in result:
result.append(item)
if tag:
@@ -494,7 +493,7 @@ send --cc-cmd cc-fname" cover p1 p2'
if smtp_server:
cmd.append('--smtp-server=%s' % smtp_server)
if in_reply_to:
- cmd.append('--in-reply-to="%s"' % tools.FromUnicode(in_reply_to))
+ cmd.append('--in-reply-to="%s"' % in_reply_to)
if thread:
cmd.append('--thread')
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 1d92bdb910..a6746e87c4 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -272,7 +272,6 @@ class Series(dict):
for x in set(cc) & set(settings.bounces):
print(col.Color(col.YELLOW, 'Skipping "%s"' % x))
cc = set(cc) - set(settings.bounces)
- cc = [tools.FromUnicode(m) for m in cc]
if limit is not None:
cc = cc[:limit]
all_ccs += cc
@@ -281,11 +280,10 @@ class Series(dict):
if cover_fname:
cover_cc = gitutil.BuildEmailList(self.get('cover_cc', ''))
- cover_cc = [tools.FromUnicode(m) for m in cover_cc]
cover_cc = list(set(cover_cc + all_ccs))
if limit is not None:
cover_cc = cover_cc[:limit]
- cc_list = '\0'.join([tools.ToUnicode(x) for x in sorted(cover_cc)])
+ cc_list = '\0'.join([x for x in sorted(cover_cc)])
print(cover_fname, cc_list, file=fd)
fd.close()
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 8c10eab264..60cdc1c102 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -112,7 +112,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
val = ConfigParser.SafeConfigParser.get(
self, section, option, *args, **kwargs
)
- return tools.ToUnicode(val)
+ return val
def items(self, section, *args, **kwargs):
"""Extend SafeConfigParser to add project_section to section.
@@ -147,8 +147,7 @@ class _ProjectConfigParser(ConfigParser.SafeConfigParser):
item_dict = dict(top_items)
item_dict.update(project_items)
- return {(tools.ToUnicode(item), tools.ToUnicode(val))
- for item, val in item_dict.items()}
+ return {(item, val) for item, val in item_dict.items()}
def ReadGitAliases(fname):
"""Read a git alias file. This is in the form used by git:
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index bbb157da87..55ba1e9c98 100644
--- a/tools/patman/tools.py
+++ b/tools/patman/tools.py
@@ -414,8 +414,6 @@ def WriteFile(fname, data, binary=True):
def GetBytes(byte, size):
"""Get a string of bytes of a given size
- This handles the unfortunate different between Python 2 and Python 2.
-
Args:
byte: Numeric byte value to use
size: Size of bytes/string to return
@@ -423,43 +421,7 @@ def GetBytes(byte, size):
Returns:
A bytes type with 'byte' repeated 'size' times
"""
- if sys.version_info[0] >= 3:
- data = bytes([byte]) * size
- else:
- data = chr(byte) * size
- return data
-
-def ToUnicode(val):
- """Make sure a value is a unicode string
-
- This allows some amount of compatibility between Python 2 and Python3. For
- the former, it returns a unicode object.
-
- Args:
- val: string or unicode object
-
- Returns:
- unicode version of val
- """
- if sys.version_info[0] >= 3:
- return val
- return val if isinstance(val, unicode) else val.decode('utf-8')
-
-def FromUnicode(val):
- """Make sure a value is a non-unicode string
-
- This allows some amount of compatibility between Python 2 and Python3. For
- the former, it converts a unicode object to a string.
-
- Args:
- val: string or unicode object
-
- Returns:
- non-unicode version of val
- """
- if sys.version_info[0] >= 3:
- return val
- return val if isinstance(val, str) else val.encode('utf-8')
+ return bytes([byte]) * size
def ToByte(ch):
"""Convert a character to an ASCII value
@@ -506,12 +468,9 @@ def ToBytes(string):
string: string to convert
Returns:
- Python 3: A bytes type
- Python 2: A string type
+ A bytes type
"""
- if sys.version_info[0] >= 3:
- return string.encode('utf-8')
- return string
+ return string.encode('utf-8')
def ToString(bval):
"""Convert a bytes type into a str type