#NEWLINE# @ contextmanager #NEWLINE# def make_context( self , context , silent_build = False , extra_context = None ) : #NEWLINE# #INDENT# "\n        Context manager for creating the context of the image\n\n        Arguments:\n\n        context - ``harpoon.option_spec.image_objs.Context``\n            Knows all the context related options\n\n        docker_file - ``harpoon.option_spec.image_objs.Dockerfile``\n            Knows what is in the dockerfile and it's mtime\n\n        silent_build - boolean\n            If True, then suppress printing out information\n\n        extra_context - List of (string, string)\n            First string represents the content to put in a file and the second\n            string represents where in the context this extra file should go\n        " #NEWLINE# with a_temp_file ( ) as tmpfile : #NEWLINE# #INDENT# t = tarfile . open ( mode = 'w' , fileobj = tmpfile ) #NEWLINE# for ( thing , mtime , arcname ) in self . find_mtimes ( context , silent_build ) : #NEWLINE# #INDENT# if mtime : #NEWLINE# #INDENT# os . utime ( thing , ( mtime , mtime ) ) #NEWLINE# #UNINDENT# log . debug ( 'Context: {0}' . format ( arcname ) ) #NEWLINE# t . add ( thing , arcname = arcname ) #NEWLINE# #UNINDENT# if self : #NEWLINE# #INDENT# extra = list ( extra_context ) #NEWLINE# for ( content , arcname ) in extra : #NEWLINE# #INDENT# mtime_match = re . search ( 'mtime\\((\\d+)\\)$' , arcname ) #NEWLINE# specified_mtime = ( None if ( not mtime_match ) else int ( mtime_match . groups ( ) [ 0 ] ) ) #NEWLINE# with self . the_context ( content , silent_build = silent_build ) as fle : #NEWLINE# #INDENT# if specified_mtime : #NEWLINE# #INDENT# os . utime ( fle . name , ( specified_mtime , specified_mtime ) ) #NEWLINE# #UNINDENT# log . debug ( 'Context: {0}' . format ( arcname ) ) #NEWLINE# t . add ( fle . name , arcname = arcname ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ( yield ContextWrapper ( t , tmpfile ) )