wsa.py
def mkwsa(dir, name, js, css, config_version, template, manifest, force):
    """ Command line template for creating a basic web-standard-apps module """
    module_dir = os.path.join(dir, name)
    parent_dir = os.path.abspath(os.path.join(module_dir, os.pardir))

    static_dir = os.path.join(module_dir, "static")
    css_dir = os.path.join(static_dir, "css")
    css_modules = "modules"
    css_modules_dir = os.path.join(css_dir, "modules")
    js_dir = os.path.join(static_dir, "js")
    js_modules = "modules"
    js_modules_dir = os.path.join(js_dir, "modules")

    site_config_dir = os.path.join(js_dir, "siteconfig")
    site_config_module_dir = os.path.join(site_config_dir, "modules")
    site_config_file = os.path.join(site_config_module_dir, "{}-siteconfig.json".format(name))

    template_dir = os.path.join(module_dir, "templates")
    template_module_dir = os.path.join(template_dir, "modules")
    template_module_name_dir = os.path.join(template_module_dir, name)
    template_module_file = os.path.join(template_module_name_dir, "{}-{}".format(name, template))

    click.echo("Creating module named {} in {} ...".format(name, dir))

    if os.path.isdir(module_dir):
        if not force:
            click.echo("Directory already exists, use --force option to overwrite module setup settings")
            sys.exit()
    else:
        # create base module folder
        os.mkdir(module_dir)

    # setup python package
    click.echo("Creating __init__.py file ...")
    with open(os.path.join(module_dir, "__init__.py"), 'wb') as fp:
        output = "# -*- coding: utf-8 -*-"
        content = six.u(output)
        fp.write(content)

    click.echo("Creating modules.py file in {} ...".format(module_dir))
    with open(os.path.join(DIR, "defaults/modules.py"), 'rb') as fp:
        content = fp.read()
        content = content.format(name=name)
        data = six.u(content)
        with open(os.path.join(module_dir, "modules.py"), 'wb') as fp_new:
            fp_new.write(data)

    # setup template folder structure and default template
    create_dir(template_dir)
    create_dir(template_module_dir)
    create_dir(template_module_name_dir)

    click.echo("Creating {}.html file in {} ...".format(template_module_file, template_module_name_dir))
    with open("{}.html".format(template_module_file), 'wb') as fp:
        output = '<div class="{}-container"></div>'.format(name)
        content = six.u(output)
        fp.write(content)

    # setup static folder structure and config files
    create_dir(static_dir)
    create_dir(css_dir)
    create_dir(js_dir)

    create_dir(site_config_dir)
    create_dir(site_config_module_dir)

    default_siteconfig['version'] = config_version
    default_siteconfig['siteModules'][name] = {}

    # create js modules directory and templated js file
    if js:
        create_dir(js_modules_dir)
        click.echo("Creating {}.js file in {} ...".format(name, js_modules_dir))
        with open(os.path.join(DIR, "defaults/template.js"), 'rb') as fp:
            content = fp.read()
            data = six.u(content)
            with open(os.path.join(js_modules_dir, "{}.js".format(name)), 'wb') as fp_new:
                fp_new.write(data)
        default_siteconfig['siteModules'][name]['path'] = "{}/{}".format(js_modules, name)

    # create css modules directory and templated css file
    if css:
        create_dir(css_modules_dir)
        click.echo("Creating {}.css file in {} ...".format(name, css_modules_dir))
        with open(os.path.join(css_modules_dir, "{}.css".format(name)), 'wb') as fp:
            output = '.{}-container {}'.format(name, "{}")
            content = six.u(output)
            fp.write(content)
        default_siteconfig['siteModules'][name]['css'] = "{}/{}".format(css_modules, name)

    click.echo("Creating {}-siteconfig.json file in {} ..." \
               .format(name, site_config_module_dir))
    create_json(site_config_file, default_siteconfig)

    if manifest:
        append_manifest(parent_dir, module_dir, name)

    click.echo("---------------------------------\n")
    click.echo("Successfully installed {} module!".format(name))
    click.echo("Next steps:")
    click.echo("\t1.) Add {} to INSTALLED_APPS in uscp-web/uscp-web/settings/base.py".format(name))
    click.echo("\t2.) Create module in PRESTO")
    click.echo("\t3.) Add module to layout of choice")
 Command line template for creating a basic web-standard-apps module 
