def _check_choices_attribute(self):   # pragma: no cover
        """Checks to make sure that choices contains valid timezone choices."""

        if self.choices:
            warning_params = {
                'msg': (
                    "'choices' contains an invalid time zone value '{value}' "
                    "which was not found as a supported time zone by pytz "
                    "{version}."
                ),
                'hint': "Values must be found in pytz.all_timezones.",
                'obj': self,
            }

            for option_key, option_value in self.choices:
                if isinstance(option_value, (list, tuple)):
                    # This is an optgroup, so look inside the group for
                    # options.
                    for optgroup_key in map(lambda x: x[0], option_value):
                        if optgroup_key not in pytz.all_timezones:
                            # Make sure we don't raise this error on empty
                            #   values
                            if optgroup_key not in self.empty_values:
                                # Update the error message by adding the value
                                warning_params.update({
                                    'msg': warning_params['msg'].format(
                                        value=optgroup_key,
                                        version=pytz.VERSION
                                    )
                                })

                                # Return the warning
                                return [
                                    checks.Warning(**warning_params)
                                ]

                elif option_key not in pytz.all_timezones:
                    # Make sure we don't raise this error on empty
                    #   values
                    if option_key not in self.empty_values:
                        # Update the error message by adding the value
                        warning_params.update({
                            'msg': warning_params['msg'].format(
                                value=option_key,
                                version=pytz.VERSION
                            )
                        })

                        # Return the warning
                        return [
                            checks.Warning(**warning_params)
                        ]

        # When no error, return an empty list
        return []
def _check_choices_attribute ( self ) : if self . choices : warning_params = { 'msg' : ( "'choices' contains an invalid time zone value '{value}' " "which was not found as a supported time zone by pytz " "{version}." ) , 'hint' : "Values must be found in pytz.all_timezones." , 'obj' : self , } for option_key , option_value in self . choices : if isinstance ( option_value , ( list , tuple ) ) : for optgroup_key in map ( lambda x : x [ 0 ] , option_value ) : if optgroup_key not in pytz . all_timezones : if optgroup_key not in self . empty_values : warning_params . update ( { 'msg' : warning_params [ 'msg' ] . format ( value = optgroup_key , version = pytz . VERSION ) } ) return [ checks . Warning ( ** warning_params ) ] elif option_key not in pytz . all_timezones : if option_key not in self . empty_values : warning_params . update ( { 'msg' : warning_params [ 'msg' ] . format ( value = option_key , version = pytz . VERSION ) } ) return [ checks . Warning ( ** warning_params ) ] return [ ]
Checks to make sure that choices contains valid timezone choices.