def test_single_suffix_dot_in_path(pathlib_glob): import menpo.io.input.base as mio_base from pathlib import Path fake_path = Path('fake_path.t0.t1.t2') pathlib_glob.return_value = [fake_path] ext_map = MagicMock() ext_map.__contains__.side_effect = lambda x: x == '.t2' ret_val = next(mio_base.glob_with_suffix('*.t0.t1.t2', ext_map)) assert (ret_val == fake_path) ext_map.__contains__.assert_called_with('.t2')
def test_double_suffix(pathlib_glob): import menpo.io.input.base as mio_base from pathlib import Path fake_path = Path("fake_path.t1.t2") pathlib_glob.return_value = [fake_path] ext_map = MagicMock() ext_map.__contains__.side_effect = lambda x: x == ".t1.t2" ret_val = next(mio_base.glob_with_suffix("*.t1.t2", ext_map)) assert ret_val == fake_path ext_map.__contains__.assert_any_call(".t1.t2") ext_map.__contains__.assert_any_call(".t2")
with open(str(path)) as f: nb = nbformat.read(f, 4) try: parent = path.parent PREPROCESSOR.preprocess(nb, {'metadata': {'path': str(parent)}}) with open(str(path), 'wt') as f: nbformat.write(nb, f) except CellExecutionError as e: print(e) if __name__ == '__main__': args = docopt(__doc__, version='1.0') projects_to_build = args['<project>'] or PROJECTS_WITH_NOTEBOOKS timeout = int(args['--timeout']) PREPROCESSOR = ExecutePreprocessor(timeout=timeout, kernel_name='python3') for project in projects_to_build: notebook_names = glob_with_suffix('{}/**/*.ipynb'.format(project), {'.ipynb': None}) print(' Executing {} notebooks '.format(project).center(80, '*')) for path in notebook_names: if path.parent.name != '.ipynb_checkpoints': execute_and_write_notebook(path)
def landmark_file_paths(pattern): r""" Return landmark file filepaths that Menpo3d can import that match the glob pattern. """ return glob_with_suffix(pattern, mesh_landmark_types)
def mesh_paths(pattern): r""" Return mesh filepaths that Menpo3d can import that match the glob pattern. """ return glob_with_suffix(pattern, mesh_types)