Skip to content

Commit 79d2406

Browse files
committed
[AIRFLOW-XXX] Fix python3 and flake8 errors in dev/airflow-jira
This is a script that checks if the Jira's marked as fixed in a release are actually merged in - getting this working is helpful to me in preparing 1.10.1
1 parent 25bb0df commit 79d2406

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

dev/airflow-jira

+31-30
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ TMP_CREDENTIALS = {}
3939
PROJECT = "AIRFLOW"
4040

4141
# Python 3 compatibility
42-
try:
43-
import urllib2 as urllib
44-
except ImportError:
45-
import urllib.request as urllib
4642
if sys.version_info[0] == 3:
4743
raw_input = input
4844

@@ -52,12 +48,6 @@ except ImportError:
5248
print("Could not find the click library. Run 'sudo pip install click' to install.")
5349
sys.exit(-1)
5450

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-
6151
try:
6252
import git
6353
except ImportError:
@@ -73,11 +63,11 @@ GIT_LOG_FORMAT = '%x1f'.join(GIT_LOG_FORMAT) + '%x1e'
7363

7464

7565
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})
7867

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+
)
8171

8272

8373
def get_merged_issues(version):
@@ -97,7 +87,7 @@ def get_merged_issues(version):
9787
match = issue_re.match(log_item['subject'])
9888
if match:
9989
issue_id = match.group(1)
100-
if log_item.has_key('body'):
90+
if 'body' in log_item:
10191
match = pr_re.match(log_item['body'])
10292
if match:
10393
log_item['pull_request'] = match.group(2)
@@ -111,6 +101,7 @@ def get_merged_issues(version):
111101

112102
return merges
113103

104+
114105
@click.group()
115106
def cli():
116107
r"""
@@ -127,22 +118,34 @@ def compare(target_version):
127118
merges = get_merged_issues(target_version)
128119
issues = get_jiras_for_version(target_version)
129120

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"))
134137

135138
for issue in issues:
136139
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 "-"))
146149

147150

148151
if __name__ == "__main__":
@@ -154,5 +157,3 @@ if __name__ == "__main__":
154157
cli()
155158
except:
156159
raise
157-
158-

0 commit comments

Comments
 (0)