#NEWLINE# def parse_options( ) : #NEWLINE# #INDENT# option_parser = get_option_parser ( ) #NEWLINE# ( options , args ) = option_parser . parse_args ( ) #NEWLINE# if options . config : #NEWLINE# #INDENT# app . config . from_pyfile ( options . config ) #NEWLINE# #UNINDENT# if os . environ . get ( 'SCOUT_CONFIG' ) : #NEWLINE# #INDENT# app . config . from_pyfile ( os . environ [ 'SCOUT_CONFIG' ] ) #NEWLINE# #UNINDENT# if os . environ . get ( 'SCOUT_DATABASE' ) : #NEWLINE# #INDENT# app . config [ 'DATABASE' ] = os . environ [ 'SCOUT_DATABASE' ] #NEWLINE# #UNINDENT# if ( ( len ( args ) == 0 ) and ( not app . config . get ( 'DATABASE' ) ) ) : #NEWLINE# #INDENT# panic ( 'Error: missing required path to database file.' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( args ) > 1 ) : #NEWLINE# #INDENT# panic ( ( 'Error: [%s] only accepts one argument, which is the path to the database file.' % __file__ ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if args : #NEWLINE# #INDENT# app . config [ 'DATABASE' ] = args [ 0 ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if options . api_key : #NEWLINE# #INDENT# app . config [ 'AUTHENTICATION' ] = options . api_key #NEWLINE# #UNINDENT# if options . debug : #NEWLINE# #INDENT# app . config [ 'DEBUG' ] = True #NEWLINE# #UNINDENT# if options . host : #NEWLINE# #INDENT# app . config [ 'HOST' ] = options . host #NEWLINE# #UNINDENT# if options . paginate_by : #NEWLINE# #INDENT# if ( ( options . paginate_by < 1 ) or ( options . paginate_by > 1000 ) ) : #NEWLINE# #INDENT# panic ( 'paginate-by must be between 1 and 1000' ) #NEWLINE# #UNINDENT# app . config [ 'PAGINATE_BY' ] = options . paginate_by #NEWLINE# #UNINDENT# if options . port : #NEWLINE# #INDENT# app . config [ 'PORT' ] = options . port #NEWLINE# #UNINDENT# if options . stem : #NEWLINE# #INDENT# if ( options . stem not in ( 'simple' , 'porter' ) ) : #NEWLINE# #INDENT# panic ( 'Unrecognized stemmer. Must be "porter" or "simple".' ) #NEWLINE# #UNINDENT# app . config [ 'STEM' ] = options . stem #NEWLINE# #UNINDENT# if options . star_all : #NEWLINE# #INDENT# app . config [ 'STAR_ALL' ] = True #NEWLINE# #UNINDENT# if options . search_version : #NEWLINE# #INDENT# app . config [ 'SEARCH_EXTENSION' ] = ( 'FTS%s' % options . search_version )