def _substitute(self, query, model_class=None):
if '<STR_LIT:$>' in query:<EOL><INDENT>mapping = dict(db="<STR_LIT>" % self.db_name)<EOL>if model_class:<EOL><INDENT>mapping['<STR_LIT>'] = "<STR_LIT>" % (self.db_name, model_class.table_name())<EOL><DEDENT>query = Template(query).safe_substitute(mapping)<EOL><DEDENT>return query<EOL>
Replaces $db and $table placeholders in the query.