forked from gregmalcolm/python_koans
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·35 lines (31 loc) · 1 KB
/
run.py
File metadata and controls
executable file
·35 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import os
import sys
try:
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import re
import time
except ImportError:
os.system("python contemplate_koans.py")
class ModifyHandler(FileSystemEventHandler):
@classmethod
def is_about_file(filename):
is_file = os.path.isfile(filename)
matches_name_pattern = re.match("^.*about_.+\.py", filename)
return is_file and matches_name_pattern
def on_modified(self, event):
#print event.event_type, event.src_path
if (is_about_file(event.src_path)):
from runner.mountain import Mountain
Mountain().walk_the_path(".")
if __name__ == "__main__":
observer = Observer()
observer.schedule(ModifyHandler(), ".", recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()