Command line template for creating a basic web-standard-apps module
Command line template for creating a basic web - standard - apps module
def mkwsa(dir, name, js, css, config_version, template, manifest, force):
    module_dir = os.path.join(dir, name)
    parent_dir = os.path.abspath(os.path.join(module_dir, os.pardir))
    static_dir = os.path.join(module_dir, "static")
    css_dir = os.path.join(static_dir, "css")
    css_modules = "modules"
    css_modules_dir = os.path.join(css_dir, "modules")
    js_dir = os.path.join(static_dir, "js")
    js_modules = "modules"
    js_modules_dir = os.path.join(js_dir, "modules")
    site_config_dir = os.path.join(js_dir, "siteconfig")
    site_config_module_dir = os.path.join(site_config_dir, "modules")
    site_config_file = os.path.join(site_config_module_dir, "{}-siteconfig.json".format(name))
    template_dir = os.path.join(module_dir, "templates")
    template_module_dir = os.path.join(template_dir, "modules")
    template_module_name_dir = os.path.join(template_module_dir, name)
    template_module_file = os.path.join(template_module_name_dir, "{}-{}".format(name, template))
    click.echo("Creating module named {} in {} ...".format(name, dir))
    if os.path.isdir(module_dir):
        if not force:
            click.echo("Directory already exists, use --force option to overwrite module setup settings")
            sys.exit()
    else:
        os.mkdir(module_dir)
    click.echo("Creating __init__.py file ...")
    with open(os.path.join(module_dir, "__init__.py"), 'wb') as fp:
        output = "# -*- coding: utf-8 -*-"
        content = six.u(output)
        fp.write(content)
    click.echo("Creating modules.py file in {} ...".format(module_dir))
    with open(os.path.join(DIR, "defaults/modules.py"), 'rb') as fp:
        content = fp.read()
        content = content.format(name=name)
        data = six.u(content)
        with open(os.path.join(module_dir, "modules.py"), 'wb') as fp_new:
            fp_new.write(data)
    create_dir(template_dir)
    create_dir(template_module_dir)
    create_dir(template_module_name_dir)
    click.echo("Creating {}.html file in {} ...".format(template_module_file, template_module_name_dir))
    with open("{}.html".format(template_module_file), 'wb') as fp:
        output = '<div class="{}-container"></div>'.format(name)
        content = six.u(output)
        fp.write(content)
    create_dir(static_dir)
    create_dir(css_dir)
    create_dir(js_dir)
    create_dir(site_config_dir)
    create_dir(site_config_module_dir)
    default_siteconfig['version'] = config_version
    default_siteconfig['siteModules'][name] = {}
    if js:
        create_dir(js_modules_dir)
        click.echo("Creating {}.js file in {} ...".format(name, js_modules_dir))
        with open(os.path.join(DIR, "defaults/template.js"), 'rb') as fp:
            content = fp.read()
            data = six.u(content)
            with open(os.path.join(js_modules_dir, "{}.js".format(name)), 'wb') as fp_new:
                fp_new.write(data)
        default_siteconfig['siteModules'][name]['path'] = "{}/{}".format(js_modules, name)
    if css:
        create_dir(css_modules_dir)
        click.echo("Creating {}.css file in {} ...".format(name, css_modules_dir))
        with open(os.path.join(css_modules_dir, "{}.css".format(name)), 'wb') as fp:
            output = '.{}-container {}'.format(name, "{}")
            content = six.u(output)
            fp.write(content)
        default_siteconfig['siteModules'][name]['css'] = "{}/{}".format(css_modules, name)
    click.echo("Creating {}-siteconfig.json file in {} ..." \
               .format(name, site_config_module_dir))
    create_json(site_config_file, default_siteconfig)
    if manifest:
        append_manifest(parent_dir, module_dir, name)
    click.echo("---------------------------------\n")
    click.echo("Successfully installed {} module!".format(name))
    click.echo("Next steps:")
    click.echo("\t1.) Add {} to INSTALLED_APPS in uscp-web/uscp-web/settings/base.py".format(name))
    click.echo("\t2.) Create module in PRESTO")
    click.echo("\t3.) Add module to layout of choice")
