def api_config(self, stage=None):
if stage in self.known_api_configurations:<EOL><INDENT>return self.known_api_configurations[stage]<EOL><DEDENT>if not stage:<EOL><INDENT>section = '<STR_LIT>'<EOL>api_url = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>section = '<STR_LIT>'.format(stage)<EOL>try:<EOL><INDENT>api_url = self.lookup(section, '<STR_LIT>')<EOL><DEDENT>except ConfigurationError:<EOL><INDENT>api_url = '<STR_LIT>'.format(stage)<EOL><DEDENT><DEDENT>return APIConfig(api_url)<EOL>
Create api config based on stage.