diff options
author | 2019-12-14 07:00:02 -0800 | |
---|---|---|
committer | 2019-12-14 07:00:02 -0800 | |
commit | e5078f6fca9c2d6cf2360cb76c98d24c346c1984 (patch) | |
tree | 3e04ca2959addc30beed0535c64951c2d27e0ee4 | |
parent | pre-receive.gentoo-news: add zeros check (diff) | |
download | githooks-e5078f6fca9c2d6cf2360cb76c98d24c346c1984.tar.gz githooks-e5078f6fca9c2d6cf2360cb76c98d24c346c1984.tar.bz2 githooks-e5078f6fca9c2d6cf2360cb76c98d24c346c1984.zip |
pre-receive.gentoo-news: convert to python3
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rwxr-xr-x | local/git.gentoo.org/pre-receive.gentoo-news | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/local/git.gentoo.org/pre-receive.gentoo-news b/local/git.gentoo.org/pre-receive.gentoo-news index a820507..1b88732 100755 --- a/local/git.gentoo.org/pre-receive.gentoo-news +++ b/local/git.gentoo.org/pre-receive.gentoo-news @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # vim:fileencoding=utf-8 et st=4 sts=4 # Copyright 2012-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 @@ -8,7 +8,12 @@ # Author: Robin H. Johnson <robbat2@gentoo.org> (hook fixups) # Based on work of: Ulrich Müller <ulm@gentoo.org> -import datetime, os, re, subprocess, sys, fileinput +import datetime +import os +import re +import subprocess +import sys +import fileinput PATH_REGEX = re.compile(r''' (?P<year> \d{4}) - (?P<month> \d{2}) - (?P<day> \d{2}) @@ -28,13 +33,13 @@ def main(prog, *argv): # <old-value> SP <new-value> SP <ref-name> LF (oldrev, newrev, refname) = line.split() results += [validate(oldrev, newrev, refname)] - results = filter(lambda x: x != 0, results) + results = [x for x in results if x != 0] if len(results) == 0: return 0 - else: - print '%s: errors in commits' % (prog, ) - print ''.join(map(lambda x: x+"\n", results)) - return 1 + + print('%s: errors in commits' % (prog, )) + print(''.join([x+"\n" for x in results])) + return 1 def validate(oldrev, newrev, refname): # Deletion of a branch means no work to do anyway. @@ -49,7 +54,7 @@ def validate(oldrev, newrev, refname): stdout=subprocess.PIPE) added = proc.communicate()[0].rstrip().split('\n') - for filename in filter(lambda f: len(f) > 0, added): + for filename in [f for f in added if len(f) > 0]: # GLEP 42: name should take the form of: # yyyy-mm-dd-<name>/yyyy-mm-dd-<name>.<lang>.txt[.asc] # where <name>: [a-z0-9+_-]+, <lang>: [a-z][a-z] @@ -68,4 +73,5 @@ def validate(oldrev, newrev, refname): return 0 if __name__ == '__main__': - sys.exit(main(*sys.argv)) + _args = sys.argv[1:] + sys.exit(main(sys.argv[0], *_args)) |