Skip to content

Commit 09ff44a

Browse files
authored
[RestClient] Cleanup base class and fix init order in derived class (#584)
* [RestClient] Cleanup base class and fix init order in derived class * Add review remark -> add *args.
1 parent f3d7f2a commit 09ff44a

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

atlassian/bitbucket.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
class Bitbucket(AtlassianRestAPI):
1111
bulk_headers = {"Content-Type": "application/vnd.atl.bitbucket.bulk+json"}
1212

13-
def __init__(self, *args, **kwargs):
14-
super(Bitbucket, self).__init__(*args, **kwargs)
15-
url = kwargs.pop('url', False)
16-
if url and 'bitbucket.org' in url:
17-
self.cloud = True
13+
def __init__(self, url, *args, **kwargs):
14+
if (not 'cloud' in kwargs
15+
and ('bitbucket.org' in url) ):
16+
kwargs['cloud'] = True
17+
super(Bitbucket, self).__init__(url, *args, **kwargs)
1818

1919
def project_list(self, limit=None):
2020
"""

atlassian/confluence.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ class Confluence(AtlassianRestAPI):
3030
".svg": "image/svg+xml"
3131
}
3232

33+
def __init__(self, url, *args, **kwargs):
34+
if (('atlassian.net' in url or 'jira.com' in url)
35+
and ('/wiki' not in url) ):
36+
url = AtlassianRestAPI.url_joiner(url, '/wiki')
37+
if not 'cloud' in kwargs:
38+
kwargs['cloud'] = True
39+
super(Confluence, self).__init__(url, *args, **kwargs)
40+
41+
3342
@staticmethod
3443
def _create_body(body, representation):
3544
if representation not in ['editor', 'export_view', 'view', 'storage', 'wiki']:

atlassian/rest_client.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ class AtlassianRestAPI(object):
2626
def __init__(self, url, username=None, password=None, timeout=60, api_root='rest/api', api_version='latest',
2727
verify_ssl=True, session=None, oauth=None, cookies=None, advanced_mode=None, kerberos=None,
2828
cloud=False, proxies=None):
29-
if ('atlassian.net' in url or 'jira.com' in url) \
30-
and '/wiki' not in url \
31-
and self.__class__.__name__ in 'Confluence':
32-
url = self.url_joiner(url, '/wiki')
3329
self.url = url
3430
self.username = username
3531
self.password = password

0 commit comments

Comments
 (0)