search.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:constantina 作者: wwoast 项目源码 文件源码
def __add_ctype_to_index(self, ctype):
        """Take a file type, list all the files there, and add all the
        body contents to the index."""
        # Make sure BaseFiles is populated
        opendir(self.config, ctype)
        card_root = GlobalConfig.get("paths", "data_root") + "/private"
        card_path = card_root + "/" + self.config.get("paths", ctype)

        for filename in BaseFiles[ctype]:
            try:
                fnmtime = int(os.path.getmtime(card_path + "/" + filename))
            except os.error:
                syslog.syslog("Failed to get \"" + filename + "\" mtime for indexing.")
                return   # File has been removed, nothing to index

            lastmtime = ''
            try:
                lastmtime = int(float(self.searcher.document(file=unicode(filename))['mtime']))
            except index.IndexError:
                lastmtime = 0   # File hasn't been indexed
            # If small revisions were made after the fact, the indexes won't
            # be accurate unless we reindex this file now
            if lastmtime < fnmtime:
                self.__add_file_to_index(fnmtime, filename, ctype)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号