本文整理匯總了Python中book.Book.DefaultDevice方法的典型用法代碼示例。如果您正苦於以下問題:Python Book.DefaultDevice方法的具體用法?Python Book.DefaultDevice怎麽用?Python Book.DefaultDevice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類book.Book
的用法示例。
在下文中一共展示了Book.DefaultDevice方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: convert
# 需要導入模塊: from book import Book [as 別名]
# 或者: from book.Book import DefaultDevice [as 別名]
def convert(outputMgr, filePath, outDir, Device, verbose):
listDir = []
isDir = os.path.isdir(filePath)
if (isDir):
title = os.path.basename(filePath)
listDir = os.listdir(filePath)
else:
listDir.append(filePath)
title = 'Pictures'
outputBook = Book()
outputBook.DefaultDevice = Device
if (title == None or title == ""):
title = 'Pictures'
files = []
directories = []
compressedFiles = []
# Recursively loop through the filesystem
for filename in listDir:
if (isDir):
filename = os.path.join(filePath, filename)
if (verbose):
print("Pre-Processing %s." % filename)
if (os.path.isdir(str(filename))):
directories.append(filename)
else:
if (outputBook.isImageFile(filename)):
if (verbose):
print("ConvertPkg: Found Image %s" % filename)
files.append(filename)
else:
imageExts = ['.cbz', '.zip']
if os.path.splitext(filename)[1].lower() in imageExts:
compressedFiles.append(filename)
if (len(files) > 0):
files.sort()
outputBook.addImageFiles(files)
outputBook.title = title
bookConvert = BookConvert(outputBook, outputMgr, os.path.abspath(outDir), verbose)
bookConvert.Export()
outDir = os.path.join(outDir, title)
for directory in directories:
if(verbose):
print("Converting %s", directory)
convertFile.convert(outputMgr, directory, outDir, Device, verbose)
for compressedFile in compressedFiles:
try:
if(verbose):
print("Uncompressing %s" % compressedFile)
z = zipfile.ZipFile(compressedFile, 'r')
except:
if (verbose):
print("Failed to convert %s. Check if it is a valid zipFile." % compressedFile)
continue
if (isDir):
temp_dir = os.path.join(filePath, os.path.splitext(os.path.basename(compressedFile))[0])
else:
temp_dir = os.path.splitext(compressedFile)[0]
try:
os.mkdir(temp_dir)
except:
continue
for name in z.namelist():
tempName = os.path.join(temp_dir, name)
convertFile.extract_from_zip(name, tempName, z)
z.close
convertFile.convert(outputMgr, temp_dir, outDir, Device, verbose)
if os.path.exists(temp_dir):
shutil.rmtree(temp_dir)