Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: f7639fbab8
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (35 sloc) 1.17 kB
import os, re, time
def update():
isPage = re.compile("^[^_].+\.html$")
time.sleep(0.3)
with open("_template.html", 'r') as tmpl:
template = tmpl.read()
for filename in os.listdir("."):
if(isPage.match(filename)):
with open(filename, 'r') as page:
with open("../"+filename, 'w') as result:
try:
result.write(template % page.read())
except TypeError as e:
print e
def watch():
"""
Windows only
"""
import win32file, win32event, win32con
watchPath = os.path.abspath(".")
change_handle = win32file.FindFirstChangeNotification(
watchPath,
0,
win32con.FILE_NOTIFY_CHANGE_LAST_WRITE)
try:
while 1:
result = win32event.WaitForSingleObject(change_handle, 500)
if(result == win32con.WAIT_OBJECT_0):
update()
win32file.FindNextChangeNotification(change_handle)
finally:
win32file.FindCloseChangeNotification(change_handle)
if __name__ == '__main__':
update()
watch()
Jump to Line
Something went wrong with that request. Please try again.