Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
 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)})
Esempio n. 4
0
 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
Esempio n. 5
0
 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
Esempio n. 6
0
 def test_load_files(self):
     dirpath = os.path.dirname(os.path.realpath(__file__))
     pages = Utils.find_pages(dirpath + '/../pages/')
Esempio n. 7
0
 def test_load_files(self):
     dirpath = os.path.dirname(os.path.realpath(__file__))
     pages = Utils.find_pages(dirpath+'/../pages/')
Esempio n. 8
0
 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