pep8 and change ticket closing message slighlty

This commit is contained in:
Kovid Goyal 2017-02-16 11:35:37 +05:30
parent 796df81638
commit d425d50a90

View File

@ -1,11 +1,16 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import (unicode_literals, division, absolute_import,
print_function)
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import importlib
import json
import re
import socket
import sys
import urllib
from lxml import html
'''
Hook to make the commit command automatically close bugs when the commit
@ -13,9 +18,7 @@ message contains `Fix #number` or `Implement #number`. Also updates the commit
message with the summary of the closed bug.
'''
import re, urllib, importlib, sys, json, socket
from lxml import html
SENDMAIL = ('/home/kovid/work/env', 'pgp_mail')
LAUNCHPAD_BUG = 'https://bugs.launchpad.net/calibre/+bug/%s'
@ -24,6 +27,7 @@ BUG_PAT = r'(Fix|Implement|Fixes|Fixed|Implemented|See)\s+#(\d+)'
socket.setdefaulttimeout(90)
class Bug:
def __init__(self):
@ -55,8 +59,10 @@ class Bug:
def close_bug(self, bug, action):
print('Closing bug #%s' % bug)
suffix = ('The fix will be in the next release. '
'calibre is usually released every Friday.')
suffix = (
'The fix will be in the next release. '
'calibre is usually released every alternate Friday.'
)
action += 'ed'
msg = '%s in branch %s. %s' % (action, 'master', suffix)
msg = msg.replace('Fixesed', 'Fixed')
@ -69,6 +75,7 @@ class Bug:
to = bug + '@bugs.launchpad.net'
sendmail.sendmail(msg, to, 'Fixed in master')
def main():
with open(sys.argv[-1], 'r+b') as f:
raw = f.read().decode('utf-8')
@ -79,6 +86,6 @@ def main():
f.truncate()
f.write(msg.encode('utf-8'))
if __name__ == '__main__':
main()