当前位置: 首页>>代码示例>>Python>>正文


Python Library.addComics方法代码示例

本文整理汇总了Python中library.Library.addComics方法的典型用法代码示例。如果您正苦于以下问题:Python Library.addComics方法的具体用法?Python Library.addComics怎么用?Python Library.addComics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在library.Library的用法示例。


在下文中一共展示了Library.addComics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Monitor

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import addComics [as 别名]

#.........这里部分代码省略.........
            md.filesize = os.path.getsize(md.path)
            md.hash = ""

            #thumbnail generation
            image_data = ca.getPage(0)
            #now resize it
            thumb = StringIO.StringIO()
            utils.resize(image_data, (200, 200), thumb)
            md.thumbnail = thumb.getvalue()

            return md
        return None

    def setStatusDetail(self, detail, level=logging.DEBUG):
        self.statusdetail = detail
        if level == logging.DEBUG:
            logging.debug(detail)
        else:
            logging.info(detail)

    def setStatusDetailOnly(self, detail):
        self.statusdetail = detail
            
    def commitMetadataList(self, md_list):
        comics = []
        for md in md_list:
            self.add_count += 1
            comic = self.library.createComicFromMetadata(md)
            comics.append(comic)
            if self.quit:
                self.setStatusDetail(u"Monitor: halting scan!")
                return

        self.library.addComics(comics)

    def createAddRemoveLists(self, dirs):
        ix = {}
        db_set = set()
        current_set = set()
        filelist = utils.get_recursive_filelist(dirs)
        for path in filelist:
            current_set.add((path, datetime.utcfromtimestamp(os.path.getmtime(path))))
        logging.info("NEW -- current_set size [%d]" % len(current_set))

        for comic_id, path, md_ts in self.library.getComicPaths():
            db_set.add((path, md_ts))
            ix[path] = comic_id
        to_add = current_set - db_set
        to_remove = db_set - current_set
        logging.info("NEW -- db_set size [%d]" % len(db_set))
        logging.info("NEW -- to_add size [%d]" % len(to_add))
        logging.info("NEW -- to_remove size [%d]" % len(to_remove))

        return [r[0] for r in to_add], [ix[r[0]] for r in to_remove]

    def dofullScan(self, dirs):
        
        self.status = "SCANNING"
        
        logging.info(u"Monitor: Beginning file scan...")
        self.setStatusDetail(u"Monitor: Making a list of all files in the folders...")

        self.add_count = 0      
        self.remove_count = 0

开发者ID:Kalinon,项目名称:ComicStreamer,代码行数:68,代码来源:monitor.py

示例2: Monitor

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import addComics [as 别名]

#.........这里部分代码省略.........

    def getComicMetadata(self, path):
        logging.debug(u"Monitor: Scanning File {0} {1}\r".format(self.read_count, path))
        self.read_count += 1
        sys.stdout.flush()
        return self.library.getComicMetadata(path)
    


    def setStatusDetail(self, detail, level=logging.DEBUG):
        self.statusdetail = detail
        if level == logging.DEBUG:
            logging.debug("Monitor: "+detail)
        else:
            logging.info("Monitor: "+detail)

    def setStatusDetailOnly(self, detail):
        self.statusdetail = detail
            
    def commitMetadataList(self, md_list):
        comics = []
        for md in md_list:
            self.add_count += 1
            comic = self.library.createComicFromMetadata(md)
            comics.append(comic)
            if self.quit:
                self.setStatusDetail(u"Monitor: Stopped")
                return
        for i in comics:
            self.library.checkBlacklist(i)
            if self.quit:
                self.setStatusDetail(u"Monitor: Stopped")
                return
        self.library.addComics(comics)
    
    def getRecursiveFilelist(self, dirs):
        filename_encoding = sys.getfilesystemencoding()
        filelist = []
        index = 0
        for p in dirs:
            # if path is a folder, walk it recursivly, and all files underneath
            if type(p) == str:
                #make sure string is unicode
                p = p.decode(filename_encoding) #, 'replace')
            elif type(p) != unicode:
                #it's probably a QString
                p = unicode(p)
            if os.path.isdir( p ):
                for root,dirs,files in os.walk( p ):
                                # issue #26: try to exclude hidden files and dirs
                    files = [f for f in files if not f[0] == '.']
                    dirs[:] = [d for d in dirs if not d[0] == '.']
                    for f in files:
                        if type(f) == str:
                                                #make sure string is unicode
                            f = f.decode(filename_encoding, 'replace')
                        elif type(f) != unicode:
                                                    #it's probably a QString
                            f = unicode(f)
                        filelist.append(os.path.join(root,f))
                        if self.quit:
                            return filelist
            else:
                self.setStatusDetailOnly(u"Monitor: {0} Files Indexed".format(index))
                index = index + 1
                filelist.append(p)
开发者ID:Tristan79,项目名称:ComicStreamer,代码行数:70,代码来源:monitor.py


注:本文中的library.Library.addComics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。