Add chdir utility function.
This commit is contained in:
parent
293cb63145
commit
b11498e8aa
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue