mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
scripts: rfr: convert to python 3
Python 2 is no longer maintained. Use python 3 to be up to date and to make it easier to work with utf-8 text. Change-Id: I341f558730caaa9106e8eef4304d67af747c7373 Signed-off-by: Konsta Hölttä <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2318760 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
Alex Waterman
parent
0cd5502935
commit
f9e9e41c7b
14
scripts/rfr
14
scripts/rfr
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/env python3
|
||||||
#
|
#
|
||||||
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All Rights Reserved.
|
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All Rights Reserved.
|
||||||
#
|
#
|
||||||
@@ -239,7 +239,7 @@ def get_user_message(start_msg):
|
|||||||
editor = os.environ.get('EDITOR', 'vim')
|
editor = os.environ.get('EDITOR', 'vim')
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile(suffix=".tmp") as filp:
|
with tempfile.NamedTemporaryFile(suffix=".tmp") as filp:
|
||||||
filp.write(start_msg)
|
filp.write(start_msg.encode('utf-8'))
|
||||||
filp.flush()
|
filp.flush()
|
||||||
|
|
||||||
edit_cmd = editor + ' ' + filp.name
|
edit_cmd = editor + ' ' + filp.name
|
||||||
@@ -253,7 +253,7 @@ def get_user_message(start_msg):
|
|||||||
filp.seek(0)
|
filp.seek(0)
|
||||||
lines = filp.readlines()
|
lines = filp.readlines()
|
||||||
|
|
||||||
return ''.join(filter(lambda l: not l.startswith('#'), lines))
|
return ''.join([l.decode('utf-8') for l in lines if not l.startswith(b'#')])
|
||||||
|
|
||||||
def indent_lines(text, ind):
|
def indent_lines(text, ind):
|
||||||
"""
|
"""
|
||||||
@@ -300,7 +300,7 @@ Thanks!
|
|||||||
# note: x['deletions'] is negative (or zero)
|
# note: x['deletions'] is negative (or zero)
|
||||||
files = c['currentPatchSet']['files']
|
files = c['currentPatchSet']['files']
|
||||||
file_widths = [
|
file_widths = [
|
||||||
len(x['file']) for x in files if x['file'] != u'/COMMIT_MSG']
|
len(x['file']) for x in files if x['file'] != '/COMMIT_MSG']
|
||||||
|
|
||||||
# For merge commits there are no files in the commit itself. So this
|
# For merge commits there are no files in the commit itself. So this
|
||||||
# causes the below max() operation to choke. Given that there are no
|
# causes the below max() operation to choke. Given that there are no
|
||||||
@@ -316,7 +316,7 @@ Thanks!
|
|||||||
sum=x['insertions'] - x['deletions'],
|
sum=x['insertions'] - x['deletions'],
|
||||||
adds=x['insertions'],
|
adds=x['insertions'],
|
||||||
dels=-x['deletions'])
|
dels=-x['deletions'])
|
||||||
for x in files if x['file'] != u'/COMMIT_MSG'
|
for x in files if x['file'] != '/COMMIT_MSG'
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
files_changed_desc = ''
|
files_changed_desc = ''
|
||||||
@@ -407,7 +407,7 @@ def email_commits(commits_info, sender, subject, args):
|
|||||||
text = get_user_message(body)
|
text = get_user_message(body)
|
||||||
|
|
||||||
if not text or text.strip() == '':
|
if not text or text.strip() == '':
|
||||||
print 'Empty user message: aborting!'
|
print('Empty user message: aborting!')
|
||||||
return
|
return
|
||||||
|
|
||||||
msg = MIMEText(text)
|
msg = MIMEText(text)
|
||||||
@@ -458,7 +458,7 @@ def main():
|
|||||||
|
|
||||||
# Oops: no commits?
|
# Oops: no commits?
|
||||||
if not arg_parser.commits or len(arg_parser.commits) == 0:
|
if not arg_parser.commits or len(arg_parser.commits) == 0:
|
||||||
print 'No commits!'
|
print('No commits!')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
# Builds a dictionary of Gerrit Change-Ids. From the Change-Ids we can then
|
# Builds a dictionary of Gerrit Change-Ids. From the Change-Ids we can then
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ def __rfr_load_ab(path, silent=False):
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
success = False
|
success = False
|
||||||
if not silent:
|
if not silent:
|
||||||
print 'Error: %s' % err
|
print('Error: %s' % err)
|
||||||
|
|
||||||
# It's not a very helpful error message I suppose. Eh. We will get more
|
# It's not a very helpful error message I suppose. Eh. We will get more
|
||||||
# detail from the __rfr_parse_addrbook() call itself.
|
# detail from the __rfr_parse_addrbook() call itself.
|
||||||
@@ -151,7 +151,7 @@ def rfr_ab_lookup_single(addr):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# If there's no address book, just pass the addr through.
|
# If there's no address book, just pass the addr through.
|
||||||
if len(__rfr_address_book.keys()) == 0:
|
if len(list(__rfr_address_book.keys())) == 0:
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
lc_addr = addr.lower()
|
lc_addr = addr.lower()
|
||||||
@@ -159,7 +159,7 @@ def rfr_ab_lookup_single(addr):
|
|||||||
if lc_addr in __rfr_address_book:
|
if lc_addr in __rfr_address_book:
|
||||||
return __rfr_address_book[lc_addr]
|
return __rfr_address_book[lc_addr]
|
||||||
|
|
||||||
if lc_addr in __rfr_address_book.values():
|
if lc_addr in list(__rfr_address_book.values()):
|
||||||
# Return the orignal, un-lowercased.
|
# Return the orignal, un-lowercased.
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user