From 05c8fe328e645a3e25fbd379ab8d3cb1dfd3b7b7 Mon Sep 17 00:00:00 2001 From: Ciro Mattia Gonano Date: Tue, 29 Jan 2013 00:08:31 +0100 Subject: [PATCH] Fixes folder handling, subfolders and issues with spaces and # on filenames. --- README.md | 1 + kcc.py | 2 +- kcc/comic2ebook.py | 10 +++++++--- kcc/gui.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6dbc003..b181dc4 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ and installed in `/usr/local/bin/` - 2.1: Added basic error reporting - 2.2: Added (valid!) ePub 2.0 output Rename .zip files to .cbz to avoid overwriting + - 2.3: Fixed win32 ePub generation, folder handling, filenames with spaces and subfolders. ## TODO - Add gracefully exit for CBR if no rarfile.py and no unrar executable are found diff --git a/kcc.py b/kcc.py index 7ff6548..9986586 100644 --- a/kcc.py +++ b/kcc.py @@ -16,7 +16,7 @@ # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. # -__version__ = '2.2' +__version__ = '2.3' __license__ = 'ISC' __copyright__ = '2012-2013, Ciro Mattia Gonano ' __docformat__ = 'restructuredtext en' diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 93ddb8f..bfe336e 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -50,13 +50,17 @@ def buildHTML(path,file): filename = getImageFileName(file) if filename is not None: postfix = '' + backref = 1 head = path while True: head, tail = os.path.split(head) if tail == 'Images': - htmlpath = os.path.join(head,'Text') + htmlpath = os.path.join(head,'Text',postfix) break postfix = tail + "/" + postfix + backref += 1 + if not os.path.exists(htmlpath): + os.makedirs(htmlpath) htmlfile = os.path.join(htmlpath,filename[0] + '.html') f = open(htmlfile, "w") f.writelines(["\n", @@ -66,7 +70,7 @@ def buildHTML(path,file): "\n", "\n", "\n", - "
\"",file,"\"
\n", + "
\"",file,"\"
\n", "\n", "" ]) @@ -133,7 +137,7 @@ def buildOPF(profile, dstdir, title, filelist, cover=None): filename = getImageFileName(path[1]) uniqueid = os.path.join(folder,filename[0]).replace('/','_') reflist.append(uniqueid) - f.write("\n") if '.png' == filename[1]: mt = 'image/png' diff --git a/kcc/gui.py b/kcc/gui.py index 2eb133f..0565a0f 100644 --- a/kcc/gui.py +++ b/kcc/gui.py @@ -155,7 +155,7 @@ class MainWindow: if self.epub_only == 1: continue; try: - retcode = call("kindlegen " + epub_path, shell=True) + retcode = call("kindlegen \"" + epub_path + "\"", shell=True) if retcode < 0: print >>sys.stderr, "Child was terminated by signal", -retcode else: