<s> import optparse <EOL> from wiseguy . loader import EPParser <EOL> from wiseguy . loader import AppLoader <EOL> from wsgiref . simple_server import make_server <EOL> class HelpFormatter ( optparse . IndentedHelpFormatter ) : <EOL> def format_description ( self , description ) : <EOL> return '<STR_LIT>' % description <EOL> def serve ( app ) : <EOL> server = make_server ( '<STR_LIT>' , <NUM_LIT> , app ) <EOL> sa = server . socket . getsockname ( ) <EOL> print "<STR_LIT>" % app , sa [ <NUM_LIT:0> ] , "<STR_LIT:port>" , sa [ <NUM_LIT:1> ] , "<STR_LIT>" <EOL> server . serve_forever ( ) <EOL> def main ( argv = None ) : <EOL> if argv is None : <EOL> import sys <EOL> argv = sys . argv <EOL> parser = optparse . OptionParser ( description = __doc__ , <EOL> formatter = HelpFormatter ( ) , <EOL> ) <EOL> parser . add_option ( '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , default = False , <EOL> help = "<STR_LIT>" ) <EOL> options , args = parser . parse_args ( argv [ <NUM_LIT:1> : ] ) <EOL> if args : <EOL> if args [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> from wiseguy . web . app import configurator <EOL> serve ( configurator ) <EOL> if args [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> filename = args [ <NUM_LIT:1> ] <EOL> loader = AppLoader ( ) <EOL> loader . load_yaml ( filename ) <EOL> app_factory = loader . get_app_factory ( '<STR_LIT>' ) <EOL> app = app_factory ( ) <EOL> serve ( app ) <EOL> if options . list_components : <EOL> ep_parser = EPParser ( ) <EOL> for component_name , component in ep_parser . get_components ( ) : <EOL> print component_name , component <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import sys <EOL> main ( sys . argv ) </s>
