コード例 #1
0
ファイル: kernelmanager.py プロジェクト: ajkurt/ipython
 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
ファイル: kernelmanager.py プロジェクト: yangshiwei/ipython
    def cwd_for_path(self, path):
        """Turn API path into absolute OS path."""
        # short circuit for NotebookManagers that pass in absolute paths
        if os.path.exists(path):
            return 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.exists(os_path) and os_path != self.root_dir:
            os_path = os.path.dirname(os_path)
        return os_path
コード例 #4
0
ファイル: kernelmanager.py プロジェクト: NirKaldero/ipython
    def cwd_for_path(self, path):
        """Turn API path into absolute OS path."""
        # short circuit for NotebookManagers that pass in absolute paths
        if os.path.exists(path):
            return 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.exists(os_path) and os_path != self.root_dir:
            os_path = os.path.dirname(os_path)
        return os_path
コード例 #5
0
ファイル: filemanager.py プロジェクト: Rongya/ipython
    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.
        """
        return to_os_path(path, self.root_dir)
コード例 #6
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.
        """
        return to_os_path(path, self.root_dir)
コード例 #7
0
ファイル: filemanager.py プロジェクト: d10genes/ipython
    def _get_os_path(self, name=None, path=''):
        """Given a filename and API path, return its file system
        path.

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

        Returns
        -------
        path : string
            API path to be evaluated relative to root_dir.
        """
        if name is not None:
            path = url_path_join(path, name)
        return to_os_path(path, self.root_dir)
コード例 #8
0
    def _get_os_path(self, name=None, path=''):
        """Given a filename and API path, return its file system
        path.

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

        Returns
        -------
        path : string
            API path to be evaluated relative to root_dir.
        """
        if name is not None:
            path = url_path_join(path, name)
        return to_os_path(path, self.root_dir)
コード例 #9
0
ファイル: filenbmanager.py プロジェクト: vindolin/ipython
    def _get_os_path(self, name=None, path=''):
        """Given a notebook name and a URL path, return its file system
        path.

        Parameters
        ----------
        name : string
            The name of a notebook file with the .ipynb extension
        path : string
            The relative URL path (with '/' as separator) to the named
            notebook.

        Returns
        -------
        path : string
            A file system path that combines notebook_dir (location where
            server started), the relative path, and the filename with the
            current operating system's url.
        """
        if name is not None:
            path = path + '/' + name
        return to_os_path(path, self.notebook_dir)
コード例 #10
0
ファイル: filenbmanager.py プロジェクト: khinsen/ipython
    def _get_os_path(self, name=None, path=''):
        """Given a notebook name and a URL path, return its file system
        path.

        Parameters
        ----------
        name : string
            The name of a notebook file with the .ipynb extension
        path : string
            The relative URL path (with '/' as separator) to the named
            notebook.

        Returns
        -------
        path : string
            A file system path that combines notebook_dir (location where
            server started), the relative path, and the filename with the
            current operating system's url.
        """
        if name is not None:
            path = path + '/' + name
        return to_os_path(path, self.notebook_dir)
コード例 #11
0
ファイル: fileio.py プロジェクト: AkiraKaneshiro/ipython
    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
コード例 #12
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
コード例 #13
0
 def to_os_path(self, api_path):
     return to_os_path(api_path, root=self.notebook_dir.name)
コード例 #14
0
ファイル: test_contents_api.py プロジェクト: Zoltrix/ipython
 def to_os_path(self, api_path):
     return to_os_path(api_path, root=self.notebook_dir.name)
コード例 #15
0
 def to_os_path(self, api_path):
     return to_os_path(api_path, root=self.td.name)