#NEWLINE# def crash_report( self , exception , args ) : #NEWLINE# #INDENT# '\n        Create a crash report and ask the user to create a GitHub issue.\n\n        :param Exception exception: some uncaught exception\n        :param ArgumentParser args: original arguments for the command.\n        ' #NEWLINE# ( fd , report_file ) = mkstemp ( suffix = '.jigcrash' ) #NEWLINE# exc_info = sys . exc_info ( ) #NEWLINE# report_contents = dedent ( '\n            Arguments:\n\n            {args}\n\n            Traceback:\n\n            {traceback}\n            ' ) . strip ( ) . format ( args = str ( args ) , traceback = '' . join ( traceback . format_exception ( * exc_info ) ) ) #NEWLINE# with open ( report_file , 'w' ) as fh : #NEWLINE# #INDENT# fh . write ( ( report_contents + '\n' ) ) #NEWLINE# #UNINDENT# message = dedent ( '\n            --- CRASH REPORT ---\n\n            Jig has failed to operate as expected.\n\n            A crash report has been created: {report_file}\n\n            Please visit http://github.com/robmadole/jig/issues and file\n            an Issue and use the contents of this crash report in the description.\n\n            --- CRASH REPORT ---\n            ' ) . strip ( ) . format ( report_file = report_file ) #NEWLINE# sys . stderr . write ( ( message + '\n' ) )