@@ -39,10 +39,6 @@ TMP_CREDENTIALS = {}
39
39
PROJECT = "AIRFLOW"
40
40
41
41
# Python 3 compatibility
42
- try :
43
- import urllib2 as urllib
44
- except ImportError :
45
- import urllib .request as urllib
46
42
if sys .version_info [0 ] == 3 :
47
43
raw_input = input
48
44
@@ -52,12 +48,6 @@ except ImportError:
52
48
print ("Could not find the click library. Run 'sudo pip install click' to install." )
53
49
sys .exit (- 1 )
54
50
55
- try :
56
- import keyring
57
- except ImportError :
58
- print ("Could not find the keyring library. Run 'sudo pip install keyring' to install." )
59
- sys .exit (- 1 )
60
-
61
51
try :
62
52
import git
63
53
except ImportError :
@@ -73,11 +63,11 @@ GIT_LOG_FORMAT = '%x1f'.join(GIT_LOG_FORMAT) + '%x1e'
73
63
74
64
75
65
def get_jiras_for_version (version ):
76
- asf_jira = jira .client .JIRA (
77
- {'server' : JIRA_API_BASE })
66
+ asf_jira = jira .client .JIRA ({'server' : JIRA_API_BASE })
78
67
79
- issues = asf_jira .search_issues ('PROJECT={} and fixVersion={}' .format (PROJECT , version ))
80
- return issues
68
+ return asf_jira .search_issues (
69
+ 'PROJECT={} and fixVersion={}' .format (PROJECT , version )
70
+ )
81
71
82
72
83
73
def get_merged_issues (version ):
@@ -97,7 +87,7 @@ def get_merged_issues(version):
97
87
match = issue_re .match (log_item ['subject' ])
98
88
if match :
99
89
issue_id = match .group (1 )
100
- if log_item . has_key ( 'body' ) :
90
+ if 'body' in log_item :
101
91
match = pr_re .match (log_item ['body' ])
102
92
if match :
103
93
log_item ['pull_request' ] = match .group (2 )
@@ -111,6 +101,7 @@ def get_merged_issues(version):
111
101
112
102
return merges
113
103
104
+
114
105
@click .group ()
115
106
def cli ():
116
107
r"""
@@ -127,22 +118,34 @@ def compare(target_version):
127
118
merges = get_merged_issues (target_version )
128
119
issues = get_jiras_for_version (target_version )
129
120
130
- print ("{:<18}|{:<12}||{:<10}||{:<10}|{:<50}|{:<6}|{:<6}|{:<40}"
131
- .format ("ISSUE ID" , "TYPE" , "PRIORITY" ,
132
- "STATUS" , "DESCRIPTION" , "MERGED" ,
133
- "PR" , "COMMIT" ))
121
+ # :<18 says left align, pad to 18
122
+ # :<50.50 truncates after 50 chars
123
+ # !s forces as string - some of the Jira objects have a string method, but
124
+ # Py3 doesn't call by default
125
+ formatstr = "{id:<18}|{typ!s:<12}||{priority!s:<10}||{status!s:<10}|" \
126
+ "{description:<50.50}|{merged:<6}|{pr:<6}|{commit:<40}"
127
+
128
+ print (formatstr .format (
129
+ id = "ISSUE ID" ,
130
+ typ = "TYPE" ,
131
+ priority = "PRIORITY" ,
132
+ status = "STATUS" ,
133
+ description = "DESCRIPTION" ,
134
+ merged = "MERGED" ,
135
+ pr = "PR" ,
136
+ commit = "COMMIT" ))
134
137
135
138
for issue in issues :
136
139
is_merged = issue .key in merges
137
- print ("{:<18}|{:<12}||{:<10}||{:<10}|{:<50}|{:<6}|{:<6}|{:<40}"
138
- . format ( issue .key ,
139
- issue .fields .issuetype ,
140
- issue .fields .priority ,
141
- issue .fields .status ,
142
- issue .fields .summary [: 50 ] ,
143
- is_merged ,
144
- merges [issue .key ]['pull_request' ] if is_merged else "-" ,
145
- merges [issue .key ]['id' ] if is_merged else "-" ))
140
+ print (formatstr . format (
141
+ id = issue .key ,
142
+ typ = issue .fields .issuetype ,
143
+ priority = issue .fields .priority ,
144
+ status = issue .fields .status ,
145
+ description = issue .fields .summary ,
146
+ merged = is_merged ,
147
+ pr = merges [issue .key ]['pull_request' ] if is_merged else "-" ,
148
+ commit = merges [issue .key ]['id' ] if is_merged else "-" ))
146
149
147
150
148
151
if __name__ == "__main__" :
@@ -154,5 +157,3 @@ if __name__ == "__main__":
154
157
cli ()
155
158
except :
156
159
raise
157
-
158
-
0 commit comments