GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Pull Request — master (#27)
by
unknown
01:28
created

b2blaze.models.bucket_list   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Test Coverage

Coverage 21.15%

Importance

Changes 0
Metric Value
eloc 55
dl 0
loc 102
ccs 11
cts 52
cp 0.2115
rs 10
c 0
b 0
f 0
wmc 15

5 Methods

Rating   Name   Duplication   Size   Complexity  
A B2Buckets.all() 0 6 1
B B2Buckets._update_bucket_list() 0 25 5
B B2Buckets.create() 0 28 6
A B2Buckets.__init__() 0 10 1
A B2Buckets.get() 0 12 2
1
"""
2
Copyright George Sibble 2018
3
"""
4
5 1
from ..b2_exceptions import B2Exception, B2InvalidBucketName, B2InvalidBucketConfiguration
6 1
from .bucket import B2Bucket
7 1
from ..api import API
8
9
10 1
class B2Buckets(object):
0 ignored issues
show
Documentation introduced by
Empty class docstring
Loading history...
11
    """
12
13
    """
14 1
    public = 'allPublic'
15 1
    private = 'allPrivate'
16
17 1
    def __init__(self, connector, single_bucket=None):
18
        """
19
20
        :param connector:
21
        :param str single_bucket: If any, the ID of the single bucket that we can list.
22
        """
23
        self.connector = connector
24
        self._single_bucket = single_bucket
25
        self._buckets_by_name = {}
26
        self._buckets_by_id = {}
27
28 1
    def all(self):
29
        """
30
31
        :return:
32
        """
33
        return self._update_bucket_list(retrieve=True)
34
35 1
    def _update_bucket_list(self, retrieve=False):
36
        """
37
38
        :param retrieve:
39
        :return:
40
        """
41
        path = API.list_all_buckets
42
        params = {}
43
        if self._single_bucket:
44
            params['bucketId'] = self._single_bucket
45
        response = self.connector.make_request(path=path, method='post', account_id_required=True, params=params)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (113/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
46
        if response.status_code == 200:
47
            response_json = response.json()
48
            buckets = []
49
            self._buckets_by_name = {}
50
            self._buckets_by_id = {}
51
            for bucket_json in response_json['buckets']:
52
                new_bucket = B2Bucket(connector=self.connector, parent_list=self, **bucket_json)
53
                buckets.append(new_bucket)
54
                self._buckets_by_name[bucket_json['bucketName']] = new_bucket
55
                self._buckets_by_id[bucket_json['bucketId']] = new_bucket
56
            if retrieve:
57
                return buckets
58
        else:
59
            raise B2Exception.parse(response)
60
61 1
    def get(self, bucket_name=None, bucket_id=None):
62
        """
63
64
        :param bucket_name:
65
        :param bucket_id:
66
        :return:
67
        """
68
        self._update_bucket_list()
69
        if bucket_name is not None:
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
70
            return self._buckets_by_name.get(bucket_name, None)
71
        else:
72
            return self._buckets_by_id.get(bucket_id, None)
73
74 1
    def create(self, bucket_name, security, configuration=None):
75
        """
76
77
        :param bucket_name:
78
        :param configuration:
79
        :return:
80
        """
81
        path = API.create_bucket
82
        if type(bucket_name) != str and type(bucket_name) != bytes:
0 ignored issues
show
introduced by
Using type() instead of isinstance() for a typecheck.
Loading history...
83
            raise B2InvalidBucketName("Bucket name must be alphanumeric or '-")
84
        if type(configuration) != dict and configuration is not None:
0 ignored issues
show
introduced by
Using type() instead of isinstance() for a typecheck.
Loading history...
85
            raise B2InvalidBucketConfiguration
86
        params = {
87
            'bucketName': bucket_name,
88
            'bucketType': security,
89
            #TODO: bucketInfo
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
90
            #TODO: corsRules
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
91
            #TODO: lifeCycleRules
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
92
        }
93
        response = self.connector.make_request(path=path, method='post', params=params, account_id_required=True)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (113/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
94
        if response.status_code == 200:
95
            bucket_json = response.json()
96
            new_bucket = B2Bucket(connector=self.connector, parent_list=self, **bucket_json)
97
            self._buckets_by_name[bucket_json['bucketName']] = new_bucket
98
            self._buckets_by_id[bucket_json['bucketId']] = new_bucket
99
            return new_bucket
100
        else:
101
            raise B2Exception.parse(response)
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...