1
0
mirror of https://github.com/ciromattia/kcc synced 2026-01-30 08:57:40 +00:00

Add option for epub output (closes #22)

This commit is contained in:
Ciro Mattia Gonano
2013-03-03 14:18:00 +01:00
parent 5103a80bb5
commit 3c45ab0903

View File

@@ -339,6 +339,8 @@ def main(argv=None):
help="Do not try to cut page numbering on images [default=True]")
parser.add_option("--rotate", action="store_true", dest="rotate", default=False,
help="Disable page spliting. Instead rotate images [default=False]")
parser.add_option("-o", "--output", action="store", dest="output", default=None,
help="Output directory or file for generated ePub")
options, args = parser.parse_args(argv)
if len(args) != 1:
parser.print_help()
@@ -352,7 +354,15 @@ def main(argv=None):
print "Creating ePub structure..."
genEpubStruct(path)
# actually zip the ePub
if os.path.isdir(args[0]):
if options.output is not None:
if options.output.endswith('.epub'):
epubpath = os.path.abspath(options.output)
elif os.path.isdir(args[0]):
epubpath = os.path.abspath(options.output) + "/" + os.path.basename(args[0]) + '.epub'
else:
epubpath = os.path.abspath(options.output) + "/" \
+ os.path.basename(os.path.splitext(args[0])[0]) + '.epub'
elif os.path.isdir(args[0]):
epubpath = args[0] + '.epub'
else:
epubpath = os.path.splitext(args[0])[0] + '.epub'