#NEWLINE# def _directory_checksum( resources_dir ) : #NEWLINE# #INDENT# 'Returns a hash of the contents of resources_dir.\n\n    The hash is based purely on the names, mtimes, and modes of the\n    files, and not on the contents or other metadata.\n\n    ' #NEWLINE# output_sha1 = hashlib . sha1 ( ) #NEWLINE# for ( dirname , subdirs , files ) in os . walk ( resources_dir ) : #NEWLINE# #INDENT# if ( not dirname . startswith ( resources_dir ) ) : #NEWLINE# #INDENT# raise AssertionError ( ( 'Expected %r to start with root directory %r' % ( dirname , resources_dir ) ) ) #NEWLINE# #UNINDENT# relative_dirname = dirname [ len ( resources_dir ) : ] #NEWLINE# dir_stat = os . lstat ( dirname ) #NEWLINE# if ( not relative_dirname . startswith ( '/' ) ) : #NEWLINE# #INDENT# relative_dirname = ( '/' + relative_dirname ) #NEWLINE# #UNINDENT# fields = [ relative_dirname , str ( dir_stat . st_mode ) , str ( int ( ( dir_stat . st_mtime * 1000 ) ) ) ] #NEWLINE# output_sha1 . update ( b'' . join ( ( ( s . encode ( 'utf-8' ) + b'\x00' ) for s in fields ) ) ) #NEWLINE# for filename in sorted ( files ) : #NEWLINE# #INDENT# relative_filename = os . path . join ( relative_dirname , filename ) #NEWLINE# true_filename = os . path . join ( dirname , filename ) #NEWLINE# file_stat = os . lstat ( true_filename ) #NEWLINE# fields = [ relative_filename , str ( file_stat . st_mode ) , str ( int ( ( file_stat . st_mtime * 1000 ) ) ) ] #NEWLINE# output_sha1 . update ( b'' . join ( ( ( s . encode ( 'utf-8' ) + b'\x00' ) for s in fields ) ) ) #NEWLINE# #UNINDENT# subdirs . sort ( ) #NEWLINE# #UNINDENT# return output_sha1 . hexdigest ( )