mirror of https://github.com/explosion/spaCy.git
Make working_dir yield absolute cwd path
This commit is contained in:
parent
3aca404735
commit
c5e31acb06
|
@ -462,11 +462,14 @@ def working_dir(path: Union[str, Path]) -> None:
|
||||||
"""Change current working directory and returns to previous on exit.
|
"""Change current working directory and returns to previous on exit.
|
||||||
|
|
||||||
path (str / Path): The directory to navigate to.
|
path (str / Path): The directory to navigate to.
|
||||||
|
YIELDS (Path): The absolute path to the current working directory. This
|
||||||
|
should be used if the block needs to perform actions within the working
|
||||||
|
directory, to prevent mismatches with relative paths.
|
||||||
"""
|
"""
|
||||||
prev_cwd = Path.cwd()
|
prev_cwd = Path.cwd()
|
||||||
os.chdir(str(path))
|
os.chdir(str(path))
|
||||||
try:
|
try:
|
||||||
yield
|
yield Path(path).resolve()
|
||||||
finally:
|
finally:
|
||||||
os.chdir(prev_cwd)
|
os.chdir(prev_cwd)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue