def format_value(self, attr, attr_props, value):
if isinstance(value, bool):<EOL><INDENT>return str(value).upper()<EOL><DEDENT>if any(i in ["<STR_LIT>"] for i in attr_props):<EOL><INDENT>if not isinstance(value, numbers.Number):<EOL><INDENT>return value.upper()  <EOL><DEDENT>else:<EOL><INDENT>return value<EOL><DEDENT><DEDENT>if "<STR_LIT:type>" in attr_props and attr_props["<STR_LIT:type>"] == "<STR_LIT:string>":  <EOL><INDENT>if self.is_expression(attr_props) and self.quoter.in_slashes(value):<EOL><INDENT>return value<EOL><DEDENT>elif self.is_expression(attr_props) and (value.endswith("<STR_LIT>") or value.endswith('<STR_LIT>')):<EOL><INDENT>return value<EOL><DEDENT>else:<EOL><INDENT>return self.quoter.add_quotes(value)<EOL><DEDENT><DEDENT>if any(i in ["<STR_LIT>", "<STR_LIT>"] for i in attr_props):  <EOL><INDENT>if "<STR_LIT>" in attr_props:<EOL><INDENT>options_list = attr_props["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>options_list = attr_props["<STR_LIT>"]<EOL><DEDENT>if self.quoter.is_string(value):<EOL><INDENT>if self.quoter.in_parenthesis(value):<EOL><INDENT>pass<EOL><DEDENT>elif attr == "<STR_LIT>" and self.quoter.in_braces(value):<EOL><INDENT>pass<EOL><DEDENT>elif attr != "<STR_LIT:text>" and self.quoter.in_brackets(value):<EOL><INDENT>pass<EOL><DEDENT>elif value.startswith("<STR_LIT>") and self.quoter.in_parenthesis(value[<NUM_LIT:4>:]):<EOL><INDENT>value = "<STR_LIT>".format(value[<NUM_LIT:4>:])<EOL><DEDENT>else:<EOL><INDENT>value = self.check_options_list(options_list, value)<EOL><DEDENT><DEDENT><DEDENT>if isinstance(value, list):<EOL><INDENT>new_values = []<EOL>for v in value:<EOL><INDENT>if not isinstance(v, numbers.Number):<EOL><INDENT>v = self.quoter.add_quotes(v)<EOL><DEDENT>new_values.append(v)<EOL><DEDENT>value = "<STR_LIT:U+0020>".join(list(map(str, new_values)))<EOL><DEDENT>else:<EOL><INDENT>value = self.quoter.escape_quotes(value)<EOL><DEDENT>return value<EOL>
TODO - refactor and add more specific tests (particularly for expressions)