def get_named_tmpfile_from_ctx(ctx, filename, dir):
 filename = basic_util.strip_path(filename)
 for ctx_file in ctx.files():
  ctx_file_name = basic_util.strip_path(ctx_file)
  if (filename == ctx_file_name):
   try:
    fctx = ctx[ctx_file]
   except LookupError:
    fctx = None
    continue
   if fctx:
    fh = tempfile.NamedTemporaryFile('wb', prefix='tmp-toolshed-gntfc', dir=dir)
    tmp_filename = fh.name
    fh.close()
    fh = open(tmp_filename, 'wb')
    fh.write(fctx.data())
    fh.close()
    return tmp_filename
 return None

def get_named_tmpfile_from_ctx ( ctx , filename , dir ) : filename = basic_util . strip_path ( filename ) for ctx_file in ctx . files ( ) : ctx_file_name = basic_util . strip_path ( ctx_file ) if ( filename == ctx_file_name ) : try : fctx = ctx [ ctx_file ] except LookupError : fctx = None continue if fctx : fh = tempfile . NamedTemporaryFile ( 'wb' , prefix = 'tmp-toolshed-gntfc' , dir = dir ) tmp_filename = fh . name fh . close ( ) fh = open ( tmp_filename , 'wb' ) fh . write ( fctx . data ( ) ) fh . close ( ) return tmp_filename return None
return a named temporary file created from a specified file with a given name included in a repository changeset revision .