def set_voice(self, voice): '''Set the voice to the proper value from this dictionary.''' voice_dict = { "none": 0, "male": -1, "female": -2, "type": -3, "auto": -4 } self.data["voice"] = key_or_value(voice.lower(), voice_dict, "voice") self.last_method = False
def config(self, line): '''Handle parsing while inside a configuration block.''' if line == "}": return self.no_macro try: attr, value = line.rsplit(":", maxsplit=1) value = value.strip() attr, value = attr.lower(), value.lower() except ValueError: raise Invalid("config colon") if attr not in self.config_dict: raise Invalid("config attr", attr) if attr in self.customization_dict: self.config_dict[attr] = key_or_value( value, self.customization_dict[attr], attr) elif attr == "autoescape": self.config_dict[attr].update(value.split()) else: self.config_dict[attr] = int_at_least( value, 0, "Configuration attribute " + attr) return self.config
def set_voice(self, voice): '''Set the voice to the proper value from this dictionary.''' voice_dict = {"none": 0, "male": -1, "female": -2, "type": -3, "auto": -4} self.data["voice"] = key_or_value(voice.lower(), voice_dict, "voice") self.last_method = False