def mkwsa ( dir , name , js , css , config_version , template , manifest , force ) : module_dir = os . path . join ( dir , name ) parent_dir = os . path . abspath ( os . path . join ( module_dir , os . pardir ) ) static_dir = os . path . join ( module_dir , "static" ) css_dir = os . path . join ( static_dir , "css" ) css_modules = "modules" css_modules_dir = os . path . join ( css_dir , "modules" ) js_dir = os . path . join ( static_dir , "js" ) js_modules = "modules" js_modules_dir = os . path . join ( js_dir , "modules" ) site_config_dir = os . path . join ( js_dir , "siteconfig" ) site_config_module_dir = os . path . join ( site_config_dir , "modules" ) site_config_file = os . path . join ( site_config_module_dir , "{}-siteconfig.json" . format ( name ) ) template_dir = os . path . join ( module_dir , "templates" ) template_module_dir = os . path . join ( template_dir , "modules" ) template_module_name_dir = os . path . join ( template_module_dir , name ) template_module_file = os . path . join ( template_module_name_dir , "{}-{}" . format ( name , template ) ) click . echo ( "Creating module named {} in {} ..." . format ( name , dir ) ) if os . path . isdir ( module_dir ) : if not force : click . echo ( "Directory already exists, use --force option to overwrite module setup settings" ) sys . exit ( ) else : os . mkdir ( module_dir ) click . echo ( "Creating __init__.py file ..." ) with open ( os . path . join ( module_dir , "__init__.py" ) , 'wb' ) as fp : output = "# -*- coding: utf-8 -*-" content = six . u ( output ) fp . write ( content ) click . echo ( "Creating modules.py file in {} ..." . format ( module_dir ) ) with open ( os . path . join ( DIR , "defaults/modules.py" ) , 'rb' ) as fp : content = fp . read ( ) content = content . format ( name = name ) data = six . u ( content ) with open ( os . path . join ( module_dir , "modules.py" ) , 'wb' ) as fp_new : fp_new . write ( data ) create_dir ( template_dir ) create_dir ( template_module_dir ) create_dir ( template_module_name_dir ) click . echo ( "Creating {}.html file in {} ..." . format ( template_module_file , template_module_name_dir ) ) with open ( "{}.html" . format ( template_module_file ) , 'wb' ) as fp : output = '<div class="{}-container"></div>' . format ( name ) content = six . u ( output ) fp . write ( content ) create_dir ( static_dir ) create_dir ( css_dir ) create_dir ( js_dir ) create_dir ( site_config_dir ) create_dir ( site_config_module_dir ) default_siteconfig [ 'version' ] = config_version default_siteconfig [ 'siteModules' ] [ name ] = { } if js : create_dir ( js_modules_dir ) click . echo ( "Creating {}.js file in {} ..." . format ( name , js_modules_dir ) ) with open ( os . path . join ( DIR , "defaults/template.js" ) , 'rb' ) as fp : content = fp . read ( ) data = six . u ( content ) with open ( os . path . join ( js_modules_dir , "{}.js" . format ( name ) ) , 'wb' ) as fp_new : fp_new . write ( data ) default_siteconfig [ 'siteModules' ] [ name ] [ 'path' ] = "{}/{}" . format ( js_modules , name ) if css : create_dir ( css_modules_dir ) click . echo ( "Creating {}.css file in {} ..." . format ( name , css_modules_dir ) ) with open ( os . path . join ( css_modules_dir , "{}.css" . format ( name ) ) , 'wb' ) as fp : output = '.{}-container {}' . format ( name , "{}" ) content = six . u ( output ) fp . write ( content ) default_siteconfig [ 'siteModules' ] [ name ] [ 'css' ] = "{}/{}" . format ( css_modules , name ) click . echo ( "Creating {}-siteconfig.json file in {} ..." . format ( name , site_config_module_dir ) ) create_json ( site_config_file , default_siteconfig ) if manifest : append_manifest ( parent_dir , module_dir , name ) click . echo ( "---------------------------------\n" ) click . echo ( "Successfully installed {} module!" . format ( name ) ) click . echo ( "Next steps:" ) click . echo ( "\t1.) Add {} to INSTALLED_APPS in uscp-web/uscp-web/settings/base.py" . format ( name ) ) click . echo ( "\t2.) Create module in PRESTO" ) click . echo ( "\t3.) Add module to layout of choice" )
Command line template for creating a basic web-standard-apps module
Command line template for creating a basic web - standard - apps module
""" Command line template for creating a basic web-standard-apps module """ # create base module folder # setup python package # setup template folder structure and default template # setup static folder structure and config files # create js modules directory and templated js file # create css modules directory and templated css file
dir
name
js
css
config_version
template
manifest
force