Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create event DB dir if non-extant. #55

Merged
merged 4 commits into from Jan 15, 2018
Merged

Create event DB dir if non-extant. #55

merged 4 commits into from Jan 15, 2018

Conversation

jdswinbank
Copy link
Owner

No description provided.

@@ -22,6 +22,8 @@

class Event_DB(object):
def __init__(self, root):
if not os.path.exists(root):
os.makedirs(root)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if root exists, but points at a file?

How about...

def ensure_dir(dirname):
    """Ensure directory exists, or raise exception if file of same name exists."""
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    elif not os.path.isdir(dirname):
        raise RuntimeError("Path exists but is not directory: \n" + dirname)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@jdswinbank jdswinbank merged commit 0787cbc into master Jan 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants