Passed
Push — master ( 2f86f7...74d48b )
by Markus
01:48
created

tcllib.dumpmgr.DumpMgr.write_dump()   B

Complexity

Conditions 5

Size

Total Lines 11
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nop 2
dl 0
loc 11
rs 8.5454
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
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
import errno
4
import glob
5
import os
6
from . import ansi
7
8
class DumpMgrMixin:
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...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
9
    def __init__(self):
10
        self.last_dump_filename = None
11
12
    def write_dump(self, data):
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...
13
        outfile = os.path.normpath("logs/{}.xml".format(self.get_salt()))
14
        if not os.path.exists(os.path.dirname(outfile)):
15
            try:
16
                os.makedirs(os.path.dirname(outfile))
17
            except OSError as e:
0 ignored issues
show
Coding Style Naming introduced by
The name e does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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...
18
                if e.errno != errno.EEXIST:
19
                    raise
20
        with open(outfile, "w", encoding="utf-8") as f:
0 ignored issues
show
Coding Style Naming introduced by
The name f does not conform to the variable naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

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...
21
            f.write(data)
22
        self.last_dump_filename = outfile
23
24
    def delete_last_dump(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...
25
        if self.last_dump_filename:
26
            os.unlink(self.last_dump_filename)
27
            self.last_dump_filename = None
28
29
    @staticmethod
30
    def write_info_if_dumps_found():
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...
31
        # To disable this info, uncomment the following line.
32
        #return
33
        files = glob.glob(os.path.normpath("logs/*.xml"))
34
        if len(files) > 0:
0 ignored issues
show
Unused Code introduced by
Do not use len(SEQUENCE) as condition value
Loading history...
35
            print()
36
            print("{}There are {} logs collected in the logs/ directory.{} Please consider uploading".format(ansi.YELLOW, len(files), ansi.RESET))
1 ignored issue
show
Coding Style introduced by
This line is too long as per the coding-style (146/80).

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

Loading history...
37
            print("them to https://tclota.birth-online.de/ by running {}./upload_logs.py{}.".format(ansi.CYAN, ansi.RESET))
1 ignored issue
show
Coding Style introduced by
This line is too long as per the coding-style (123/80).

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

Loading history...
38