Failed Conditions
Pull Request — master (#2076)
by Abdeali
02:11
created

fail_acquire_settings()   B

Complexity

Conditions 4

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 4
dl 0
loc 26
rs 8.5806
1
def fail_acquire_settings(log_printer, settings_names_dict):
2
    """
3
    This method throws an exception if any setting needs to be acquired.
4
5
    :param log_printer:     Printer responsible for logging the messages.
6
    :param settings:        A dictionary with the settings name as key and
7
                            a list containing a description in [0] and the
8
                            name of the bears who need this setting in [1]
9
                            and following.
10
    :raises AssertionError: If any setting is required.
11
    :raises TypeError:      If ``settings_names_dict`` is not a dictionary.
12
    """
13
    if not isinstance(settings_names_dict, dict):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable dict does not seem to be defined.
Loading history...
14
        raise TypeError("The settings_names_dict parameter has to be a "
15
                        "dictionary.")
16
17
    required_settings = settings_names_dict.keys()
18
    if len(required_settings) != 0:
19
        msg = ("During execution, we found that some required "
20
               "settings were not provided. They are:\n")
21
22
        for name, setting in settings_names_dict.items():
23
            msg += "{} (from {}) - {}".format(name, setting[1], setting[0])
24
25
        log_printer.err(msg)
26
        raise AssertionError
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable AssertionError does not seem to be defined.
Loading history...
27