<s> from __future__ import print_function , unicode_literals , with_statement , division <EOL> from os import path , system , listdir , sys , mkdir <EOL> from django . conf import settings <EOL> LIST_VIEW = """<STR_LIT>""" <EOL> DETAILS_VIEW = """<STR_LIT>""" <EOL> DELETE_VIEW = """<STR_LIT>""" <EOL> MODEL_TEMPLATE = """<STR_LIT>""" <EOL> IMPORT_MODEL_TEMPLATE = """<STR_LIT>""" <EOL> CHARFIELD_TEMPLATE = """<STR_LIT>""" <EOL> TEXTFIELD_TEMPLATE = """<STR_LIT>""" <EOL> INTEGERFIELD_TEMPLATE = """<STR_LIT>""" <EOL> DECIMALFIELD_TEMPLATE = """<STR_LIT>""" <EOL> DATETIMEFIELD_TEMPLATE = """<STR_LIT>""" <EOL> FOREIGNFIELD_TEMPLATE = """<STR_LIT>""" <EOL> TEMPLATE_LIST_CONTENT = """<STR_LIT>""" <EOL> TEMPLATE_DETAILS_CONTENT = """<STR_LIT>""" <EOL> URL_CONTENT = """<STR_LIT>""" <EOL> URL_EXISTS_CONTENT = """<STR_LIT>""" <EOL> ADMIN_CONTENT = """<STR_LIT>""" <EOL> FORM_CONTENT = """<STR_LIT>""" <EOL> TESTS_CONTENT = """<STR_LIT>""" <EOL> class Scaffold ( object ) : <EOL> def _info ( self , msg , indent = <NUM_LIT:0> ) : <EOL> print ( "<STR_LIT>" . format ( "<STR_LIT:\t>" * int ( indent ) , msg ) ) <EOL> def __init__ ( self , app , model , fields ) : <EOL> self . app = app <EOL> self . model = model <EOL> self . fields = fields <EOL> try : <EOL> self . SCAFFOLD_APPS_DIR = settings . SCAFFOLD_APPS_DIR <EOL> except : <EOL> self . SCAFFOLD_APPS_DIR = '<STR_LIT>' <EOL> def get_import ( self , model ) : <EOL> for dir in listdir ( self . SCAFFOLD_APPS_DIR ) : <EOL> if path . isdir ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , dir ) ) and path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , dir ) ) : <EOL> with open ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , dir ) , '<STR_LIT:r>' ) as fp : <EOL> for line in fp . readlines ( ) : <EOL> if '<STR_LIT>' . format ( model ) in line : <EOL> return IMPORT_MODEL_TEMPLATE % { '<STR_LIT>' : dir , '<STR_LIT>' : model } <EOL> return None <EOL> def is_imported ( self , path , model ) : <EOL> with open ( path , '<STR_LIT:r>' ) as import_file : <EOL> for line in import_file . readlines ( ) : <EOL> if '<STR_LIT>' . format ( model ) in line : <EOL> return True <EOL> return False <EOL> def add_global_view_imports ( self , path ) : <EOL> import_list = list ( ) <EOL> with open ( path , '<STR_LIT:r>' ) as import_file : <EOL> need_import_shortcut = True <EOL> need_import_urlresolvers = True <EOL> need_import_users = True <EOL> need_import_token = True <EOL> need_import_JsonResponse = True <EOL> for line in import_file . readlines ( ) : <EOL> if '<STR_LIT>' in line : <EOL> need_import_shortcut = False <EOL> if '<STR_LIT>' in line : <EOL> need_import_urlresolvers = False <EOL> if '<STR_LIT>' in line : <EOL> need_import_users = False <EOL> if '<STR_LIT>' in line : <EOL> need_import_token = False <EOL> if '<STR_LIT>' in line : <EOL> need_import_JsonResponse = False <EOL> if need_import_shortcut : <EOL> import_list . append ( <EOL> '<STR_LIT>' ) <EOL> if need_import_urlresolvers : <EOL> import_list . append ( '<STR_LIT>' ) <EOL> if need_import_users : <EOL> import_list . append ( '<STR_LIT>' ) <EOL> if need_import_token : <EOL> import_list . append ( '<STR_LIT>' ) <EOL> if need_import_JsonResponse : <EOL> import_list . append ( '<STR_LIT>' ) <EOL> return import_list <EOL> def view_exists ( self , path , view ) : <EOL> with open ( path , '<STR_LIT:r>' ) as view_file : <EOL> for line in view_file . readlines ( ) : <EOL> if '<STR_LIT>' . format ( view ) in line : <EOL> return True <EOL> return False <EOL> def get_field ( self , field ) : <EOL> field = field . split ( '<STR_LIT::>' ) <EOL> field_type = field [ <NUM_LIT:0> ] <EOL> if field_type . lower ( ) == '<STR_LIT>' : <EOL> try : <EOL> length = field [ <NUM_LIT:2> ] <EOL> except IndexError : <EOL> length = <NUM_LIT:255> <EOL> try : <EOL> null = field [ <NUM_LIT:3> ] <EOL> null = '<STR_LIT:False>' <EOL> except IndexError : <EOL> null = '<STR_LIT:True>' <EOL> return CHARFIELD_TEMPLATE % { '<STR_LIT:name>' : field [ <NUM_LIT:1> ] , '<STR_LIT>' : length , '<STR_LIT:null>' : null } <EOL> elif field_type . lower ( ) == '<STR_LIT:text>' : <EOL> try : <EOL> null = field [ <NUM_LIT:2> ] <EOL> null = '<STR_LIT:False>' <EOL> except IndexError : <EOL> null = '<STR_LIT:True>' <EOL> return TEXTFIELD_TEMPLATE % { '<STR_LIT:name>' : field [ <NUM_LIT:1> ] , '<STR_LIT:null>' : null } <EOL> elif field_type . lower ( ) == '<STR_LIT:int>' : <EOL> try : <EOL> null = field [ <NUM_LIT:2> ] <EOL> null = '<STR_LIT:False>' <EOL> except IndexError : <EOL> null = '<STR_LIT:True>' <EOL> try : <EOL> default = field [ <NUM_LIT:3> ] <EOL> except IndexError : <EOL> default = None <EOL> return INTEGERFIELD_TEMPLATE % { '<STR_LIT:name>' : field [ <NUM_LIT:1> ] , '<STR_LIT:null>' : null , '<STR_LIT:default>' : default } <EOL> elif field_type . lower ( ) == '<STR_LIT>' : <EOL> try : <EOL> null = field [ <NUM_LIT:4> ] <EOL> null = '<STR_LIT:False>' <EOL> except IndexError : <EOL> null = '<STR_LIT:True>' <EOL> try : <EOL> default = field [ <NUM_LIT:5> ] <EOL> except IndexError : <EOL> default = None <EOL> return DECIMALFIELD_TEMPLATE % { <EOL> '<STR_LIT:name>' : field [ <NUM_LIT:1> ] , <EOL> '<STR_LIT>' : field [ <NUM_LIT:2> ] , <EOL> '<STR_LIT>' : field [ <NUM_LIT:3> ] , <EOL> '<STR_LIT:null>' : null , <EOL> '<STR_LIT:default>' : default , <EOL> } <EOL> elif field_type . lower ( ) == '<STR_LIT>' : <EOL> try : <EOL> null = field [ <NUM_LIT:2> ] <EOL> null = '<STR_LIT:False>' <EOL> except IndexError : <EOL> null = '<STR_LIT:True>' <EOL> try : <EOL> default = field [ <NUM_LIT:3> ] <EOL> except IndexError : <EOL> default = None <EOL> return DATETIMEFIELD_TEMPLATE % { '<STR_LIT:name>' : field [ <NUM_LIT:1> ] , '<STR_LIT:null>' : null , '<STR_LIT:default>' : default } <EOL> elif field_type . lower ( ) == '<STR_LIT>' : <EOL> foreign = field [ <NUM_LIT:2> ] <EOL> name = field [ <NUM_LIT:1> ] <EOL> if foreign in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> if not self . is_imported ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , <EOL> self . app ) , foreign ) : <EOL> self . imports . append ( '<STR_LIT>' ) <EOL> return FOREIGNFIELD_TEMPLATE % { '<STR_LIT:name>' : name , '<STR_LIT>' : foreign , '<STR_LIT:null>' : '<STR_LIT:True>' } <EOL> if self . is_imported ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app ) , foreign ) : <EOL> return FOREIGNFIELD_TEMPLATE % { '<STR_LIT:name>' : name , '<STR_LIT>' : foreign , '<STR_LIT:null>' : '<STR_LIT:True>' } <EOL> if self . get_import ( foreign ) : <EOL> self . imports . append ( self . get_import ( foreign ) ) <EOL> return FOREIGNFIELD_TEMPLATE % { '<STR_LIT:name>' : name , '<STR_LIT>' : foreign , '<STR_LIT:null>' : '<STR_LIT:True>' } <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , foreign ) , <NUM_LIT:1> ) <EOL> return None <EOL> def create_app ( self ) : <EOL> self . _info ( "<STR_LIT>" ) <EOL> self . _info ( "<STR_LIT>" ) <EOL> if self . SCAFFOLD_APPS_DIR and not path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR ) ) : <EOL> raise Exception ( <EOL> "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR ) ) <EOL> if not path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) ) : <EOL> system ( '<STR_LIT>' . format ( self . app ) ) <EOL> system ( '<STR_LIT>' . format ( self . app , self . SCAFFOLD_APPS_DIR , self . app ) ) <EOL> self . _info ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> else : <EOL> self . _info ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> def create_views ( self ) : <EOL> self . _info ( "<STR_LIT>" ) <EOL> self . _info ( "<STR_LIT>" ) <EOL> view_path = '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) <EOL> if path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) ) : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:w>' ) : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> import_list = list ( ) <EOL> view_list = list ( ) <EOL> import_list . append ( '<STR_LIT:\n>' . join ( imp for imp in self . add_global_view_imports ( view_path ) ) ) <EOL> if not self . is_imported ( view_path , self . model ) : <EOL> import_list . append ( self . get_import ( self . model ) ) <EOL> lower_model = self . model . lower ( ) <EOL> if not self . view_exists ( view_path , "<STR_LIT>" . format ( lower_model ) ) : <EOL> view_list . append ( LIST_VIEW % { <EOL> '<STR_LIT>' : lower_model , <EOL> '<STR_LIT>' : self . model , <EOL> '<STR_LIT>' : self . app , <EOL> } ) <EOL> self . _info ( "<STR_LIT>" . format ( view_path , lower_model ) , <NUM_LIT:1> ) <EOL> else : <EOL> self . _info ( "<STR_LIT>" . format ( view_path , lower_model ) , <NUM_LIT:1> ) <EOL> if not self . view_exists ( view_path , "<STR_LIT>" . format ( lower_model ) ) : <EOL> view_list . append ( DETAILS_VIEW % { <EOL> '<STR_LIT>' : lower_model , <EOL> '<STR_LIT>' : self . model , <EOL> '<STR_LIT>' : self . app , <EOL> } ) <EOL> self . _info ( "<STR_LIT>" . format ( view_path , lower_model ) , <NUM_LIT:1> ) <EOL> else : <EOL> self . _info ( "<STR_LIT>" . format ( view_path , lower_model ) , <NUM_LIT:1> ) <EOL> if not self . view_exists ( view_path , "<STR_LIT>" . format ( lower_model ) ) : <EOL> view_list . append ( DELETE_VIEW % { <EOL> '<STR_LIT>' : lower_model , <EOL> '<STR_LIT>' : self . model , <EOL> } ) <EOL> self . _info ( "<STR_LIT>" . format ( view_path , lower_model ) , <NUM_LIT:1> ) <EOL> else : <EOL> self . _info ( "<STR_LIT>" . format ( view_path , lower_model ) , <NUM_LIT:1> ) <EOL> with open ( view_path , '<STR_LIT:a>' ) as view_file : <EOL> view_file . write ( '<STR_LIT:\n>' . join ( [ import_line for import_line in import_list ] ) ) <EOL> view_file . write ( '<STR_LIT>' . join ( [ view for view in view_list ] ) ) <EOL> def create_model ( self ) : <EOL> self . _info ( "<STR_LIT>" ) <EOL> self . _info ( "<STR_LIT>" ) <EOL> with open ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:r>' ) as fp : <EOL> self . models_file = fp <EOL> for line in self . models_file . readlines ( ) : <EOL> if '<STR_LIT>' . format ( self . model ) in line : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> return <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> self . imports = [ ] <EOL> fields = [ ] <EOL> for field in self . fields : <EOL> new_field = self . get_field ( field ) <EOL> if new_field : <EOL> fields . append ( new_field ) <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , field . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> ] ) , <NUM_LIT:1> ) <EOL> with open ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:a>' ) as fp : <EOL> fp . write ( '<STR_LIT>' . join ( [ import_line for import_line in self . imports ] ) ) <EOL> fp . write ( MODEL_TEMPLATE % ( self . model , '<STR_LIT>' . join ( field for field in fields ) ) ) <EOL> def create_templates ( self ) : <EOL> self . _info ( "<STR_LIT>" ) <EOL> self . _info ( "<STR_LIT>" ) <EOL> if path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) ) : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> else : <EOL> mkdir ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) ) <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> if path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app , <EOL> self . model . lower ( ) ) ) : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app , <EOL> self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> else : <EOL> mkdir ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app , <EOL> self . model . lower ( ) ) ) <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> if path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app , <EOL> self . model . lower ( ) ) ) : <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app , <EOL> self . model . lower ( ) ) , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( TEMPLATE_LIST_CONTENT % { <EOL> '<STR_LIT>' : self . model . lower ( ) , <EOL> '<STR_LIT:title>' : self . model . lower ( ) , <EOL> } ) <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> if path . exists ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) ) : <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( TEMPLATE_DETAILS_CONTENT % { <EOL> '<STR_LIT>' : self . model . lower ( ) , <EOL> '<STR_LIT:title>' : self . model . lower ( ) , <EOL> } ) <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> def create_urls ( self ) : <EOL> self . _info ( "<STR_LIT>" ) <EOL> self . _info ( "<STR_LIT>" ) <EOL> if path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) ) : <EOL> new_urls = '<STR_LIT>' <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:r>' ) as fp : <EOL> for line in fp . readlines ( ) : <EOL> new_urls += line <EOL> if '<STR_LIT>' in line : <EOL> new_urls += URL_EXISTS_CONTENT % { <EOL> '<STR_LIT>' : self . app , <EOL> '<STR_LIT>' : self . model . lower ( ) , <EOL> } <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( new_urls ) <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( URL_CONTENT % { <EOL> '<STR_LIT>' : self . app , <EOL> '<STR_LIT>' : self . model . lower ( ) , <EOL> } ) <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> def create_admin ( self ) : <EOL> self . _info ( "<STR_LIT>" ) <EOL> self . _info ( "<STR_LIT>" ) <EOL> if path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) ) : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( "<STR_LIT>" ) <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:r>' ) as fp : <EOL> content = fp . read ( ) <EOL> if "<STR_LIT>" . format ( self . model ) in content : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app , <EOL> self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:a>' ) as fp : <EOL> fp . write ( ADMIN_CONTENT % { '<STR_LIT>' : self . app , '<STR_LIT>' : self . model } ) <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app , <EOL> self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> def create_forms ( self ) : <EOL> self . _info ( "<STR_LIT>" ) <EOL> self . _info ( "<STR_LIT>" ) <EOL> if path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) ) : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( "<STR_LIT>" ) <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:r>' ) as fp : <EOL> content = fp . read ( ) <EOL> if "<STR_LIT>" . format ( self . model ) in content : <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:a>' ) as fp : <EOL> fp . write ( FORM_CONTENT % { '<STR_LIT>' : self . app , '<STR_LIT>' : self . model } ) <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> def create_tests ( self ) : <EOL> self . _info ( "<STR_LIT>" ) <EOL> self . _info ( "<STR_LIT>" ) <EOL> if path . exists ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) ) : <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> import_testcase = True <EOL> import_user = True <EOL> import_reverse = True <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:r>' ) as fp : <EOL> for line in fp . readlines ( ) : <EOL> if '<STR_LIT>' in line : <EOL> import_testcase = False <EOL> if '<STR_LIT>' in line : <EOL> import_user = False <EOL> if '<STR_LIT>' in line : <EOL> import_reverse = False <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:a>' ) as fp : <EOL> if import_testcase : <EOL> fp . write ( "<STR_LIT>" ) <EOL> if import_user : <EOL> fp . write ( "<STR_LIT>" ) <EOL> if import_reverse : <EOL> fp . write ( "<STR_LIT>" ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:w>' ) as fp : <EOL> fp . write ( "<STR_LIT>" ) <EOL> fp . write ( "<STR_LIT>" ) <EOL> fp . write ( "<STR_LIT>" ) <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app ) , <NUM_LIT:1> ) <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:r>' ) as fp : <EOL> content = fp . read ( ) <EOL> if "<STR_LIT>" . format ( self . model ) in content : <EOL> self . _info ( '<STR_LIT>' . format ( <EOL> self . SCAFFOLD_APPS_DIR , self . app , self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> else : <EOL> with open ( "<STR_LIT>" . format ( self . SCAFFOLD_APPS_DIR , self . app ) , '<STR_LIT:a>' ) as fp : <EOL> fp . write ( TESTS_CONTENT % { <EOL> '<STR_LIT>' : self . app , <EOL> '<STR_LIT>' : self . model , <EOL> '<STR_LIT>' : self . model . lower ( ) , <EOL> } ) <EOL> self . _info ( '<STR_LIT>' . format ( self . SCAFFOLD_APPS_DIR , self . app , <EOL> self . model . lower ( ) ) , <NUM_LIT:1> ) <EOL> def run ( self ) : <EOL> if not self . app : <EOL> sys . exit ( "<STR_LIT>" ) <EOL> if not self . app . isalnum ( ) : <EOL> sys . exit ( "<STR_LIT>" ) <EOL> self . create_app ( ) <EOL> if self . model : <EOL> self . create_model ( ) <EOL> self . create_views ( ) <EOL> self . create_admin ( ) <EOL> self . create_forms ( ) <EOL> self . create_urls ( ) <EOL> self . create_templates ( ) <EOL> self . create_tests ( ) </s>
