def update_placeholders(self, format_string, placeholders):
<EOL>output = []<EOL>for token in self.tokens(format_string):<EOL><INDENT>if token.group("<STR_LIT:key>") in placeholders:<EOL><INDENT>output.append(<EOL>"<STR_LIT>" % (placeholders[token.group("<STR_LIT:key>")], token.group("<STR_LIT>"))<EOL>)<EOL>continue<EOL><DEDENT>elif token.group("<STR_LIT>"):<EOL><INDENT>commands = parse_qsl(token.group("<STR_LIT>"), keep_blank_values=True)<EOL>if "<STR_LIT>" in [x[<NUM_LIT:0>] for x in commands]:<EOL><INDENT>items = []<EOL>for key, value in commands:<EOL><INDENT>if key == "<STR_LIT>":<EOL><INDENT>condition = Condition(value)<EOL>variable = condition.variable<EOL>if variable in placeholders:<EOL><INDENT>variable = placeholders[variable]<EOL>not_ = "<STR_LIT:!>" if not condition.default else "<STR_LIT>"<EOL>condition_ = condition.condition or "<STR_LIT>"<EOL>if condition_:<EOL><INDENT>value_ = condition.value<EOL><DEDENT>else:<EOL><INDENT>value_ = "<STR_LIT>"<EOL><DEDENT>value = "<STR_LIT>".format(<EOL>not_, variable, condition_, value_<EOL>)<EOL><DEDENT><DEDENT>if value:<EOL><INDENT>items.append("<STR_LIT>".format(key, value))<EOL><DEDENT>else:<EOL><INDENT>items.append(key)<EOL><DEDENT><DEDENT>output.append(r"<STR_LIT>".format("<STR_LIT:&>".join(items)))<EOL>continue<EOL><DEDENT><DEDENT>value = token.group(<NUM_LIT:0>)<EOL>output.append(value)<EOL><DEDENT>return u"<STR_LIT>".join(output)<EOL>
Update a format string renaming placeholders.