Skip to content

Commit 8213069

Browse files
committed
PYAPI-31 Common: Code Cleanup
1 parent 016e0e7 commit 8213069

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

atlassian/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, url, username, password):
1212
self.username = username
1313
self.password = password
1414

15-
def log_curl_debug(self, method, path, headers={}, data=None, level=logging.DEBUG):
15+
def log_curl_debug(self, method, path, data=None, headers={}, level=logging.DEBUG):
1616
message = "curl --silent -X {method} -u '{username}':'{password}' -H {headers} {data} '{url}'".format(
1717
method=method,
1818
username=self.username,
@@ -22,9 +22,9 @@ def log_curl_debug(self, method, path, headers={}, data=None, level=logging.DEBU
2222
url='{0}{1}'.format(self.url, path))
2323
log.log(level=level, msg=message)
2424

25-
def request(self, method='GET', path='/',
26-
headers={'Content-Type': 'application/json', 'Accept': 'application/json'}, data=None):
27-
self.log_curl_debug(method, path, headers, data)
25+
def request(self, method='GET', path='/', data=None,
26+
headers={'Content-Type': 'application/json', 'Accept': 'application/json'}):
27+
self.log_curl_debug(method=method, path=path, headers=headers, data=data)
2828
response = requests.request(
2929
method=method,
3030
url='{0}{1}'.format(self.url, path),
@@ -33,24 +33,24 @@ def request(self, method='GET', path='/',
3333
auth=(self.username, self.password),
3434
timeout=60)
3535
if response.status_code != 200:
36-
self.log_curl_debug(method, path, headers, data, level=logging.WARNING)
36+
self.log_curl_debug(method=method, path=path, headers=headers, data=data, level=logging.WARNING)
3737
log.warning(response.json())
3838
response.raise_for_status()
3939
else:
4040
log.debug('Received: {0}'.format(response.json()))
4141
return response
4242

43-
def get(self, path, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}):
44-
return self.request('GET', path, headers).json()
43+
def get(self, path, data=None, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}):
44+
return self.request('GET', path=path, data=data, headers=headers).json()
4545

46-
def post(self, path, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}, data=None):
47-
return self.request('POST', path, headers, data).json()
46+
def post(self, path, data=None, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}):
47+
return self.request('POST', path=path, data=data, headers=headers).json()
4848

49-
def put(self, path, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}, data=None):
50-
return self.request('PUT', path, headers, data).json()
49+
def put(self, path, data=None, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}):
50+
return self.request('PUT', path=path, data=data, headers=headers).json()
5151

52-
def delete(self, path, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}):
53-
return self.request('DELETE', path, headers).json()
52+
def delete(self, path, data=None, headers={'Content-Type': 'application/json', 'Accept': 'application/json'}):
53+
return self.request('DELETE', path=path, data=data, headers=headers).json()
5454

5555

5656
from .confluence import Confluence

atlassian/portfolio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ def get_estimates_dict(self, estimates):
8383

8484
def import_workitem(self, data):
8585
url = '/rest/roadmap/1.0/plans/bulk/{0}/workitems.json'.format(self.plan_id)
86-
return self.post(url, data)
86+
return self.post(url, data=data)
8787

88-
def get_jql_issues(self, jql, limit=500, exclude_linked=True, estimation_method='estimates', epic_fetch_enabled=True,
89-
load_story_points=True):
88+
def get_jql_issues(self, jql, limit=500, exclude_linked=True, estimation_method='estimates',
89+
epic_fetch_enabled=True, load_story_points=True):
9090
url = '/rest/roadmap/1.0/system/import.json'
9191
data = {'planId': str(self.plan_id),
9292
'query': jql,
@@ -95,4 +95,4 @@ def get_jql_issues(self, jql, limit=500, exclude_linked=True, estimation_method=
9595
'maxResults': limit,
9696
'estimationMethod': estimation_method,
9797
'loadStoryPoints': load_story_points}
98-
self.post(url, data=data)
98+
return self.post(url, data=data)['data']['items']

setup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from setuptools import find_packages
23
from setuptools import setup
34

45

@@ -9,15 +10,15 @@
910
description='Python Atlassian REST API Wrapper',
1011
long_description='Python Atlassian REST API Wrapper',
1112
license='Apache License 2.0',
12-
version='0.9.0',
13+
version='0.9.1',
1314
download_url='https://github.com/MattAgile/atlassian-python-api',
1415

1516
author='Matt Harasymczuk',
1617
author_email='code@mattagile.com',
1718
url='http://mattagile.com/',
1819

19-
packages=['atlassian'],
20-
package_data={'': ['LICENSE', 'README'], 'atlassian': ['*.py']},
20+
packages=find_packages(),
21+
package_data={'': ['LICENSE', 'README.rst'], 'atlassian': ['*.py']},
2122
package_dir={'atlassian': 'atlassian'},
2223
include_package_data=True,
2324

@@ -47,7 +48,6 @@
4748
'Topic :: Internet :: WWW/HTTP',
4849
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
4950
'Topic :: Software Development :: Libraries :: Python Modules',
50-
'Topic :: Software Development :: Libraries :: Application Frameworks',
51-
],
51+
'Topic :: Software Development :: Libraries :: Application Frameworks']
5252
)
5353

0 commit comments

Comments
 (0)