| Total Complexity | 1 |
| Total Lines | 17 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import inspect |
||
| 2 | from pathlib import Path |
||
| 3 | |||
| 4 | |||
| 5 | def here(frames_back: int = 0) -> Path: |
||
| 6 | """ |
||
| 7 | Get the current directory from which this function is called. |
||
| 8 | Args: |
||
| 9 | frames_back: the number of extra frames to look back. |
||
| 10 | |||
| 11 | Returns: the directory as a Path instance. |
||
| 12 | |||
| 13 | """ |
||
| 14 | stack = inspect.stack() |
||
| 15 | previous_frame = stack[1 + frames_back] |
||
| 16 | return Path(previous_frame.filename).parent |
||
| 17 |