Пример #1
0
 def load_posts(self):
     for f in os.listdir(g.source):
         if f.startswith("."):  # hidden file
             continue
         filename, ext = os.path.splitext(f)
         ext = ext.lower()[1:]
         reader = get_reader(ext)
         if reader is not None:
             logger.info('Loading file %s' % filename)
             path = os.path.join(g.source, f)
             post = reader(path)
             if post.type == "page":
                 self.pages.append(post)
             else:
                 self.posts.append(post)
         else:
             self.non_post_files.append(f)
     self.posts.sort(key=lambda x: x.datetime, reverse=True)
Пример #2
0
 def load_posts(self):
     for f in os.listdir(g.source):
         if f.startswith("."):  # hidden file
             continue
         filename, ext = os.path.splitext(f)
         ext = ext.lower()[1:]
         reader = get_reader(ext)
         if reader is not None:
             logger.info('Loading file %s' % filename)
             path = os.path.join(g.source, f)
             post = reader(path)
             if post.type == "page":
                 self.pages.append(post)
             else:
                 self.posts.append(post)
         else:
             self.non_post_files.append(f)
     self.posts.sort(
         key=lambda x: x.datetime,
         reverse=True
     )
Пример #3
0
def test_reader_choser():
    from catsup.reader import get_reader, markdown_reader, txt_reader
    assert get_reader("md") == markdown_reader
    assert get_reader("markdown") == markdown_reader
    assert get_reader("txt") == txt_reader
Пример #4
0
def test_reader_choser():
    from catsup.reader import get_reader, markdown_reader, txt_reader
    assert get_reader("md") == markdown_reader
    assert get_reader("markdown") == markdown_reader
    assert get_reader("txt") == txt_reader