#NEWLINE# def _get_default_cache_dir( self ) : #NEWLINE# #INDENT# def _unsafe_dir( ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Cannot determine safe temp directory.  You need to explicitly provide one.' ) #NEWLINE# #UNINDENT# tmpdir = tempfile . gettempdir ( ) #NEWLINE# if ( os . name == 'nt' ) : #NEWLINE# #INDENT# return tmpdir #NEWLINE# #UNINDENT# if ( not hasattr ( os , 'getuid' ) ) : #NEWLINE# #INDENT# _unsafe_dir ( ) #NEWLINE# #UNINDENT# dirname = ( '_jinja2-cache-%d' % os . getuid ( ) ) #NEWLINE# actual_dir = os . path . join ( tmpdir , dirname ) #NEWLINE# try : #NEWLINE# #INDENT# os . mkdir ( actual_dir , stat . S_IRWXU ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# if ( e . errno != errno . EEXIST ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# os . chmod ( actual_dir , stat . S_IRWXU ) #NEWLINE# actual_dir_stat = os . lstat ( actual_dir ) #NEWLINE# if ( ( actual_dir_stat . st_uid != os . getuid ( ) ) or ( not stat . S_ISDIR ( actual_dir_stat . st_mode ) ) or ( stat . S_IMODE ( actual_dir_stat . st_mode ) != stat . S_IRWXU ) ) : #NEWLINE# #INDENT# _unsafe_dir ( ) #NEWLINE# #UNINDENT# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# if ( e . errno != errno . EEXIST ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# #UNINDENT# actual_dir_stat = os . lstat ( actual_dir ) #NEWLINE# if ( ( self . st_uid != os . getuid ( ) ) or ( not stat . S_ISDIR ( actual_dir_stat . st_mode ) ) or ( stat . S_IMODE ( actual_dir_stat . st_mode ) != stat . S_IRWXU ) ) : #NEWLINE# #INDENT# _unsafe_dir ( ) #NEWLINE# #UNINDENT# return actual_dir