def mkproject_cmd(argv):
    """Create a new project directory and its associated virtualenv."""
    if '-l' in argv or '--list' in argv:
        templates = [t.name[9:] for t in workon_home.glob("template_*")]
        print("Available project templates:", *templates, sep='\n')
        return

    parser = mkvirtualenv_argparser()
    parser.add_argument('envname')
    parser.add_argument(
        '-t', action='append', default=[], dest='templates', help='Multiple \
templates may be selected.  They are applied in the order specified on the \
command line.')
    parser.add_argument(
        '-l', '--list', action='store_true', help='List available templates.')

    args, rest = parser.parse_known_args(argv)

    projects_home = Path(os.environ.get('PROJECT_HOME', '.'))
    if not projects_home.exists():
        sys.exit('ERROR: Projects directory %s does not exist. \
Create it or set PROJECT_HOME to an existing directory.' % projects_home)

    project = (projects_home / args.envname).absolute()
    if project.exists():
        sys.exit('Project %s already exists.' % args.envname)

    mkvirtualenv(args.envname, args.python, args.packages, project.absolute(),
                 args.requirements, rest)

    project.mkdir()

    for template_name in args.templates:
        template = workon_home / ("template_" + template_name)
        inve(args.envname, str(template), args.envname, str(project))
    if args.activate:
        shell(args.envname, cwd=str(project))
def mkproject_cmd ( argv ) : if '-l' in argv or '--list' in argv : templates = [ t . name [ 9 : ] for t in workon_home . glob ( "template_*" ) ] print ( "Available project templates:" , * templates , sep = '\n' ) return parser = mkvirtualenv_argparser ( ) parser . add_argument ( 'envname' ) parser . add_argument ( '-t' , action = 'append' , default = [ ] , dest = 'templates' , help = 'Multiple \
templates may be selected.  They are applied in the order specified on the \
command line.' ) parser . add_argument ( '-l' , '--list' , action = 'store_true' , help = 'List available templates.' ) args , rest = parser . parse_known_args ( argv ) projects_home = Path ( os . environ . get ( 'PROJECT_HOME' , '.' ) ) if not projects_home . exists ( ) : sys . exit ( 'ERROR: Projects directory %s does not exist. \
Create it or set PROJECT_HOME to an existing directory.' % projects_home ) project = ( projects_home / args . envname ) . absolute ( ) if project . exists ( ) : sys . exit ( 'Project %s already exists.' % args . envname ) mkvirtualenv ( args . envname , args . python , args . packages , project . absolute ( ) , args . requirements , rest ) project . mkdir ( ) for template_name in args . templates : template = workon_home / ( "template_" + template_name ) inve ( args . envname , str ( template ) , args . envname , str ( project ) ) if args . activate : shell ( args . envname , cwd = str ( project ) )
Create a new project directory and its associated virtualenv.