本文整理汇总了Python中library.Library.createComicFromMetadata方法的典型用法代码示例。如果您正苦于以下问题:Python Library.createComicFromMetadata方法的具体用法?Python Library.createComicFromMetadata怎么用?Python Library.createComicFromMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类library.Library
的用法示例。
在下文中一共展示了Library.createComicFromMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Monitor
# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import createComicFromMetadata [as 别名]
#.........这里部分代码省略.........
# No metadata in comic. make some guesses from the filename
md = ca.metadataFromFilename()
md.path = ca.path
md.page_count = ca.page_count
md.mod_ts = datetime.utcfromtimestamp(os.path.getmtime(ca.path))
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...")
示例2: Monitor
# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import createComicFromMetadata [as 别名]
#.........这里部分代码省略.........
#curr = datetime.datetime.fromtimestamp(os.path.getmtime(comic.path))
curr = datetime.utcfromtimestamp(getmtime(comic.path))
prev = comic.mod_ts
if curr != prev:
self.setStatusDetail(u"Updating")
logging.debug(u"Monitor: Flushing Modifed {0}".format(comic.path))
remove = True
return remove
"""
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')