diff --git a/IPython/html/nbextensions.py b/IPython/html/nbextensions.py index 2aa9dc5c6..78359f81d 100644 --- a/IPython/html/nbextensions.py +++ b/IPython/html/nbextensions.py @@ -1,12 +1,8 @@ # coding: utf-8 """Utilities for installing Javascript extensions for the notebook""" -#----------------------------------------------------------------------------- -# Copyright (C) 2014 The IPython Development Team -# -# Distributed under the terms of the BSD License. The full license is in -# the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. from __future__ import print_function @@ -24,7 +20,7 @@ except ImportError: from urlparse import urlparse from urllib import urlretrieve -from IPython.utils.path import get_ipython_dir +from IPython.utils.path import get_ipython_dir, ensure_dir_exists from IPython.utils.py3compat import string_types, cast_unicode_py2 from IPython.utils.tempdir import TemporaryDirectory @@ -109,8 +105,7 @@ def install_nbextension(files, overwrite=False, symlink=False, ipython_dir=None, ipython_dir = ipython_dir or get_ipython_dir() nbext = pjoin(ipython_dir, u'nbextensions') # make sure nbextensions dir exists - if not os.path.exists(nbext): - os.makedirs(nbext) + ensure_dir_exists(nbext) if isinstance(files, string_types): # one file given, turn it into a list diff --git a/IPython/html/services/notebooks/filenbmanager.py b/IPython/html/services/notebooks/filenbmanager.py index 27c3e5777..b9bd38921 100644 --- a/IPython/html/services/notebooks/filenbmanager.py +++ b/IPython/html/services/notebooks/filenbmanager.py @@ -1,21 +1,7 @@ -"""A notebook manager that uses the local file system for storage. +"""A notebook manager that uses the local file system for storage.""" -Authors: - -* Brian Granger -* Zach Sailer -""" - -#----------------------------------------------------------------------------- -# Copyright (C) 2011 The IPython Development Team -# -# Distributed under the terms of the BSD License. The full license is in -# the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. import io import os @@ -26,6 +12,7 @@ from tornado import web from .nbmanager import NotebookManager from IPython.nbformat import current +from IPython.utils.path import ensure_dir_exists from IPython.utils.traitlets import Unicode, Bool, TraitError from IPython.utils.py3compat import getcwd from IPython.utils import tz @@ -402,8 +389,7 @@ class FileNotebookManager(NotebookManager): ) os_path = self._get_os_path(path=path) cp_dir = os.path.join(os_path, self.checkpoint_dir) - if not os.path.exists(cp_dir): - os.mkdir(cp_dir) + ensure_dir_exists(cp_dir) cp_path = os.path.join(cp_dir, filename) return cp_path @@ -429,8 +415,6 @@ class FileNotebookManager(NotebookManager): checkpoint_id = u"checkpoint" cp_path = self.get_checkpoint_path(checkpoint_id, name, path) self.log.debug("creating checkpoint for notebook %s", name) - if not os.path.exists(self.checkpoint_dir): - os.mkdir(self.checkpoint_dir) self._copy(nb_path, cp_path) # return the checkpoint info