def on_modified(self, event): # When files/dirs are modified in the posts folder, re-process them for the out folder. path = event.src_path # If title is modified, it must be modified in out folder's index. if path[-10:] == 'title.html': renderer.render_local_viewing(path[6:-10] + "index.html") print "Prepared out/" + path[6:-10] + "index.html for local viewing." # If image or index is modified, it must be modified in out folder. elif path.endswith(FILE_FORMATS): renderer.render_local_viewing(path[6:]) print "Prepared out/" + path[6:] + " for local viewing."
def on_created(self, event): # When files/dirs are created in the posts folder, create them in the out folder. path = event.src_path if path[-10:] == 'title.html': return out_path = "out" + path[5:] if path.endswith(FILE_FORMATS): if not(os.path.exists('out/' + path.split('/')[-2])): os.makedirs('out/' + path.split('/')[-2]) open(out_path, 'a').close() renderer.render_local_viewing(path[6:]) elif os.path.isdir(path): if not(os.path.exists(out_path)): os.makedirs(out_path) else: # Not dir, article, or image (aka must be temp file). return print "Created " + out_path