Skip to content

Commit 3280ac4

Browse files
Gonchik TsymzhitovGonchik Tsymzhitov
authored andcommitted
Change returns althrough get instead of brackets
1 parent 29e6c65 commit 3280ac4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

atlassian/confluence.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_page_child_by_type(self, page_id, type='page', start=None, limit=None):
4646
url = 'rest/api/content/{page_id}/child/{type}'.format(page_id=page_id, type=type)
4747
log.info(url)
4848
try:
49-
return self.get(url, params=params).get('results')
49+
return (self.get(url, params=params) or {}).get('results')
5050
except IndexError as e:
5151
log.error(e)
5252
return None
@@ -66,7 +66,7 @@ def get_page_space(self, page_id):
6666
:param page_id: content ID
6767
:return:
6868
"""
69-
return self.get_page_by_id(page_id, expand='space')['space']['key']
69+
return ((self.get_page_by_id(page_id, expand='space') or {}).get('space') or {}).get('key')
7070

7171
def get_page_by_title(self, space, title, start=None, limit=None):
7272
"""
@@ -91,7 +91,7 @@ def get_page_by_title(self, space, title, start=None, limit=None):
9191
params['title'] = str(title)
9292
url = 'rest/api/content'
9393
try:
94-
return self.get(url, params=params).get('results')[0]
94+
return (self.get(url, params=params) or {}).get('results')[0]
9595
except IndexError as e:
9696
log.error(e)
9797
return None
@@ -159,7 +159,7 @@ def get_all_pages_from_space(self, space, start=0, limit=500):
159159
url = 'rest/api/content?spaceKey={space}&limit={limit}&start={start}'.format(space=space,
160160
limit=limit,
161161
start=start)
162-
return self.get(url)['results']
162+
return (self.get(url) or {}).get('results')
163163

164164
def get_all_pages_from_space_trash(self, space, start=0, limit=500, status='trashed'):
165165
"""
@@ -460,7 +460,7 @@ def get_page_ancestors(self, page_id):
460460
:return: get properties
461461
"""
462462
url = 'rest/api/content/{page_id}?expand=ancestors'.format(page_id=page_id)
463-
return self.get(path=url).get('ancestors')
463+
return (self.get(path=url) or {}).get('ancestors')
464464

465465
def clean_all_caches(self):
466466
""" Clean all caches from cache management"""

atlassian/jira.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ def issue_create_or_update(self, fields):
292292
def get_issue_transitions(self, issue_key):
293293
url = 'rest/api/2/issue/{issue_key}?expand=transitions.fields&fields=status'.format(issue_key=issue_key)
294294
return [{'name': transition['name'], 'id': int(transition['id']), 'to': transition['to']['name']}
295-
for transition in self.get(url)['transitions']]
295+
for transition in (self.get(url) or {}).get('transitions')]
296296

297297
def get_status_id_from_name(self, status_name):
298298
url = 'rest/api/2/status/{name}'.format(name=status_name)
299-
return int(self.get(url)['id'])
299+
return int((self.get(url) or {}).get('id'))
300300

301301
def get_transition_id_to_status_name(self, issue_key, status_name):
302302
for transition in self.get_issue_transitions(issue_key):
@@ -313,7 +313,7 @@ def set_issue_status(self, issue_key, status_name):
313313

314314
def get_issue_status(self, issue_key):
315315
url = 'rest/api/2/issue/{issue_key}?fields=status'.format(issue_key=issue_key)
316-
return self.get(url)['fields']['status']['name']
316+
return (self.get(url) or {}).get('fields').get('status').get('name')
317317

318318
def component(self, component_id):
319319
return self.get('rest/api/2/component/{component_id}'.format(component_id=component_id))

0 commit comments

Comments
 (0)