def detect_change(self): changed = False for path in Utils.find_pages(self.directory): if path in self.files: if self.files[path].has_changed(): changed = True else: changed = True self.files[path] = FileWatcher(path) continue return changed
def _create_new_html(self, pagedir, template_html): parser = ContentParser() pagefiles = Utils.find_pages(pagedir) pagequeue = PriorityQueue() numpages = len(pagefiles) for pagefile in pagefiles: page_obj = parser.file_to_content_dict(pagefile) if page_obj['index'].isdigit(): pagequeue.put([int(page_obj['index']), page_obj]) else: pagequeue.put([numpages, page_obj]) continue return pystache.render(template_html, {'pages':self._page_queue_to_list(pagequeue)})
def has_changed(self): new_checksum = hashlib.md5( Utils.file_content(self.path, 'ascii') ).hexdigest() changed = self.checksum != new_checksum self.checksum = new_checksum return changed
def has_changed(self): new_checksum = hashlib.md5(Utils.file_content(self.path, 'ascii')).hexdigest() changed = self.checksum != new_checksum self.checksum = new_checksum return changed
def test_load_files(self): dirpath = os.path.dirname(os.path.realpath(__file__)) pages = Utils.find_pages(dirpath + '/../pages/')
def test_load_files(self): dirpath = os.path.dirname(os.path.realpath(__file__)) pages = Utils.find_pages(dirpath+'/../pages/')
def generate(self, pagedir, templatefile, newfile): html = self._create_new_html(pagedir, Utils.file_content(templatefile)) newfile_obj = codecs.open(newfile, 'w', encoding='utf-8') newfile_obj.write(html) newfile_obj.close() return html