mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 18:56:28 +00:00
Split comic2ebook.py main in two again
Now has main() which initialises the program and makeParser() which sets up the option parser.
This commit is contained in:
@@ -887,14 +887,16 @@ def Usage():
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None, qtGUI=None):
|
def makeParser():
|
||||||
global parser, options, GUI
|
"""Create and return an option parser set up with kcc's options."""
|
||||||
parser = OptionParser(usage="Usage: kcc-c2e [options] comic_file|comic_folder", add_help_option=False)
|
parser = OptionParser(usage="Usage: kcc-c2e [options] comic_file|comic_folder", add_help_option=False)
|
||||||
|
|
||||||
mainOptions = OptionGroup(parser, "MAIN")
|
mainOptions = OptionGroup(parser, "MAIN")
|
||||||
processingOptions = OptionGroup(parser, "PROCESSING")
|
processingOptions = OptionGroup(parser, "PROCESSING")
|
||||||
outputOptions = OptionGroup(parser, "OUTPUT SETTINGS")
|
outputOptions = OptionGroup(parser, "OUTPUT SETTINGS")
|
||||||
customProfileOptions = OptionGroup(parser, "CUSTOM PROFILE")
|
customProfileOptions = OptionGroup(parser, "CUSTOM PROFILE")
|
||||||
otherOptions = OptionGroup(parser, "OTHER")
|
otherOptions = OptionGroup(parser, "OTHER")
|
||||||
|
|
||||||
mainOptions.add_option("-p", "--profile", action="store", dest="profile", default="KHD",
|
mainOptions.add_option("-p", "--profile", action="store", dest="profile", default="KHD",
|
||||||
help="Device profile (Choose one among K1, K2, K345, KDX, KHD, KF, KFHD, KFHD8, KFHDX,"
|
help="Device profile (Choose one among K1, K2, K345, KDX, KHD, KF, KFHD, KFHD8, KFHDX,"
|
||||||
" KFHDX8, KFA, KoMT, KoG, KoA, KoAHD) [Default=KHD]")
|
" KFHDX8, KFA, KoMT, KoG, KoA, KoAHD) [Default=KHD]")
|
||||||
@@ -904,6 +906,7 @@ def main(argv=None, qtGUI=None):
|
|||||||
help="Manga style (Right-to-left reading and splitting)")
|
help="Manga style (Right-to-left reading and splitting)")
|
||||||
mainOptions.add_option("-w", "--webtoon", action="store_true", dest="webtoon", default=False,
|
mainOptions.add_option("-w", "--webtoon", action="store_true", dest="webtoon", default=False,
|
||||||
help="Webtoon processing mode"),
|
help="Webtoon processing mode"),
|
||||||
|
|
||||||
outputOptions.add_option("-o", "--output", action="store", dest="output", default=None,
|
outputOptions.add_option("-o", "--output", action="store", dest="output", default=None,
|
||||||
help="Output generated file to specified directory or file")
|
help="Output generated file to specified directory or file")
|
||||||
outputOptions.add_option("-t", "--title", action="store", dest="title", default="defaulttitle",
|
outputOptions.add_option("-t", "--title", action="store", dest="title", default="defaulttitle",
|
||||||
@@ -912,6 +915,7 @@ def main(argv=None, qtGUI=None):
|
|||||||
help="Outputs a CBZ archive and does not generate EPUB")
|
help="Outputs a CBZ archive and does not generate EPUB")
|
||||||
outputOptions.add_option("--batchsplit", action="store_true", dest="batchsplit", default=False,
|
outputOptions.add_option("--batchsplit", action="store_true", dest="batchsplit", default=False,
|
||||||
help="Split output into multiple files"),
|
help="Split output into multiple files"),
|
||||||
|
|
||||||
processingOptions.add_option("--blackborders", action="store_true", dest="black_borders", default=False,
|
processingOptions.add_option("--blackborders", action="store_true", dest="black_borders", default=False,
|
||||||
help="Disable autodetection and force black borders")
|
help="Disable autodetection and force black borders")
|
||||||
processingOptions.add_option("--whiteborders", action="store_true", dest="white_borders", default=False,
|
processingOptions.add_option("--whiteborders", action="store_true", dest="white_borders", default=False,
|
||||||
@@ -934,17 +938,28 @@ def main(argv=None, qtGUI=None):
|
|||||||
help="Stretch images to device's resolution")
|
help="Stretch images to device's resolution")
|
||||||
processingOptions.add_option("--upscale", action="store_true", dest="upscale", default=False,
|
processingOptions.add_option("--upscale", action="store_true", dest="upscale", default=False,
|
||||||
help="Resize images smaller than device's resolution")
|
help="Resize images smaller than device's resolution")
|
||||||
|
|
||||||
customProfileOptions.add_option("--customwidth", type="int", dest="customwidth", default=0,
|
customProfileOptions.add_option("--customwidth", type="int", dest="customwidth", default=0,
|
||||||
help="Replace screen width provided by device profile")
|
help="Replace screen width provided by device profile")
|
||||||
customProfileOptions.add_option("--customheight", type="int", dest="customheight", default=0,
|
customProfileOptions.add_option("--customheight", type="int", dest="customheight", default=0,
|
||||||
help="Replace screen height provided by device profile")
|
help="Replace screen height provided by device profile")
|
||||||
|
|
||||||
otherOptions.add_option("-h", "--help", action="help",
|
otherOptions.add_option("-h", "--help", action="help",
|
||||||
help="Show this help message and exit")
|
help="Show this help message and exit")
|
||||||
|
|
||||||
parser.add_option_group(mainOptions)
|
parser.add_option_group(mainOptions)
|
||||||
parser.add_option_group(outputOptions)
|
parser.add_option_group(outputOptions)
|
||||||
parser.add_option_group(processingOptions)
|
parser.add_option_group(processingOptions)
|
||||||
parser.add_option_group(customProfileOptions)
|
parser.add_option_group(customProfileOptions)
|
||||||
parser.add_option_group(otherOptions)
|
parser.add_option_group(otherOptions)
|
||||||
|
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv=None, qtGUI=None):
|
||||||
|
global parser, options, GUI
|
||||||
|
|
||||||
|
parser = makeParser()
|
||||||
options, args = parser.parse_args(argv)
|
options, args = parser.parse_args(argv)
|
||||||
checkOptions()
|
checkOptions()
|
||||||
if qtGUI:
|
if qtGUI:
|
||||||
@@ -960,6 +975,7 @@ def main(argv=None, qtGUI=None):
|
|||||||
outputPath = makeBook(source, qtGUI=qtGUI)
|
outputPath = makeBook(source, qtGUI=qtGUI)
|
||||||
return outputPath
|
return outputPath
|
||||||
|
|
||||||
|
|
||||||
def makeBook(source, qtGUI=None):
|
def makeBook(source, qtGUI=None):
|
||||||
"""Generates EPUB/CBZ comic ebook from a bunch of images."""
|
"""Generates EPUB/CBZ comic ebook from a bunch of images."""
|
||||||
global GUI
|
global GUI
|
||||||
|
|||||||
Reference in New Issue
Block a user