Skip to content

Commit

Permalink
Create folder if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Reale committed Mar 8, 2020
1 parent ecc1b13 commit 1ac2817
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions timestampy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@
from inotify.constants import IN_CREATE, IN_MODIFY, IN_MOVED_TO
from subprocess import call
import os
import errno


@click.command()
@click.option('--f', default='~/timestampy')
def main(f):
f = os.path.expanduser(f)

# create f if it does not exist
try:
os.makedirs(f)
except OSError as e:
if e.errno != errno.EEXIST:
raise

i = inotify.adapters.Inotify()
i.add_watch(f, mask=IN_CREATE | IN_MODIFY | IN_MOVED_TO)

Expand Down

0 comments on commit 1ac2817

Please sign in to comment.