1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-15 10:46:40 +00:00

Code cleanup

This commit is contained in:
Ciro Mattia Gonano
2013-03-05 11:27:50 +01:00
parent 2ef148908a
commit 1a9db245bf
3 changed files with 19 additions and 25 deletions

View File

@@ -36,12 +36,6 @@ import cbxarchive
import pdfjpgextract import pdfjpgextract
def sort_nicely(l):
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
l.sort(key=alphanum_key)
def buildHTML(path, imgfile): def buildHTML(path, imgfile):
filename = getImageFileName(imgfile) filename = getImageFileName(imgfile)
if filename is not None: if filename is not None:

View File

@@ -18,12 +18,13 @@
# PERFORMANCE OF THIS SOFTWARE. # PERFORMANCE OF THIS SOFTWARE.
# #
__license__ = 'ISC' __license__ = 'ISC'
__copyright__ = '2012-2013, Ciro Mattia Gonano <ciromattia@gmail.com>' __copyright__ = '2012-2013, Ciro Mattia Gonano <ciromattia@gmail.com>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
import os import os
class PdfJpgExtract: class PdfJpgExtract:
def __init__(self, origFileName): def __init__(self, origFileName):
self.origFileName = origFileName self.origFileName = origFileName
@@ -48,14 +49,14 @@ class PdfJpgExtract:
istream = pdf.find("stream", i) istream = pdf.find("stream", i)
if istream < 0: if istream < 0:
break break
istart = pdf.find(startmark, istream, istream+20) istart = pdf.find(startmark, istream, istream + 20)
if istart < 0: if istart < 0:
i = istream+20 i = istream + 20
continue continue
iend = pdf.find("endstream", istart) iend = pdf.find("endstream", istart)
if iend < 0: if iend < 0:
raise Exception("Didn't find end of stream!") raise Exception("Didn't find end of stream!")
iend = pdf.find(endmark, iend-20) iend = pdf.find(endmark, iend - 20)
if iend < 0: if iend < 0:
raise Exception("Didn't find end of JPG!") raise Exception("Didn't find end of JPG!")
@@ -63,10 +64,9 @@ class PdfJpgExtract:
iend += endfix iend += endfix
print "JPG %d from %d to %d" % (njpg, istart, iend) print "JPG %d from %d to %d" % (njpg, istart, iend)
jpg = pdf[istart:iend] jpg = pdf[istart:iend]
jpgfile = file(self.path+"/jpg%d.jpg" % njpg, "wb") jpgfile = file(self.path + "/jpg%d.jpg" % njpg, "wb")
jpgfile.write(jpg) jpgfile.write(jpg)
jpgfile.close() jpgfile.close()
njpg += 1 njpg += 1
i = iend i = iend

View File

@@ -16,8 +16,8 @@ ez_setup.use_setuptools()
import sys import sys
from setuptools import setup from setuptools import setup
NAME='KindleComicConverter' NAME = 'KindleComicConverter'
VERSION="2.6-dev" VERSION = "2.6-dev"
mainscript = 'kcc.py' mainscript = 'kcc.py'
if sys.platform == 'darwin': if sys.platform == 'darwin':
@@ -29,12 +29,12 @@ if sys.platform == 'darwin':
argv_emulation=True, argv_emulation=True,
iconfile='resources/comic2ebook.icns', iconfile='resources/comic2ebook.icns',
plist=dict( plist=dict(
CFBundleName = NAME, CFBundleName=NAME,
CFBundleShortVersionString = VERSION, CFBundleShortVersionString=VERSION,
CFBundleGetInfoString = NAME + " " + VERSION + ", written 2012-2013 by Ciro Mattia Gonano", CFBundleGetInfoString=NAME + " " + VERSION + ", written 2012-2013 by Ciro Mattia Gonano",
CFBundleExecutable = NAME, CFBundleExecutable=NAME,
CFBundleIdentifier = 'com.github.ciromattia.kcc', CFBundleIdentifier='com.github.ciromattia.kcc',
CFBundleSignature = 'dplt' CFBundleSignature='dplt'
) )
) )
) )
@@ -43,7 +43,7 @@ elif sys.platform == 'win32':
from cx_Freeze import setup, Executable from cx_Freeze import setup, Executable
base = "Win32GUI" base = "Win32GUI"
extra_options = dict( extra_options = dict(
executables = [Executable("kcc.py", base=base)] executables=[Executable("kcc.py", base=base)]
) )
else: else:
extra_options = dict( extra_options = dict(
@@ -57,10 +57,10 @@ setup(
version=VERSION, version=VERSION,
author="Ciro Mattia Gonano", author="Ciro Mattia Gonano",
author_email="ciromattia@gmail.com", 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)", license="ISC License (ISCL)",
keywords = "kindle comic mobipocket mobi cbz cbr manga", keywords="kindle comic mobipocket mobi cbz cbr manga",
url = "http://github.com/ciromattia/kcc", url="http://github.com/ciromattia/kcc",
classifiers=[ classifiers=[
'Development Status :: 4 - Beta' 'Development Status :: 4 - Beta'
'License :: OSI Approved :: ISC License (ISCL)', 'License :: OSI Approved :: ISC License (ISCL)',