import os import shutil def examples(path, root, verbose=False, force=False): """ Copies the notebooks to the supplied path. """ filepath = os.path.abspath(os.path.dirname(root)) example_dir = os.path.join(filepath, './examples') if not os.path.exists(example_dir): example_dir = os.path.join(filepath, '../examples') if os.path.exists(path): if not force: print('%s directory already exists, either delete it or set the force flag' % path) return shutil.rmtree(path) ignore = shutil.ignore_patterns('.ipynb_checkpoints', '*.pyc', '*~') tree_root = os.path.abspath(example_dir) if os.path.isdir(tree_root): shutil.copytree(tree_root, path, ignore=ignore, symlinks=True) else: print('Cannot find %s' % tree_root)