u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
To: Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de,
	Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Subject: [PATCH 1/1] scripts/mailmapper: enable running with Python 3
Date: Thu, 16 Sep 2021 10:59:12 +0200	[thread overview]
Message-ID: <20210916085912.52853-1-heinrich.schuchardt@canonical.com> (raw)

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


             reply	other threads:[~2021-09-16  8:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16  8:59 Heinrich Schuchardt [this message]
2021-09-24 18:29 ` [PATCH 1/1] scripts/mailmapper: enable running with Python 3 Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210916085912.52853-1-heinrich.schuchardt@canonical.com \
    --to=heinrich.schuchardt@canonical.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).