示例#1
0
 def cwd_for_path(self, path):
     """Turn API path into absolute OS path."""
     os_path = to_os_path(path, self.root_dir)
     # in the case of notebooks and kernels not being on the same filesystem,
     # walk up to root_dir if the paths don't exist
     while not os.path.isdir(os_path) and os_path != self.root_dir:
         os_path = os.path.dirname(os_path)
     return os_path
示例#2
0
 def cwd_for_path(self, path):
     """Turn API path into absolute OS path."""
     os_path = to_os_path(path, self.root_dir)
     # in the case of notebooks and kernels not being on the same filesystem,
     # walk up to root_dir if the paths don't exist
     while not os.path.isdir(os_path) and os_path != self.root_dir:
         os_path = os.path.dirname(os_path)
     return os_path
示例#3
0
    def _get_os_path(self, path):
        """Given an API path, return its file system path.

        Parameters
        ----------
        path : string
            The relative API path to the named file.

        Returns
        -------
        path : string
            Native, absolute OS path to for a file.

        Raises
        ------
        404: if path is outside root
        """
        root = os.path.abspath(self.root_dir)
        os_path = to_os_path(path, root)
        if not (os.path.abspath(os_path) + os.path.sep).startswith(root):
            raise HTTPError(404, "%s is outside root contents directory" % path)
        return os_path
示例#4
0
 def to_os_path(self, api_path):
     return to_os_path(api_path, root=self.notebook_dir.name)
 def to_os_path(self, api_path):
     return to_os_path(api_path, root=self.notebook_dir.name)