本文整理汇总了Python中library.Library.deleteComics方法的典型用法代码示例。如果您正苦于以下问题:Python Library.deleteComics方法的具体用法?Python Library.deleteComics怎么用?Python Library.deleteComics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类library.Library
的用法示例。
在下文中一共展示了Library.deleteComics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Monitor
# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import deleteComics [as 别名]
#.........这里部分代码省略.........
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
filelist, to_remove = self.createAddRemoveLists(dirs)
self.setStatusDetail(u"Monitor: Removing missing or modified files from db ({0} files)".format(len(to_remove)), logging.INFO)
if len(to_remove) > 0:
self.library.deleteComics(to_remove)
self.setStatusDetail(u"Monitor: {0} new files to scan...".format(len(filelist)), logging.INFO)
md_list = []
self.read_count = 0
for filename in filelist:
md = self.getComicMetadata(filename)
if md is not None:
md_list.append(md)
self.setStatusDetailOnly(u"Monitor: {0} files: {1} scanned, {2} added to library...".format(len(filelist), self.read_count,self.add_count))
if self.quit:
self.setStatusDetail(u"Monitor: halting scan!")
return
#every so often, commit to DB
if self.read_count % 10 == 0 and self.read_count != 0:
if len(md_list) > 0:
self.commitMetadataList(md_list)
md_list = []
if len(md_list) > 0:
self.commitMetadataList(md_list)
self.setStatusDetail(u"Monitor: finished scanning metadata in {0} of {1} files".format(self.read_count,len(filelist)), logging.INFO)
self.status = "IDLE"
self.statusdetail = ""
self.scancomplete_ts = int(time.mktime(datetime.utcnow().timetuple()) * 1000)
logging.info("Monitor: Added {0} comics".format(self.add_count))
logging.info("Monitor: Removed {0} comics".format(self.remove_count))
if self.quit_when_done:
self.quit = True
def doEventProcessing(self, eventList):
logging.debug(u"Monitor: event_list:{0}".format(eventList))
示例2: Monitor
# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import deleteComics [as 别名]
#.........这里部分代码省略.........
else:
self.setStatusDetailOnly(u"Monitor: {0} Files Indexed".format(index))
index = index + 1
filelist.append(p)
return filelist
def createAddRemoveLists(self, dirs):
ix = {}
db_set = set()
current_set = set()
self.dbfiles = len(db_set)
filelist = self.getRecursiveFilelist(dirs)
if self.quit:
return [],[]
for path in filelist:
try:
current_set.add((path, datetime.utcfromtimestamp(os.path.getmtime(path))))
except:
logging.debug(u"Monitor: Failed To Access '{0}'".format(path))
filelist.remove(path)
logging.debug(u"Monitor: %d Files Found " % len(current_set))
try:
for comic_id, path, md_ts in self.library.getComicPaths():
db_set.add((path, md_ts))
ix[path] = comic_id
if self.quit:
return [],[]
except:
logging.debug(u"Monitor: Failed To Access '{0}'".format(path))
to_add = current_set - db_set
to_remove = db_set - current_set
logging.debug(u"Monitor: %d Files In Library " % len(db_set))
logging.debug(u"Monitor: %d Files To Remove" % len(to_remove))
logging.info(u"Monitor: %d Files To Scan" % len(to_add))
return [r[0] for r in to_add], [ix[r[0]] for r in to_remove]
def dofullScan(self, dirs):
self.status = u"CHECKING"
self.setStatusDetailOnly(u"Files")
self.add_count = 0
self.remove_count = 0
filelist, to_remove = self.createAddRemoveLists(dirs)
if self.quit:
self.status = u"QUITING"
self.setStatusDetailOnly(u"")
return
self.setStatusDetail(u"Removing {0} Files".format(len(to_remove)))
if len(to_remove) > 0:
self.library.deleteComics(to_remove)
self.setStatusDetail(u"Scanning {0} Files".format(len(filelist)))
self.status = u"SCANNING"
md_list = []
self.read_count = 0
commitlength = 10
for filename in filelist:
md = self.getComicMetadata(filename)
if md is not None:
md_list.append(md)
self.setStatusDetailOnly(u"File {0}/{1} Found {2}".format(len(filelist), self.read_count,self.add_count))
if self.quit:
self.status = u"QUITING"
self.setStatusDetailOnly(u"")
return
#every so often, commit to DB
if self.read_count % commitlength == 0 and self.read_count != 0:
if len(md_list) > 0:
self.commitMetadataList(md_list)
md_list = []
commitlength = 200
if len(md_list) > 0:
self.commitMetadataList(md_list)
self.setStatusDetail(u"Metadata {0}/{1} Files".format(self.read_count,len(filelist)))
self.status = u"IDLE"
self.statusdetail = ""
self.scancomplete_ts = int(time.mktime(datetime.utcnow().timetuple()) * 1000)
logging.info(u"Monitor: Added {0} Files".format(self.add_count))
logging.info(u"Monitor: Removed {0} Files".format(self.remove_count))
if self.quit_when_done:
self.quit = True
"""