'Initialize a new Zappa project by creating a new zappa_settings.json in a guided process.
This should probably be broken up into few separate componants once it\'s stable.
Testing these inputs requires monkeypatching with mock, which isn\'t pretty.'

def init(self, settings_file=u'zappa_settings.json'):

    self.check_venv()
    if os.path.isfile(settings_file):
        raise ClickException(((u'This    project    already    has    a    ' + click.style(u'{0!s}    file'.format(settings_file), fg=u'red', bold=True)) + u'!'))
    click.echo(click.style(u'\n\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557    \u2588\u2588\u2588\u2588\u2588\u2557    \u2588\u2588\u2588\u2588\u2588\u2588\u2557    \u2588\u2588\u2588\u2588\u2588\u2588\u2557        \u2588\u2588\u2588\u2588\u2588\u2557\n\u255a\u2550\u2550\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\n        \u2588\u2588\u2588\u2554\u255d    \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\n    \u2588\u2588\u2588\u2554\u255d        \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u255d    \u2588\u2588\u2554\u2550\u2550\u2550\u255d    \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\n\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551        \u2588\u2588\u2551\u2588\u2588\u2551                    \u2588\u2588\u2551                    \u2588\u2588\u2551        \u2588\u2588\u2551\n\u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d\u255a\u2550\u255d        \u255a\u2550\u255d\u255a\u2550\u255d                    \u255a\u2550\u255d                    \u255a\u2550\u255d        \u255a\u2550\u255d\n', fg=u'green', bold=True))
    click.echo(((click.style(u'Welcome    to    ', bold=True) + click.style(u'Zappa', fg=u'green', bold=True)) + click.style(u'!\n', bold=True)))
    click.echo((click.style(u'Zappa', bold=True) + u'    is    a    system    for    running    server-less    Python    web    applications    on    AWS    Lambda    and    AWS    API    Gateway.'))
    click.echo(u'This    `init`    command    will    help    you    create    and    configure    your    new    Zappa    deployment.')
    click.echo(u"Let's    get    started!\n")
    while True:
        click.echo(((((((u"Your    Zappa    configuration    can    support    multiple    production    stages,    like    '" + click.style(u'dev', bold=True)) + u"',    '") + click.style(u'staging', bold=True)) + u"',    and    '") + click.style(u'production', bold=True)) + u"'."))
        env = (input(u"What    do    you    want    to    call    this    environment    (default    'dev'):    ") or u'dev')
        try:
            self.check_stage_name(env)
            break
        except ValueError:
            click.echo(click.style(u'Stage    names    must    match    a-zA-Z0-9_', fg=u'red'))
    session = botocore.session.Session()
    config = session.full_config
    profiles = config.get(u'profiles', {})
    profile_names = list(profiles.keys())
    click.echo(u"\nAWS    Lambda    and    API    Gateway    are    only    available    in    certain    regions.    Let's    check    to    make    sure    you    have    a    profile    set    up    in    one    that    will    work.")
    if (not profile_names):
        (profile_name, profile) = (None, None)
        click.echo(u"We    couldn't    find    an    AWS    profile    to    use.    Before    using    Zappa,    you'll    need    to    set    one    up.    See    here    for    more    info:    {}".format(click.style(BOTO3_CONFIG_DOCS_URL, fg=u'blue', underline=True)))
    elif (len(profile_names) == 1):
        profile_name = profile_names[0]
        profile = profiles[profile_name]
        click.echo(u'Okay,    using    profile    {}!'.format(click.style(profile_name, bold=True)))
    else:
        if (u'default' in profile_names):
            default_profile = [p for p in profile_names if (p == u'default')][0]
        else:
            default_profile = profile_names[0]
        while True:
            profile_name = (input(u"We    found    the    following    profiles:    {},    and    {}.    Which    would    you    like    us    to    use?    (default    '{}'):    ".format(u',    '.join(profile_names[:(-1)]), profile_names[(-1)], default_profile)) or default_profile)
            if (profile_name in profiles):
                profile = profiles[profile_name]
                break
            else:
                click.echo(u'Please    enter    a    valid    name    for    your    AWS    profile.')
    profile_region = (profile.get(u'region') if profile else None)
    click.echo(((u'\nYour    Zappa    deployments    will    need    to    be    uploaded    to    a    ' + click.style(u'private    S3    bucket', bold=True)) + u'.'))
    click.echo(u"If    you    don't    have    a    bucket    yet,    we'll    create    one    for    you    too.")
    default_bucket = (u'zappa-' + u''.join((random.choice((string.ascii_lowercase + string.digits)) for _ in range(9))))
    bucket = (input((u"What    do    you    want    call    your    bucket?    (default    '%s'):    " % default_bucket)) or default_bucket)
    try:
        import django
        has_django = True
    except ImportError as e:
        has_django = False
    try:
        import flask
        has_flask = True
    except ImportError as e:
        has_flask = False
    print u''
    if has_django:
        click.echo(((u'It    looks    like    this    is    a    ' + click.style(u'Django', bold=True)) + u'    application!'))
        click.echo(((u'What    is    the    ' + click.style(u'module    path', bold=True)) + u"    to    your    projects's    Django    settings?"))
        django_settings = None
        matches = detect_django_settings()
        while (django_settings in [None, u'']):
            if matches:
                click.echo((u'We    discovered:    ' + click.style(u',    '.join((u'{}'.format(i) for (v, i) in enumerate(matches))), bold=True)))
                django_settings = (input((u"Where    are    your    project's    settings?    (default    '%s'):    " % matches[0])) or matches[0])
            else:
                click.echo(u"(This    will    likely    be    something    like    'your_project.settings')")
                django_settings = input(u"Where    are    your    project's    settings?:    ")
        django_settings = django_settings.replace(u"'", u'')
        django_settings = django_settings.replace(u'"', u'')
    else:
        matches = None
        if has_flask:
            click.echo(((u'It    looks    like    this    is    a    ' + click.style(u'Flask', bold=True)) + u'    application.'))
            matches = detect_flask_apps()
        click.echo(((u"What's    the    " + click.style(u'modular    path', bold=True)) + u"    to    your    app's    function?"))
        click.echo(u"This    will    likely    be    something    like    'your_module.app'.")
        app_function = None
        while (app_function in [None, u'']):
            if matches:
                click.echo((u'We    discovered:    ' + click.style(u',    '.join((u'{}'.format(i) for (v, i) in enumerate(matches))), bold=True)))
                app_function = (input((u"Where    is    your    app's    function?    (default    '%s'):    " % matches[0])) or matches[0])
            else:
                app_function = input(u"Where    is    your    app's    function?:    ")
        app_function = app_function.replace(u"'", u'')
        app_function = app_function.replace(u'"', u'')
    click.echo(((u'\nYou    can    optionally    deploy    to    ' + click.style(u'all    available    regions', bold=True)) + u'    in    order    to    provide    fast    global    service.'))
    click.echo(u"If    you    are    using    Zappa    for    the    first    time,    you    probably    don't    want    to    do    this!")
    global_deployment = False
    while True:
        global_type = input(((u'Would    you    like    to    deploy    this    application    ' + click.style(u'globally', bold=True)) + u"?    (default    'n')    [y/n/(p)rimary]:    "))
        if (not global_type):
            break
        if (global_type.lower() in [u'y', u'yes', u'p', u'primary']):
            global_deployment = True
            break
        if (global_type.lower() in [u'n', u'no']):
            global_deployment = False
            break
    if global_deployment:
        regions = API_GATEWAY_REGIONS
        if (global_type.lower() in [u'p', u'primary']):
            envs = [{((env + u'_') + region.replace(u'-', u'_')): {u'aws_region': region}} for region in regions if (u'-1' in region)]
        else:
            envs = [{((env + u'_') + region.replace(u'-', u'_')): {u'aws_region': region}} for region in regions]
    else:
        envs = [{env: {}}]
    zappa_settings = {}
    for each_env in envs:
        env_name = list(each_env.keys())[0]
        env_dict = each_env[env_name]
        env_bucket = bucket
        if global_deployment:
            env_bucket = ((bucket + u'-') + env_name).replace(u'_', u'-')
        env_zappa_settings = {env_name: {u's3_bucket': env_bucket}}
        if profile_name:
            env_zappa_settings[env_name][u'profile_name'] = profile_name
        if (u'aws_region' in env_dict):
            env_zappa_settings[env_name][u'aws_region'] = env_dict.get(u'aws_region')
        elif profile_region:
            env_zappa_settings[env_name][u'aws_region'] = profile_region
        zappa_settings.update(env_zappa_settings)
        if has_django:
            zappa_settings[env_name][u'django_settings'] = django_settings
        else:
            zappa_settings[env_name][u'app_function'] = app_function
    import json as json
    zappa_settings_json = json.dumps(zappa_settings, sort_keys=True, indent=4)
    click.echo(((u"\nOkay,    here's    your    " + click.style(u'zappa_settings.json', bold=True)) + u':\n'))
    click.echo(click.style(zappa_settings_json, fg=u'yellow', bold=False))
    confirm = (input(((u'\nDoes    this    look    ' + click.style(u'okay', bold=True, fg=u'green')) + u"?    (default    'y')    [y/n]:    ")) or u'yes')
    if (confirm[0] not in [u'y', u'Y', u'yes', u'YES']):
        click.echo(((u'' + click.style(u'Sorry', bold=True, fg=u'red')) + u'    to    hear    that!    Please    init    again.'))
        return
    with open(u'zappa_settings.json', u'w') as zappa_settings_file:
        zappa_settings_file.write(zappa_settings_json)
    if global_deployment:
        click.echo(((((u'\n' + click.style(u'Done', bold=True)) + u'!    You    can    also    ') + click.style(u'deploy    all', bold=True)) + u'    by    executing:\n'))
        click.echo(click.style(u' DCTB $    zappa    deploy    --all', bold=True))
        click.echo(((u'\nAfter    that,    you    can    ' + click.style(u'update', bold=True)) + u'    your    application    code    with:\n'))
        click.echo(click.style(u' DCTB $    zappa    update    --all', bold=True))
    else:
        click.echo(((((u'\n' + click.style(u'Done', bold=True)) + u'!    Now    you    can    ') + click.style(u'deploy', bold=True)) + u'    your    Zappa    application    by    executing:\n'))
        click.echo(click.style((u' DCTB $    zappa    deploy    %s' % env), bold=True))
        click.echo(((u'\nAfter    that,    you    can    ' + click.style(u'update', bold=True)) + u'    your    application    code    with:\n'))
        click.echo(click.style((u' DCTB $    zappa    update    %s' % env), bold=True))
    click.echo((((u'\nTo    learn    more,    check    out    our    project    page    on    ' + click.style(u'GitHub', bold=True)) + u'    here:    ') + click.style(u'https://github.com/Miserlou/Zappa', fg=u'cyan', bold=True)))
    click.echo((((u'and    stop    by    our    ' + click.style(u'Slack', bold=True)) + u'    channel    here:    ') + click.style(u'https://slack.zappa.io', fg=u'cyan', bold=True)))
    click.echo(u'\nEnjoy!,')
    click.echo(((u'    ~    Team    ' + click.style(u'Zappa', bold=True)) + u'!'))
    return
