Exemplo n.º 1
0
def tac_file(options):
    """Generates the Twisted tac file from temnplate"""
    mgr=TemplateManager()
    t=mgr.get_sys_domain().get_template('tpl/tac.evoque')
    return t.evoque(
            app_name=options['app_name'],
            app_config=options['app_config']
    )
Exemplo n.º 2
0
def init_file(installPath, options):
    """Return the correct Init file for the current distribution."""
    mgr = TemplateManager()
    t = mgr.get_sys_domain().get_template(
        'rc.scripts/{0}.evoque'.format(distro))
    return t.evoque(app_name=options['app_name'],
                    app_desc=options['app_desc'],
                    app_file=options['app_file'],
                    app_log=options['app_log'],
                    app_share=installPath['share'])
Exemplo n.º 3
0
def project_file(options):
    """Generates the Goliat project file from template"""
    mgr = TemplateManager()
    t = mgr.get_sys_domain().get_template('tpl/project.evoque')
    return t.evoque(goliat_ver=options['goliat_ver'],
                    project_ver=options['app_version'],
                    app_name=options['app_name'],
                    app_desc=options['app_desc'],
                    app_layout=options['app_layout'],
                    app_port=options['app_port'])
Exemplo n.º 4
0
def main_js_file(options):
    """Generates the Goliat main application JavaScript file from template"""
    mgr = TemplateManager()
    t = mgr.get_sys_domain().get_template('tpl/mainJs.evoque')
    return t.evoque(
            app_name=options['app_name'].replace(' ', ''),
            app_version=options['app_version'],
            app_layout='Goliat.layout.'+''.join([p.capitalize() \
                for p in options['app_layout'].split('_')])
    )
Exemplo n.º 5
0
def main_js_file(options):
    """Generates the Goliat main application JavaScript file from template"""
    mgr=TemplateManager()
    t=mgr.get_sys_domain().get_template('tpl/mainJs.evoque')
    return t.evoque(
            app_name=options['app_name'].replace(' ', ''),
            app_version=options['app_version'],
            app_layout='Goliat.layout.'+''.join([p.capitalize() \
                for p in options['app_layout'].split('_')])
    )
Exemplo n.º 6
0
def init_file(installPath, options):
    """Return the correct Init file for the current distribution."""
    mgr=TemplateManager()
    t=mgr.get_sys_domain().get_template('rc.scripts/{0}.evoque'.format(distro))
    return t.evoque(
             app_name=options['app_name'],
             app_desc=options['app_desc'],
             app_file=options['app_file'],
             app_log=options['app_log'],
             app_share=installPath['share']
    )
Exemplo n.º 7
0
def project_file(options):
    """Generates the Goliat project file from template"""
    mgr=TemplateManager()
    t=mgr.get_sys_domain().get_template('tpl/project.evoque')
    return t.evoque(
            goliat_ver=options['goliat_ver'],
            project_ver=options['app_version'],
            app_name=options['app_name'],
            app_desc=options['app_desc'],
            app_layout=options['app_layout'],
            app_port=options['app_port']
    )
Exemplo n.º 8
0
def tac_file(options):
    """Generates the Twisted tac file from temnplate"""
    mgr = TemplateManager()
    t = mgr.get_sys_domain().get_template('tpl/tac.evoque')
    return t.evoque(app_name=options['app_name'],
                    app_config=options['app_config'])
Exemplo n.º 9
0
def schema_file():
    """Generates the Goliat database schema file template"""
    mgr = TemplateManager()
    t = mgr.get_sys_domain().get_template('tpl/schema.evoque')
    return t.evoque()
Exemplo n.º 10
0
def schema_file():
    """Generates the Goliat database schema file template"""
    mgr=TemplateManager()
    t=mgr.get_sys_domain().get_template('tpl/schema.evoque')
    return t.evoque()
Exemplo n.º 11
0
    def perform(self, args):
        cfg=self._look_at_cur_path()
        module_name, opts=self.parse_args(args)
        if not len(module_name):
            print self.long_help()
            sys.exit(-1)
        try:
            _schema=Schema('config/schema.yaml')
            _schema.fix_tables()
        except TypeError:
            if opts.get('model')!=None:
                print red('The schema is not defined.')
                sys.exit(-1)
        _module_model_import=''
        _module_get_schema_model=''

        if opts.get('path')==None:
            _module_register_path='"{0}"'.format(module_name.lower())
        else:
            _module_register_path='"{0}"'.format(opts['path'])
        if opts.get('model')!=None:
            if not check_model(opts['model']):
                print red(\
                '\n{0} model does not exist at the project schema.\nUse ' \
                'module -l or module --list to show a list of available ' \
                'models.'.format(\
                    opts['model'] if len(opts['model']) else 'Noname'))
                sys.exit(0)
            gen=Generator(opts['verbose'])
            _use_model=True
            _model_name=gen._generate_model_name(opts['model'])
            tmodel=gen.create_m(\
                opts['model'], _schema.find_table(opts['model']),
                _module_register_path)

            _module_model_import='from application.model.{0} import {1}' \
            .format(gen._generate_model_name(opts['model']),
                gen._generate_model_name(opts['model']))
            _module_get_schema_model='''def get_schema_model(self, request, **kwargs): 
        """Return the schema model %s architecture.""" 
        model_schema, model_view = %s.get_model_info() 
        if model_schema == None: 
            return json.dumps({
                "success" : False,
                "error" : "Unable to fetch a schema for model %s"
            })        
                
        return json.dumps({
            "success" : True,
            "model" : model_schema,
            "view" : model_view
        })'''%(gen._generate_model_name(opts['model']),
            gen._generate_model_name(opts['model']),
            opts['model'])

        print '\n'+bold('Generating {0} module...'.format(module_name))
        mgr=TemplateManager()
        t=mgr.get_sys_domain().get_template('tpl/module.evoque')
        module=t.evoque(
            module_file="application/controller/{0}".format(module_name),
            module_creation_date=datetime.now(),
            module_name=module_name,
            module_model_import=_module_model_import,
            module_register_path=_module_register_path,
            module_get_schema_model=_module_get_schema_model,
            use_model=_use_model,
            model_name=_model_name
        )
        if opts['dump']:
            if opts.get('model')!=None:
                print '\napplication/model/{0}.py'.format(tmodel['work'][0])
                print tmodel['work'][1]
            print '\napplication/controller/{0}.py'.format(module_name)
            print  module
        else :
            if opts.get('model')!=None:
                gen.write_model(tmodel['work'][0], tmodel['work'][1])
            fp=file('application/controller/{0}.py'.format(module_name), 'w')
            fp.write(module.encode('utf8'))
            fp.close()

        print bold('Module created successfully.')