def perform(self, args): opts=self.parse_args(args) try: _schema=Schema('config/schema.yaml') _schema.fix_tables() except TypeError: print red('The schema is not defined.') sys.exit(-1) gen=Generator(opts['verbose']) for model_name in _schema.get_tables_list(): print '\n'+bold('Generating {0} model...'.format(model_name)) templates=gen.create_b(model_name, _schema.find_table(model_name)) if opts['dump']: print '\napplication/model/base/{0}Base.py'.format( templates['base'][0]) print templates['base'][1] if templates.get('rel')!=None: for rel in templates['rel']: print '\n\napplication/model/relation/{0}.py'.format( rel[0]) print rel[1] else : gen.write_base_model(templates['base'][0], templates['base'][1]) if templates.get('rel')!=None: for rel in templates['rel']: gen.write_relation(rel[0], rel[1]) print bold('Model {0} created successfully.'.format(model_name))
def perform(self, args): opts = self.parse_args(args) try: _schema = Schema('config/schema.yaml') _schema.fix_tables() except TypeError: print red('The schema is not defined.') sys.exit(-1) gen = Generator(opts['verbose']) for model_name in _schema.get_tables_list(): print '\n' + bold('Generating {0} model...'.format(model_name)) templates = gen.create_b(model_name, _schema.find_table(model_name)) if opts['dump']: print '\napplication/model/base/{0}Base.py'.format( templates['base'][0]) print templates['base'][1] if templates.get('rel') != None: for rel in templates['rel']: print '\n\napplication/model/relation/{0}.py'.format( rel[0]) print rel[1] else: gen.write_base_model(templates['base'][0], templates['base'][1]) if templates.get('rel') != None: for rel in templates['rel']: gen.write_relation(rel[0], rel[1]) print bold('Model {0} created successfully.'.format(model_name))
def model_list(): """Return a list of available models at current schema""" try: _schema=Schema('config/schema.yaml') for table in _schema.get_tables_list(): print brown(table) except TypeError: print red('Schema is not defined.')
def model_list(): """Return a list of available models at current schema""" try: _schema = Schema('config/schema.yaml') for table in _schema.get_tables_list(): print brown(table) except TypeError: print red('Schema is not defined.')
def check_model(model_name): """Checks if a model given by model name exists at the current schema""" if not len(model_name): return False _schema=Schema('config/schema.yaml') if not model_name in _schema.get_tables_list(): return False return True
def check_model(model_name): """Checks if a model given by model name exists at the current schema""" if not len(model_name): return False _schema = Schema('config/schema.yaml') if not model_name in _schema.get_tables_list(): return False return True