diff options
author | blue <playbynumbers@gmail.com> | 2014-05-18 00:30:56 +0100 |
---|---|---|
committer | Paweł Jastrzębski <pawelj@vulturis.eu> | 2014-05-29 18:28:27 +0200 |
commit | 59b26cfc8bb6fb6e42d665f382aeda7a3d03a67b (patch) | |
tree | 303621545a6b48694f0a382decbb41d3e421275a | |
parent | Split comic2ebook.py main in two (diff) | |
download | kcc-59b26cfc8bb6fb6e42d665f382aeda7a3d03a67b.tar.gz kcc-59b26cfc8bb6fb6e42d665f382aeda7a3d03a67b.tar.bz2 kcc-59b26cfc8bb6fb6e42d665f382aeda7a3d03a67b.zip |
Split comic2ebook.py main in two again
Now has main() which initialises the program and makeParser() which sets up the option parser.
-rwxr-xr-x | kcc/comic2ebook.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 2140ba0..89ad0a2 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -887,14 +887,16 @@ def Usage(): parser.print_help() -def main(argv=None, qtGUI=None): - global parser, options, GUI +def makeParser(): + """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) + mainOptions = OptionGroup(parser, "MAIN") processingOptions = OptionGroup(parser, "PROCESSING") outputOptions = OptionGroup(parser, "OUTPUT SETTINGS") customProfileOptions = OptionGroup(parser, "CUSTOM PROFILE") otherOptions = OptionGroup(parser, "OTHER") + 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," " 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)") mainOptions.add_option("-w", "--webtoon", action="store_true", dest="webtoon", default=False, help="Webtoon processing mode"), + outputOptions.add_option("-o", "--output", action="store", dest="output", default=None, help="Output generated file to specified directory or file") 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") outputOptions.add_option("--batchsplit", action="store_true", dest="batchsplit", default=False, help="Split output into multiple files"), + processingOptions.add_option("--blackborders", action="store_true", dest="black_borders", default=False, help="Disable autodetection and force black borders") 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") processingOptions.add_option("--upscale", action="store_true", dest="upscale", default=False, help="Resize images smaller than device's resolution") + customProfileOptions.add_option("--customwidth", type="int", dest="customwidth", default=0, help="Replace screen width provided by device profile") customProfileOptions.add_option("--customheight", type="int", dest="customheight", default=0, help="Replace screen height provided by device profile") + otherOptions.add_option("-h", "--help", action="help", help="Show this help message and exit") + parser.add_option_group(mainOptions) parser.add_option_group(outputOptions) parser.add_option_group(processingOptions) parser.add_option_group(customProfileOptions) 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) checkOptions() if qtGUI: @@ -960,6 +975,7 @@ def main(argv=None, qtGUI=None): outputPath = makeBook(source, qtGUI=qtGUI) return outputPath + def makeBook(source, qtGUI=None): """Generates EPUB/CBZ comic ebook from a bunch of images.""" global GUI |