<s> '''<STR_LIT>''' <EOL> import os <EOL> from flask import Flask <EOL> from markwiki . git . git_integration import GitIntegration <EOL> from markwiki . search . engine import SearchEngine <EOL> from markwiki . storage . factory import UserStorageFactory <EOL> from markwiki import util <EOL> def build_app ( app_name ) : <EOL> '''<STR_LIT>''' <EOL> app = MarkWikiApp ( app_name ) <EOL> if not app . is_bootstrapped ( ) : <EOL> print ( '<STR_LIT>' ) <EOL> util . bootstrap ( app ) <EOL> app . search_engine = SearchEngine ( app . config [ '<STR_LIT>' ] ) <EOL> if not app . search_engine . has_index ( ) : <EOL> app . search_engine . create_index ( app . config [ '<STR_LIT>' ] ) <EOL> user_storage_factory = UserStorageFactory ( ) <EOL> app . user_storage = user_storage_factory . get_storage ( app . config ) <EOL> app . gitint = None <EOL> if app . config [ '<STR_LIT>' ] : <EOL> app . gitint = GitIntegration ( app . config [ '<STR_LIT>' ] ) <EOL> return app <EOL> class MarkWikiApp ( Flask ) : <EOL> boolean_settings = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> bootstrapped_token_file = '<STR_LIT>' <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( MarkWikiApp , self ) . __init__ ( * args , ** kwargs ) <EOL> self . config . from_object ( '<STR_LIT>' ) <EOL> loaded = self . config . from_envvar ( '<STR_LIT>' , silent = True ) <EOL> if not loaded : <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . _load_from_environment ( ) <EOL> self . config [ '<STR_LIT>' ] = os . path . join ( self . config [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' ) <EOL> if not self . config [ '<STR_LIT>' ] : <EOL> self . config [ '<STR_LIT>' ] = True <EOL> if self . config [ '<STR_LIT>' ] : <EOL> self . static_folder = self . config [ '<STR_LIT>' ] <EOL> if self . config [ '<STR_LIT>' ] : <EOL> self . template_folder = self . config [ '<STR_LIT>' ] <EOL> def _load_from_environment ( self ) : <EOL> '''<STR_LIT>''' <EOL> for key in sorted ( self . config . keys ( ) ) : <EOL> if os . environ . get ( key ) is not None : <EOL> print ( '<STR_LIT>' . format ( key = key ) ) <EOL> if key in self . boolean_settings : <EOL> self . config [ key ] = util . boolify ( os . environ [ key ] ) <EOL> else : <EOL> self . config [ key ] = os . environ [ key ] <EOL> def is_bootstrapped ( self ) : <EOL> return os . path . exists ( os . path . join ( self . config [ '<STR_LIT>' ] , <EOL> self . bootstrapped_token_file ) ) </s>
