Passed
Pull Request — master (#3135)
by Alexander
02:46
created

ssg.utils.merge_dicts()   A

Complexity

Conditions 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 1
1 1
from __future__ import absolute_import
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 1
from __future__ import print_function
3
4 1
import multiprocessing
5
6
7 1
class SSGError(RuntimeError):
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...
8 1
    pass
9
10
11 1
def required_key(_dict, _key):
0 ignored issues
show
Coding Style introduced by
This function 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...
12
    if _key in _dict:
13
        return _dict[_key]
14
15
    raise ValueError("%s is required but was not found in:\n%s" %
16
                     (_key, repr(_dict)))
17
18
19 1
def get_cpu_count():
0 ignored issues
show
Coding Style introduced by
This function 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...
20
    try:
21
        return max(1, multiprocessing.cpu_count())
22
23
    except NotImplementedError:
24
        # 2 CPUs is the most probable
25
        return 2
26
27
28 1
def merge_dicts(left, right):
29
    """
30
    Merges two dictionaries, keeing left and right as passed. If there are any
31
    common keys between left and right, the value from right is use.
32
33
    Returns the merger of the left and right dictionaries
34
    """
35 1
    result = left.copy()
36 1
    result.update(right)
37
    return result
38