(self, pathname, container_root, volumes="")
return os.path.realpath(f_path)
Auxiliary translate container path to host path
Auxiliary translate container path to host path
Auxiliary translate container path to host path
def _cont2host(self, pathname, container_root, volumes=""):
        """Auxiliary translate container path to host path"""
        if not (pathname and pathname.startswith('/')):
            return ""
        if not volumes:
            volumes = []
        path = ""
        real_container_root = os.path.realpath(container_root)
        pathname = re.sub("/+", '/', os.path.normpath(pathname))
        for vol in volumes:
            (host_path, cont_path) = Uvolume(vol).split()
            if cont_path != host_path:
                if pathname.startswith(cont_path):
                    path = host_path + pathname[len(cont_path):]
                    break
            elif pathname.startswith(host_path):
                path = pathname
                break
        if not path:
            path = real_container_root + '/' + pathname
        f_path = ""
        for d_comp in path.split('/')[1:]:
            f_path = f_path + '/' + d_comp
            while os.path.islink(f_path):
                real_path = os.readlink(f_path)
                if real_path.startswith('/'):
                    if f_path.startswith(real_container_root): # in container
                        if real_path.startswith(real_container_root):
                            f_path = real_path
                        else:
                            f_path = real_container_root + real_path
                    else:
                        f_path = real_path
                else:
                    f_path = os.path.dirname(f_path) + '/' + real_path
        return os.path.realpath(f_path)
def _cont2host ( self , pathname , container_root , volumes = "" ) : if not ( pathname and pathname . startswith ( '/' ) ) : return "" if not volumes : volumes = [ ] path = "" real_container_root = os . path . realpath ( container_root ) pathname = re . sub ( "/+" , '/' , os . path . normpath ( pathname ) ) for vol in volumes : ( host_path , cont_path ) = Uvolume ( vol ) . split ( ) if cont_path != host_path : if pathname . startswith ( cont_path ) : path = host_path + pathname [ len ( cont_path ) : ] break elif pathname . startswith ( host_path ) : path = pathname break if not path : path = real_container_root + '/' + pathname f_path = "" for d_comp in path . split ( '/' ) [ 1 : ] : f_path = f_path + '/' + d_comp while os . path . islink ( f_path ) : real_path = os . readlink ( f_path ) if real_path . startswith ( '/' ) : if f_path . startswith ( real_container_root ) : # in container if real_path . startswith ( real_container_root ) : f_path = real_path else : f_path = real_container_root + real_path else : f_path = real_path else : f_path = os . path . dirname ( f_path ) + '/' + real_path return os . path . realpath ( f_path )