Working commandline without PyQt

* Show simple usage in doc comments
  * python3 ready print() calls
  * add note on format and image filename preservation
  * display progress
  * remove Qt dependency for mangle-cli.py
This commit is contained in:
clach04 2021-07-16 20:34:32 -07:00
parent 089a3e5dfc
commit fec243c4d4

View File

@ -1,24 +1,40 @@
#!/usr/bin/env python2
"""python mangle-cli.py extracted_cbz_folder/*
-d directory_name defaults to ./
-t title defaults 'Unknown'
-o book.outputFormat defaults to 'CBZ only'
NOTE order of arguments for image files is significant.
"""
import shutil
import sys
import os
import getopt
from mangle.book import Book
import mangle.cbz
import mangle.image
from mangle.image import ImageFlags
class FakeBook:
device = 'Kindle 2/3/Touch' # See mangle/image.py KindleData.Profiles
outputFormat = 'CBZ only'
title = 'Unknown'
imageFlags = ImageFlags.Orient | ImageFlags.Resize | ImageFlags.Quantize
try:
opts, args = getopt.getopt(sys.argv[1:], 'd:t:o:')
except getopt.GetoptError, err:
print str(err)
print(str(err))
sys.exit(2)
directory = '.'
book = Book()
book.device = 'Kindle 3'
book = FakeBook()
book.device = 'Kindle 2/3/Touch'
#book.device = 'Kindle Paperwhite 1 & 2'
book.outputFormat = 'CBZ only'
book.title = 'Unknown'
@ -40,9 +56,10 @@ if not os.path.isdir(bookPath):
os.makedirs(bookPath)
for index in range(1, len(args)):
target = os.path.join(bookPath, '%05d.png' % index)
for index in range(0, len(args)):
target = os.path.join(bookPath, '%05d.png' % index) # FIXME preserve original; format and name?
print(index, args[index], target) # cheap display progress
mangle.image.convertImage(args[index], target, str(book.device), book.imageFlags)
archive.addFile(target);
@ -51,3 +68,4 @@ if 'Image' not in book.outputFormat:
shutil.rmtree(bookPath)
archive.close()