mirror of
https://github.com/gryf/ebook-converter.git
synced 2026-03-31 17:33:32 +02:00
Cleaned up __init__.py for main module
This commit is contained in:
20
ebook_converter/utils/directory.py
Normal file
20
ebook_converter/utils/directory.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
|
||||
|
||||
class CurrentDir(object):
|
||||
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
self.cwd = None
|
||||
|
||||
def __enter__(self, *args):
|
||||
self.cwd = os.getcwd()
|
||||
os.chdir(self.path)
|
||||
return self.cwd
|
||||
|
||||
def __exit__(self, *args):
|
||||
try:
|
||||
os.chdir(self.cwd)
|
||||
except EnvironmentError:
|
||||
# The previous CWD no longer exists
|
||||
pass
|
||||
Reference in New Issue
Block a user