<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , print_function <EOL> import argparse <EOL> import os . path <EOL> import sys <EOL> from datetime import date <EOL> import pyscaffold <EOL> from . import info , repo , shell , structure , templates , utils <EOL> __author__ = "<STR_LIT>" <EOL> __copyright__ = "<STR_LIT>" <EOL> __license__ = "<STR_LIT>" <EOL> def parse_args ( args ) : <EOL> """<STR_LIT>""" <EOL> parser = argparse . ArgumentParser ( <EOL> description = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> dest = "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> required = False , <EOL> help = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT:description>" , <EOL> required = False , <EOL> help = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT:url>" , <EOL> required = False , <EOL> help = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" ) <EOL> license_choices = templates . licenses . keys ( ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> choices = license_choices , <EOL> required = False , <EOL> default = "<STR_LIT:none>" , <EOL> help = "<STR_LIT>" . format ( <EOL> choices = str ( license_choices ) , default = "<STR_LIT>" ) , <EOL> metavar = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" ) <EOL> group = parser . add_mutually_exclusive_group ( ) <EOL> group . add_argument ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> default = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> group . add_argument ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False , <EOL> help = "<STR_LIT>" ) <EOL> version = pyscaffold . __version__ <EOL> parser . add_argument ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:version>' , <EOL> version = '<STR_LIT>' . format ( ver = version ) ) <EOL> opts = vars ( parser . parse_args ( args ) ) <EOL> opts [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] . rstrip ( os . sep ) <EOL> return { k : v for k , v in opts . items ( ) if v is not None } <EOL> def get_default_opts ( project_name , ** aux_opts ) : <EOL> """<STR_LIT>""" <EOL> opts = parse_args ( [ project_name ] ) <EOL> aux_opts . pop ( '<STR_LIT>' , None ) <EOL> opts . update ( aux_opts ) <EOL> opts . setdefault ( '<STR_LIT>' , utils . make_valid_identifier ( opts [ '<STR_LIT>' ] ) ) <EOL> opts . setdefault ( '<STR_LIT>' , info . username ( ) ) <EOL> opts . setdefault ( '<STR_LIT:email>' , info . email ( ) ) <EOL> opts . setdefault ( '<STR_LIT>' , date . today ( ) . strftime ( '<STR_LIT>' ) ) <EOL> opts . setdefault ( '<STR_LIT>' , date . today ( ) . year ) <EOL> opts . setdefault ( '<STR_LIT>' , '<STR_LIT:none>' ) <EOL> opts . setdefault ( '<STR_LIT:description>' , '<STR_LIT>' ) <EOL> opts . setdefault ( '<STR_LIT:url>' , '<STR_LIT>' ) <EOL> opts . setdefault ( '<STR_LIT:version>' , pyscaffold . __version__ ) <EOL> opts . setdefault ( '<STR_LIT:title>' , <EOL> '<STR_LIT:=>' * len ( opts [ '<STR_LIT>' ] ) + '<STR_LIT:\n>' + opts [ '<STR_LIT>' ] + '<STR_LIT:\n>' + <EOL> '<STR_LIT:=>' * len ( opts [ '<STR_LIT>' ] ) ) <EOL> classifiers = [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> opts . setdefault ( '<STR_LIT>' , utils . list2str ( <EOL> classifiers , indent = <NUM_LIT:4> , brackets = False , quotes = False , sep = '<STR_LIT>' ) ) <EOL> opts . setdefault ( '<STR_LIT:url>' , '<STR_LIT>' ) <EOL> opts . setdefault ( '<STR_LIT>' , list ( ) ) <EOL> opts [ '<STR_LIT>' ] = utils . prepare_namespace ( opts [ '<STR_LIT>' ] ) <EOL> if opts [ '<STR_LIT>' ] : <EOL> opts [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> opts [ '<STR_LIT>' ] = "<STR_LIT:.>" . join ( [ opts [ '<STR_LIT>' ] [ - <NUM_LIT:1> ] , <EOL> opts [ '<STR_LIT>' ] ] ) <EOL> else : <EOL> opts [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> opts [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> if opts [ '<STR_LIT>' ] : <EOL> if not os . path . exists ( project_name ) : <EOL> raise RuntimeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( project = project_name ) ) <EOL> opts = info . project ( opts ) <EOL> opts [ '<STR_LIT>' ] = project_name <EOL> if opts [ '<STR_LIT>' ] : <EOL> opts [ '<STR_LIT>' ] = True <EOL> opts [ '<STR_LIT>' ] = opts [ '<STR_LIT>' ] <EOL> opts [ '<STR_LIT>' ] . append ( '<STR_LIT>' ) <EOL> if opts [ '<STR_LIT>' ] : <EOL> opts [ '<STR_LIT>' ] = True <EOL> return opts <EOL> def create_project ( opts ) : <EOL> """<STR_LIT>""" <EOL> if opts [ '<STR_LIT>' ] : <EOL> structure . create_django_proj ( opts ) <EOL> if opts [ '<STR_LIT>' ] : <EOL> structure . create_cookiecutter ( opts ) <EOL> proj_struct = structure . make_structure ( opts ) <EOL> structure . create_structure ( proj_struct , <EOL> update = opts [ '<STR_LIT>' ] or opts [ '<STR_LIT>' ] ) <EOL> if not opts [ '<STR_LIT>' ] and not repo . is_git_repo ( opts [ '<STR_LIT>' ] ) : <EOL> repo . init_commit_repo ( opts [ '<STR_LIT>' ] , proj_struct ) <EOL> def make_sanity_checks ( opts ) : <EOL> """<STR_LIT>""" <EOL> if not info . is_git_installed ( ) : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> if not info . is_git_configured ( ) : <EOL> raise RuntimeError ( <EOL> '<STR_LIT>' + <EOL> '<STR_LIT>' + <EOL> '<STR_LIT>' + <EOL> "<STR_LIT>" ) <EOL> if os . path . exists ( opts [ '<STR_LIT>' ] ) : <EOL> if not opts [ '<STR_LIT>' ] and not opts [ '<STR_LIT>' ] : <EOL> raise RuntimeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( dir = opts [ '<STR_LIT>' ] ) ) <EOL> if '<STR_LIT>' in opts : <EOL> if not utils . is_valid_identifier ( opts [ '<STR_LIT>' ] ) : <EOL> raise RuntimeError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( opts [ '<STR_LIT>' ] ) ) <EOL> def main ( args ) : <EOL> """<STR_LIT>""" <EOL> utils . check_setuptools_version ( ) <EOL> opts = parse_args ( args ) <EOL> make_sanity_checks ( opts ) <EOL> opts = get_default_opts ( opts [ '<STR_LIT>' ] , ** opts ) <EOL> create_project ( opts ) <EOL> if opts [ '<STR_LIT>' ] and not opts [ '<STR_LIT>' ] : <EOL> note = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> print ( note . format ( pyscaffold . __version__ ) ) <EOL> @ shell . called_process_error2exit_decorator <EOL> @ utils . exceptions2exit ( [ RuntimeError ] ) <EOL> def run ( ) : <EOL> """<STR_LIT>""" <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( sys . argv [ <NUM_LIT:1> : ] ) </s>
