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.
Passed
Pull Request — master (#4)
by Oleg
02:28
created

ChunkLogger.filename2()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 8
ccs 0
cts 2
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
import enarksh
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
4
class ChunkLogger:
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
5
    _file_count = 0
6
7
    # ------------------------------------------------------------------------------------------------------------------
8
    def __init__(self):
9
        self._chunk_count = 0
10
        self._position = 0
11
        self._buffer = bytearray(b' ' * enarksh.CHUNK_SIZE)
12
        self._filename1 = ''
13
        self._filename2 = ''
14
15
    # ------------------------------------------------------------------------------------------------------------------
16
    @property
17
    def filename1(self):
18
        """
19
        Getter for filename1.
20
21
        :rtype: str
22
        """
23
        return self._filename1
24
25
    # ------------------------------------------------------------------------------------------------------------------
26
    @property
27
    def filename2(self):
28
        """
29
        Getter for filename2.
30
31
        :rtype: str
32
        """
33
        return self._filename2
34
35
    # ------------------------------------------------------------------------------------------------------------------
36
    @staticmethod
37
    def _get_filename():
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
38
        ChunkLogger._file_count += 1
39
40
        return '{0!s}/{1!s}/{2:010d}.log'.format(enarksh.HOME, 'var/lib/logger', ChunkLogger._file_count)
41
42
    # ------------------------------------------------------------------------------------------------------------------
43
    def write(self, buffer):
44
        """
45
        :param bytes buffer:
46
        """
47
        size = len(buffer)
48
        pos = 0
49
50
        while size > 0:
51
            n = min(size, enarksh.CHUNK_SIZE - self._position)
0 ignored issues
show
Coding Style Naming introduced by
The name n does not conform to the variable naming conventions ([a-z_][a-z0-9_]{1,60}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
52
            self._buffer[self._position:self._position + n] = buffer[pos:pos + n]
53
54
            if n < size:
55
                if self._chunk_count == 0:
56
                    self._filename1 = self._get_filename()
57
                    with open(self._filename1, "wb") as file:
58
                        file.write(self._buffer[:enarksh.CHUNK_SIZE])
59
60
                self._position = 0
61
                self._chunk_count += 1
62
            else:
63
                self._position += n
64
65
            size -= n
66
            pos += n
67
68
    # ------------------------------------------------------------------------------------------------------------------
69
    def get_total_log_size(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
70
        return self._chunk_count * enarksh.CHUNK_SIZE + self._position
71
72
    # ------------------------------------------------------------------------------------------------------------------
73
    def close(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
74
        if self._position != 0:
75
            if self._chunk_count == 0:
76
                # Write first chunk to the file system.
77
                self._filename1 = self._get_filename()
78
                with open(self._filename1, "wb") as file:
79
                    file.write(self._buffer[:self._position])
80
                    file.close()
81
82
            else:
83
                self._filename2 = self._get_filename()
84
                with open(self._filename2, "wb") as file:
85
                    if self._chunk_count >= 2:
86
                        file.write(self._buffer[self._position:enarksh.CHUNK_SIZE])
87
                    file.write(self._buffer[:self._position])
88
                    file.close()
89
90
91
# ----------------------------------------------------------------------------------------------------------------------
92