Migrate git hooks to py3

This commit is contained in:
Kovid Goyal 2018-06-12 18:01:55 +05:30
parent c82ee257dd
commit e8fdd7a83c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 14 deletions

View File

@ -1,7 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# vim:fileencoding=utf-8 # vim:fileencoding=utf-8
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>' __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
@ -19,9 +17,9 @@ base = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
os.chdir(base) os.chdir(base)
if flags == '1': # A branch checkout if flags == '1': # A branch checkout
prev_branch, cur_branch = map(get_branch_name, (prev_rev, current_rev)) prev_branch, cur_branch = list(map(get_branch_name, (prev_rev, current_rev)))
subprocess.check_call([sys.executable, 'setup.py', 'gui', '--summary']) subprocess.check_call(['python2', 'setup.py', 'gui', '--summary'])
# Remove .pyc files as some of them might have been orphaned # Remove .pyc files as some of them might have been orphaned
for dirpath, dirnames, filenames in os.walk('.'): for dirpath, dirnames, filenames in os.walk('.'):

View File

@ -1,7 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# vim:fileencoding=utf-8 # vim:fileencoding=utf-8
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>' __copyright__ = '2014, Kovid Goyal <kovid at kovidgoyal.net>'

View File

@ -1,14 +1,16 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# vim:fileencoding=utf-8 # vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net> # License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
import importlib import importlib
import json import json
import re import re
import socket import socket
import sys import sys
import urllib import urllib.error
import urllib.parse
import urllib.request
from lxml import html from lxml import html
@ -41,14 +43,14 @@ class Bug:
self.seen.add(bug) self.seen.add(bug)
if int(bug) > 100000: # Launchpad bug if int(bug) > 100000: # Launchpad bug
raw = urllib.urlopen(LAUNCHPAD_BUG % bug).read() raw = urllib.request.urlopen(LAUNCHPAD_BUG % bug).read()
try: try:
h1 = html.fromstring(raw).xpath('//h1[@id="edit-title"]')[0] h1 = html.fromstring(raw).xpath('//h1[@id="edit-title"]')[0]
summary = html.tostring(h1, method='text', encoding=unicode).strip() summary = html.tostring(h1, method='text', encoding=str).strip()
except: except:
summary = 'Private bug' summary = 'Private bug'
else: else:
summary = json.loads(urllib.urlopen(GITHUB_BUG % bug).read())['title'] summary = json.loads(urllib.request.urlopen(GITHUB_BUG % bug).read())['title']
if summary: if summary:
print('Working on bug:', summary) print('Working on bug:', summary)
if int(bug) > 100000 and action != 'See': if int(bug) > 100000 and action != 'See':