Commit 70de597a authored by BorjaEst's avatar BorjaEst
Browse files

Edit log to global newdir path when at cd

parent b126d3ec
......@@ -17,16 +17,17 @@ logger = logging.getLogger('o3skim.utils')
@contextmanager
def cd(newdir):
def cd(dir):
"""Changes the directory inside a 'with' context. When the code
reaches the end of the 'with' block or the code fails, the
previous folder is restored.
:param newdir: Path folder where to change the working directory.
:type newdir: str
:param dir: Path folder where to change the working directory.
:type dir: str
"""
prevdir = os.getcwd()
os.chdir(os.path.expanduser(newdir))
os.chdir(os.path.expanduser(dir))
newdir = os.getcwd()
try:
logger.debug("Changing directory: '%s'", newdir)
yield
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment