From cc3237d05119e3ef7126efb18042af31f630baa2 Mon Sep 17 00:00:00 2001 From: Ciro Mattia Gonano Date: Tue, 5 Mar 2013 11:54:23 +0100 Subject: [PATCH] Formatting and PEP-8 codestyle --- kcc/comic2ebook.py | 72 ++++++++++++++++++++++++---------------------- kcc/image.py | 2 +- setup.py | 2 +- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 619b026..ab30137 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -86,21 +86,22 @@ def buildHTML(path, imgfile): f.close() return path, imgfile + def buildBlankHTML(path): - f = open(os.path.join(path, 'blank.html'), "w") - f.writelines(["\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "" - ]) - f.close() - return path + f = open(os.path.join(path, 'blank.html'), "w") + f.writelines(["\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + ""]) + f.close() + return path + def buildNCX(dstdir, title, chapters): ncxfile = os.path.join(dstdir, 'OEBPS', 'toc.ncx') @@ -196,22 +197,23 @@ def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False): f.write("\n") f.write("\n\n") for entry in reflist: - if entry.endswith("-1"): - if ((righttoleft and facing == 'left') or (not righttoleft and facing == 'right')) and (options.profile == 'K4' or options.profile == 'KHD'): - f.write("\n") - f.write("\n") - elif entry.endswith("-2"): - f.write("\n") - if righttoleft: - facing = "right" - else: - facing = "left" - else: - f.write("\n") - if facing == 'right': - facing = 'left' - else: - facing = 'right' + if entry.endswith("-1"): + if (righttoleft and facing == 'left') or (not righttoleft and facing == 'right') and \ + (options.profile == 'K4' or options.profile == 'KHD'): + f.write("\n") + f.write("\n") + elif entry.endswith("-2"): + f.write("\n") + if righttoleft: + facing = "right" + else: + facing = "left" + else: + f.write("\n") + if facing == 'right': + facing = 'left' + else: + facing = 'right' f.write("\n\n\n\n") f.close() # finish with standard ePub folders @@ -277,11 +279,11 @@ def dirImgProcess(path): if options.verbose: print "Splitted " + afile if options.righttoleft: - toRight1 = False; - toRight2 = True; + toRight1 = False + toRight2 = True else: - toRight1 = True; - toRight2 = False; + toRight1 = True + toRight2 = False img0 = image.ComicPage(split[0], options.profile) applyImgOptimization(img0, True, toRight1) img0.saveToDir(dirpath) @@ -326,7 +328,7 @@ def genEpubStruct(path): filelist.sort(key=lambda name: (alphanum_key(name[0].lower()), alphanum_key(name[1].lower()))) buildOPF(options.profile, path, options.title, filelist, cover, options.righttoleft) if (options.profile == 'K4' or options.profile == 'KHD') and splittedSomething: - filelist.append(buildBlankHTML(os.path.join(path, 'OEBPS', 'Text'))) + filelist.append(buildBlankHTML(os.path.join(path, 'OEBPS', 'Text'))) def getWorkFolder(afile): diff --git a/kcc/image.py b/kcc/image.py index 6f52471..f3080ed 100755 --- a/kcc/image.py +++ b/kcc/image.py @@ -85,7 +85,7 @@ class ProfileData: 'KDX': ("Kindle DX", (824, 1200), Palette15), 'KDXG': ("Kindle DXG", (824, 1200), Palette16) } - + ProfileLabels = { "Kindle": 'K1', "Kindle 2": 'K2', diff --git a/setup.py b/setup.py index 0fd4b00..7ad2dec 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ setup( version=VERSION, author="Ciro Mattia Gonano", author_email="ciromattia@gmail.com", - description=("A tool to convert comics (CBR/CBZ/PDFs/image folders) to Mobipocket."), + description="A tool to convert comics (CBR/CBZ/PDFs/image folders) to Mobipocket.", license = "ISC License (ISCL)", keywords = "kindle comic mobipocket mobi cbz cbr manga", url = "http://github.com/ciromattia/kcc",