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 (#29)
by
unknown
02:03
created

b2blaze.models.bucket_list.B2Buckets.all()   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 6
ccs 1
cts 2
cp 0.5
crap 1.125
rs 10
c 0
b 0
f 0
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):
18
        """
19
20
        :param connector:
21
        """
22
        self.connector = connector
23
        self._buckets_by_name = {}
24
        self._buckets_by_id = {}
25
26 1
    def all(self):
27
        """
28
29
        :return:
30
        """
31
        return self._update_bucket_list(retrieve=True)
32
33 1
    def _update_bucket_list(self, retrieve=False):
34
        """
35
36
        :param retrieve:
37
        :return:
38
        """
39
        path = API.list_all_buckets
40
        response = self.connector.make_request(path=path, method='post', account_id_required=True)
41
        if response.status_code == 200:
42
            response_json = response.json()
43
            buckets = []
44
            self._buckets_by_name = {}
45
            self._buckets_by_id = {}
46
            for bucket_json in response_json['buckets']:
47
                new_bucket = B2Bucket(connector=self.connector, parent_list=self, **bucket_json)
48
                buckets.append(new_bucket)
49
                self._buckets_by_name[bucket_json['bucketName']] = new_bucket
50
                self._buckets_by_id[bucket_json['bucketId']] = new_bucket
51
            if retrieve:
52
                return buckets
53
        else:
54
            raise B2Exception.parse(response)
55
56 1
    def get(self, bucket_name=None, bucket_id=None):
57
        """
58
59
        :param bucket_name:
60
        :param bucket_id:
61
        :return:
62
        """
63
        self._update_bucket_list()
64
        if bucket_name is not None:
0 ignored issues
show
unused-code introduced by
Unnecessary "else" after "return"
Loading history...
65
            return self._buckets_by_name.get(bucket_name, None)
66
        else:
67
            return self._buckets_by_id.get(bucket_id, None)
68
69 1
    def create(self, bucket_name, security, configuration=None):
70
        """
71
72
        :param bucket_name:
73
        :param configuration:
74
        :return:
75
        """
76
        path = API.create_bucket
77
        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...
78
            raise B2InvalidBucketName("Bucket name must be alphanumeric or '-")
79
        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...
80
            raise B2InvalidBucketConfiguration
81
        params = {
82
            'bucketName': bucket_name,
83
            'bucketType': security,
84
            #TODO: bucketInfo
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
85
            #TODO: corsRules
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
86
            #TODO: lifeCycleRules
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
87
        }
88
        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...
89
        if response.status_code == 200:
90
            bucket_json = response.json()
91
            new_bucket = B2Bucket(connector=self.connector, parent_list=self, **bucket_json)
92
            self._buckets_by_name[bucket_json['bucketName']] = new_bucket
93
            self._buckets_by_id[bucket_json['bucketId']] = new_bucket
94
            return new_bucket
95
        else:
96
            raise B2Exception.parse(response)
0 ignored issues
show
Coding Style introduced by
Final newline missing
Loading history...