Completed
Push — master ( 48b27b...9784f9 )
by Tomaz
22s
created

OpscenterAction.urljoin_sane()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 5
rs 9.4285
1
from urlparse import urljoin
2
3
from st2actions.runners.pythonrunner import Action
4
5
6
class OpscenterAction(Action):
7
8
    def __init__(self, config=None):
9
        super(OpscenterAction, self).__init__(config=config)
10
        self.cluster_id = self.config.get('cluster_id', None)
11
        self.base_url = self.config.get('opscenter_base_url', None)
12
13
    def _get_auth_creds(self):
14
        pass
15
16
    def _get_full_url(self, url_parts):
17
        base = self.base_url
18
19
        if not url_parts:
20
            return base
21
22
        parts = [base]
23
        parts.extend(url_parts)
24
25
        def urljoin_sane(url1, url2):
26
            if url1.endswith('/'):
27
                return urljoin(url1, url2)
28
            else:
29
                return urljoin(url1 + '/', url2)
30
31
        return reduce(urljoin_sane, parts)
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'reduce'
Loading history...
32