| Total Complexity | 5 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 61.11% |
| Changes | 0 | ||
| 1 | 1 | from __future__ import absolute_import |
|
|
|
|||
| 2 | 1 | from __future__ import print_function |
|
| 3 | |||
| 4 | 1 | import multiprocessing |
|
| 5 | |||
| 6 | |||
| 7 | 1 | class SSGError(RuntimeError): |
|
| 8 | 1 | pass |
|
| 9 | |||
| 10 | |||
| 11 | 1 | def required_key(_dict, _key): |
|
| 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(): |
|
| 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 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.