|
1 | 1 | # AUTOGENERATED! DO NOT EDIT! File to edit: nbs/02_foundation.ipynb (unless otherwise specified). |
2 | 2 |
|
3 | | -__all__ = ['copy_func', 'patch_to', 'patch', 'patch_property', 'add_docs', 'docs', 'custom_dir', 'coll_repr', 'is_bool', |
4 | | - 'mask2idxs', 'cycle', 'zip_cycle', 'is_indexer', 'GetAttr', 'delegate_attr', 'CollBase', 'L', |
5 | | - 'save_config_file', 'read_config_file', 'Config'] |
| 3 | +__all__ = ['copy_func', 'patch_to', 'patch', 'patch_property', 'working_directory', 'add_docs', 'docs', 'custom_dir', |
| 4 | + 'coll_repr', 'is_bool', 'mask2idxs', 'cycle', 'zip_cycle', 'is_indexer', 'GetAttr', 'delegate_attr', |
| 5 | + 'CollBase', 'L', 'save_config_file', 'read_config_file', 'Config'] |
6 | 6 |
|
7 | 7 | # Cell |
8 | 8 | from .imports import * |
@@ -53,6 +53,15 @@ def patch_property(f): |
53 | 53 | cls = next(iter(f.__annotations__.values())) |
54 | 54 | return patch_to(cls, as_prop=True)(f) |
55 | 55 |
|
| 56 | +# Cell |
| 57 | +@contextmanager |
| 58 | +def working_directory(path): |
| 59 | + "Change working directory to `path` and return to previous on exit." |
| 60 | + prev_cwd = Path.cwd() |
| 61 | + os.chdir(path) |
| 62 | + try: yield |
| 63 | + finally: os.chdir(prev_cwd) |
| 64 | + |
56 | 65 | # Cell |
57 | 66 | def add_docs(cls, cls_doc=None, **docs): |
58 | 67 | "Copy values from `docs` to `cls` docstrings, and confirm all public methods are documented" |
|
0 commit comments