Either ``local_files`` and/or ``context`` should be supplied.
    
    Will stage a ``local_files`` dictionary of path:filename pairs where path
    is relative to ``local_dir`` into a local tmp staging directory.
    
    Returns a path to the temporary local staging directory

def _stage_local_files(local_dir, local_files={}):
    """
    Either ``local_files`` and/or ``context`` should be supplied.
    
    Will stage a ``local_files`` dictionary of path:filename pairs where path
    is relative to ``local_dir`` into a local tmp staging directory.
    
    Returns a path to the temporary local staging directory

    """
    staging_dir = os.path.join(tempfile.mkdtemp(),os.path.basename(local_dir))
    os.mkdir(staging_dir)
    for root, dirs, files in os.walk(local_dir):
        relative_tree = root.replace(local_dir,'')
        if relative_tree:
            relative_tree = relative_tree[1:]
        if local_files:
            files = local_files.get(relative_tree,[])
        for file in files:
            if relative_tree:
                filepath = os.path.join(relative_tree,file)
                if not os.path.exists(os.path.join(staging_dir,relative_tree)):
                    os.mkdir(os.path.join(staging_dir,relative_tree))
            else: filepath = file
            shutil.copy2(os.path.join(root,file),os.path.join(staging_dir,filepath))
    return staging_dir