From b11498e8aa458385660da6d3b6db646626a6c4a1 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Fri, 22 Feb 2013 18:33:38 +0100 Subject: [PATCH] Add chdir utility function. --- patoolib/util.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/patoolib/util.py b/patoolib/util.py index 1601479..374c95e 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -492,4 +492,16 @@ def link_or_copy(src, dst, verbose=False): shutil.copy(src, dst) +def chdir(directory): + """Remember and return current directory before calling os.chdir(). + If the current directory could not be determined, return None. + """ + try: + olddir = os.getcwd() + except OSError: + olddir = None + os.chdir(directory) + return olddir + + init_mimedb()