<s> from inspect import getmembers , isclass <EOL> from flask . ext . failsafe import failsafe <EOL> from flask . ext . script import Manager <EOL> from flask . ext . script . commands import Clean , Server , Shell , ShowUrls <EOL> from flask . ext . migrate import MigrateCommand <EOL> from flask . ext . assets import ManageAssets <EOL> from factory . alchemy import SQLAlchemyModelFactory <EOL> from app import create_app , db , models <EOL> from config . application import AVAILABLE_CONFIGS , DEFAULT_CONFIG <EOL> from test import factories <EOL> manager = Manager ( failsafe ( create_app ) , with_default_commands = False ) <EOL> def _make_context ( ) : <EOL> context = dict ( app = manager . app , db = db ) <EOL> context . update ( getmembers ( <EOL> models , lambda m : isclass ( m ) and issubclass ( m , db . Model ) <EOL> ) ) <EOL> context . update ( getmembers ( <EOL> factories , <EOL> lambda m : isclass ( m ) and issubclass ( m , SQLAlchemyModelFactory ) <EOL> ) ) <EOL> return context <EOL> manager . add_option ( '<STR_LIT:-c>' , '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> choices = list ( AVAILABLE_CONFIGS ) , default = DEFAULT_CONFIG ) <EOL> manager . add_command ( '<STR_LIT>' , Clean ( ) ) <EOL> manager . add_command ( '<STR_LIT>' , Server ( host = '<STR_LIT>' ) ) <EOL> manager . add_command ( '<STR_LIT>' , Shell ( make_context = _make_context ) ) <EOL> manager . add_command ( '<STR_LIT>' , ShowUrls ( ) ) <EOL> manager . add_command ( '<STR_LIT>' , MigrateCommand ) <EOL> manager . add_command ( "<STR_LIT>" , ManageAssets ( ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> manager . run ( ) </s>
