Skip to content

Commit

Permalink
Port to Python 3
Browse files Browse the repository at this point in the history
Use latest requests module
Change base image to python3
  • Loading branch information
fuzzyhandle committed Feb 5, 2020
1 parent 833d27f commit cf4eb0c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:2.7-alpine
FROM python:3-alpine

ADD jira-dependency-graph.py /jira/
ADD requirements.txt /jira/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Example output

Requirements:
=============
* Python 2.6+
* Python 3+
* [requests](http://docs.python-requests.org/en/master/)

Or
Expand Down
15 changes: 8 additions & 7 deletions jira-dependency-graph.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/usr/bin/env python

from __future__ import print_function


import argparse
import getpass
import sys
import textwrap

import requests
from functools import reduce

GOOGLE_CHART_URL = 'http://chart.apis.google.com/chart'
MAX_SUMMARY_LENGTH = 30
Expand Down Expand Up @@ -95,9 +96,9 @@ def create_node_text(issue_key, fields, islink=True):
return '"{}\\n({})" [href="{}", fillcolor="{}", style=filled]'.format(issue_key, summary.encode('utf-8'), jira.get_issue_uri(issue_key), get_status_color(status))

def process_link(fields, issue_key, link):
if link.has_key('outwardIssue'):
if 'outwardIssue' in link:
direction = 'outward'
elif link.has_key('inwardIssue'):
elif 'inwardIssue' in link:
direction = 'inward'
else:
return
Expand Down Expand Up @@ -174,7 +175,7 @@ def walk(issue_key, graph):
create_node_text(subtask_key, subtask['fields']))
graph.append(node)
children.append(subtask_key)
if fields.has_key('subtasks') and not ignore_subtasks:
if 'subtasks' in fields and not ignore_subtasks:
for subtask in fields['subtasks']:
subtask_key = get_key(subtask)
log(issue_key + ' => has subtask => ' + subtask_key)
Expand All @@ -184,7 +185,7 @@ def walk(issue_key, graph):
graph.append(node)
children.append(subtask_key)

if fields.has_key('issuelinks'):
if 'issuelinks' in fields:
for other_link in fields['issuelinks']:
result = process_link(fields, issue_key, other_link)
if result is not None:
Expand Down Expand Up @@ -250,7 +251,7 @@ def filter_duplicates(lst):
# Enumerate the list to restore order lately; reduce the sorted list; restore order
def append_unique(acc, item):
return acc if acc[-1][1] == item[1] else acc.append(item) or acc
srt_enum = sorted(enumerate(lst), key=lambda (i, val): val)
srt_enum = sorted(enumerate(lst), key=lambda i_val: i_val[1])
return [item[1] for item in sorted(reduce(append_unique, srt_enum, [srt_enum[0]]))]


Expand All @@ -263,7 +264,7 @@ def main():
else:
# Basic Auth is usually easier for scripts like this to deal with than Cookies.
user = options.user if options.user is not None \
else raw_input('Username: ')
else input('Username: ')
password = options.password if options.password is not None \
else getpass.getpass('Password: ')
auth = (user, password)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
requests ~= 2.12
requests ~= 2.22

0 comments on commit cf4eb0c

Please sign in to comment.