-
Notifications
You must be signed in to change notification settings - Fork 2
/
what_on_bz.py
executable file
·60 lines (46 loc) · 1.57 KB
/
what_on_bz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python2
from argparse import ArgumentParser
from datetime import datetime, timedelta
import urllib
URL = 'https://bugzilla.mozilla.org/buglist.cgi'
LAST_WEEK_PARAMS = {
'query_format': 'advanced',
'chfield': 'bug_status',
'bug_status': 'RESOLVED',
'chfieldvalue': 'RESOLVED',
'chfieldto': 'Now',
'emailtype1': 'equals',
'emailassigned_to1': '1',
}
# TODO: Declare NEW or ASSIGNED bug status.
PRESENT_PARAMS = {
'query_format': 'advanced',
'emailtype1': 'equals',
'emailassigned_to1': '1',
}
def parse_arguments():
parser = ArgumentParser()
parser.add_argument('email', help='email address of changes')
return parser.parse_args()
def get_date_str(daydelta):
"""Returns YYYY-MM-DD"""
seven_days_ago = (datetime.now() - timedelta(days=daydelta)).strftime('%Y-%m-%d')
return str(seven_days_ago)
def get_url_for_params(static_params, dynamic_params):
out_params = static_params.copy()
out_params.update(dynamic_params)
return URL + '?' + urllib.urlencode(out_params)
args = parse_arguments()
dynamic_params = {
'email1': args.email,
'chfieldfrom': get_date_str(7)
}
print('PAST: ' + get_url_for_params(LAST_WEEK_PARAMS, dynamic_params))
print('') # newline.
print('PRESENT: ' + get_url_for_params(PRESENT_PARAMS, dynamic_params))
print('') # newline
dynamic_params['chfieldfrom'] = get_date_str(2)
print('MIDWEEK PAST: ' + get_url_for_params(LAST_WEEK_PARAMS, dynamic_params))
print('') # newline.
print('MIDWEEK PRESENT: ' + get_url_for_params(PRESENT_PARAMS, dynamic_params))
print('') # newline