| Conditions | 6 | 
| Total Lines | 86 | 
| Lines | 0 | 
| Ratio | 0 % | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | #!/usr/bin/env python  | 
            ||
| 40 | |||
| 41 | @click.command(context_settings=dict(help_option_names=[u'-h', u'--help']))  | 
            ||
| 42 | @click.version_option(__version__, u'-V', u'--version', message=version_msg())  | 
            ||
| 43 | @click.argument(u'template')  | 
            ||
| 44 | @click.option(  | 
            ||
| 45 | u'--no-input', is_flag=True,  | 
            ||
| 46 | help=u'Do not prompt for parameters and only use cookiecutter.json '  | 
            ||
| 47 | u'file content',  | 
            ||
| 48 | )  | 
            ||
| 49 | @click.option(  | 
            ||
| 50 | u'-c', u'--checkout',  | 
            ||
| 51 | help=u'branch, tag or commit to checkout after git clone',  | 
            ||
| 52 | )  | 
            ||
| 53 | @click.option(  | 
            ||
| 54 | '-v', '--verbose',  | 
            ||
| 55 | is_flag=True, help='Print debug information', default=False  | 
            ||
| 56 | )  | 
            ||
| 57 | @click.option(  | 
            ||
| 58 | u'--replay', is_flag=True,  | 
            ||
| 59 | help=u'Do not prompt for parameters and only use information entered '  | 
            ||
| 60 | u'previously',  | 
            ||
| 61 | )  | 
            ||
| 62 | @click.option(  | 
            ||
| 63 | u'-f', u'--overwrite-if-exists', is_flag=True,  | 
            ||
| 64 | help=u'Overwrite the contents of the output directory if it already exists'  | 
            ||
| 65 | )  | 
            ||
| 66 | @click.option(  | 
            ||
| 67 | u'-o', u'--output-dir', default='.', type=click.Path(),  | 
            ||
| 68 | help=u'Where to output the generated project dir into'  | 
            ||
| 69 | )  | 
            ||
| 70 | @click.option(  | 
            ||
| 71 | u'--config-file', type=click.Path(), default=USER_CONFIG_PATH,  | 
            ||
| 72 | help=u'User configuration file'  | 
            ||
| 73 | )  | 
            ||
| 74 | @click.option(  | 
            ||
| 75 | u'--default-config', is_flag=True,  | 
            ||
| 76 | help=u'Do not load a config file. Use the defaults instead'  | 
            ||
| 77 | )  | 
            ||
| 78 | def main(template, no_input, checkout, verbose, replay, overwrite_if_exists,  | 
            ||
| 79 | output_dir, config_file, default_config):  | 
            ||
| 80 | """Create a project from a Cookiecutter project template (TEMPLATE)."""  | 
            ||
| 81 | if verbose:  | 
            ||
| 82 | logging.basicConfig(  | 
            ||
| 83 | format=u'%(levelname)s %(filename)s: %(message)s',  | 
            ||
| 84 | level=logging.DEBUG  | 
            ||
| 85 | )  | 
            ||
| 86 | else:  | 
            ||
| 87 | # Log info and above to console  | 
            ||
| 88 | logging.basicConfig(  | 
            ||
| 89 | format=u'%(levelname)s: %(message)s',  | 
            ||
| 90 | level=logging.INFO  | 
            ||
| 91 | )  | 
            ||
| 92 | |||
| 93 | try:  | 
            ||
| 94 | # If you _need_ to support a local template in a directory  | 
            ||
| 95 | # called 'help', use a qualified path to the directory.  | 
            ||
| 96 | if template == u'help':  | 
            ||
| 97 | click.echo(click.get_current_context().get_help())  | 
            ||
| 98 | sys.exit(0)  | 
            ||
| 99 | |||
| 100 | user_config = None if default_config else config_file  | 
            ||
| 101 | |||
| 102 | cookiecutter(  | 
            ||
| 103 | template, checkout, no_input,  | 
            ||
| 104 | replay=replay,  | 
            ||
| 105 | overwrite_if_exists=overwrite_if_exists,  | 
            ||
| 106 | output_dir=output_dir,  | 
            ||
| 107 | config_file=user_config  | 
            ||
| 108 | )  | 
            ||
| 109 | except (OutputDirExistsException,  | 
            ||
| 110 | InvalidModeException,  | 
            ||
| 111 | FailedHookException,  | 
            ||
| 112 | UnknownExtension,  | 
            ||
| 113 | RepositoryNotFound) as e:  | 
            ||
| 114 | click.echo(e)  | 
            ||
| 115 | sys.exit(1)  | 
            ||
| 116 | except UndefinedVariableInTemplate as undefined_err:  | 
            ||
| 117 |         click.echo('{}'.format(undefined_err.message)) | 
            ||
| 118 |         click.echo('Error message: {}'.format(undefined_err.error.message)) | 
            ||
| 119 | |||
| 120 | context_str = json.dumps(  | 
            ||
| 121 | undefined_err.context,  | 
            ||
| 122 | indent=4,  | 
            ||
| 123 | sort_keys=True  | 
            ||
| 124 | )  | 
            ||
| 125 |         click.echo('Context: {}'.format(context_str)) | 
            ||
| 126 | sys.exit(1)  | 
            ||
| 131 |