Conditions | 2 |
Total Lines | 11 |
Code Lines | 5 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 2 |
Changes | 0 |
1 | 1 | from __future__ import absolute_import |
|
11 | 1 | def required_key(_dict, _key): |
|
12 | """ |
||
13 | Returns the value of _key if it is in _dict; otherwise, raise an |
||
14 | exception stating that it was not found but is required. |
||
15 | """ |
||
16 | |||
17 | 1 | if _key in _dict: |
|
18 | 1 | return _dict[_key] |
|
19 | |||
20 | 1 | raise ValueError("%s is required but was not found in:\n%s" % |
|
21 | (_key, repr(_dict))) |
||
22 | |||
63 |
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.