* [PATCH 1/1] scripts/mailmapper: enable running with Python 3
@ 2021-09-16 8:59 Heinrich Schuchardt
2021-09-24 18:29 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2021-09-16 8:59 UTC (permalink / raw)
To: Tom Rini; +Cc: u-boot, Heinrich Schuchardt
Our mailmapper script required Python 2 which is no longer maintained.
A main difference when converting to Python 3 is that byte strings are not
character strings. So add conversion and skip over conversion errors.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
scripts/mailmapper | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/scripts/mailmapper b/scripts/mailmapper
index 2e2d7faff5..0e744ec1a0 100755
--- a/scripts/mailmapper
+++ b/scripts/mailmapper
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (C) 2014, Masahiro Yamada <yamada.m@jp.panasonic.com>
@@ -89,9 +89,10 @@ output = {}
for line in shortlog.splitlines():
# tmp, mail = line.rsplit(None, 1) is not safe
# because weird email addresses might include whitespaces
- tmp, mail = line.split('<')
- mail = '<' + mail.rstrip()
try:
+ line = line.decode("utf-8")
+ tmp, mail = line.split('<')
+ mail = '<' + mail.rstrip()
_, name = tmp.rstrip().split(None, 1)
except ValueError:
# author name is empty
@@ -100,8 +101,11 @@ for line in shortlog.splitlines():
# another name for the same email address
prev_name = mail_vs_name[mail]
# Take the name with more commits
- major_name = sorted([prev_name, name],
- key=lambda x: commits_per_name[x] if x else 0)[1]
+ try:
+ major_name = sorted([prev_name, name],
+ key=lambda x: commits_per_name[x] if x else 0)[1]
+ except:
+ continue
mail_vs_name[mail] = major_name
if commits_per_name[major_name] > MIN_COMMITS:
output[mail] = major_name
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] scripts/mailmapper: enable running with Python 3
2021-09-16 8:59 [PATCH 1/1] scripts/mailmapper: enable running with Python 3 Heinrich Schuchardt
@ 2021-09-24 18:29 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2021-09-24 18:29 UTC (permalink / raw)
To: Heinrich Schuchardt; +Cc: u-boot
[-- Attachment #1: Type: text/plain, Size: 424 bytes --]
On Thu, Sep 16, 2021 at 10:59:12AM +0200, Heinrich Schuchardt wrote:
> Our mailmapper script required Python 2 which is no longer maintained.
> A main difference when converting to Python 3 is that byte strings are not
> character strings. So add conversion and skip over conversion errors.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-24 18:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 8:59 [PATCH 1/1] scripts/mailmapper: enable running with Python 3 Heinrich Schuchardt
2021-09-24 18:29 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).