mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
Code cleanup
This commit is contained in:
@@ -28,4 +28,4 @@ from kindlecomicconverter.startup import startC2P
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
freeze_support()
|
freeze_support()
|
||||||
startC2P()
|
startC2P()
|
||||||
|
|||||||
2
kcc.py
2
kcc.py
@@ -39,7 +39,7 @@ elif sys.platform.startswith('win'):
|
|||||||
class _Popen(forking.Popen):
|
class _Popen(forking.Popen):
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
if hasattr(sys, 'frozen'):
|
if hasattr(sys, 'frozen'):
|
||||||
# noinspection PyProtectedMember
|
# noinspection PyUnresolvedReferences,PyProtectedMember
|
||||||
os.putenv('_MEIPASS2', sys._MEIPASS)
|
os.putenv('_MEIPASS2', sys._MEIPASS)
|
||||||
try:
|
try:
|
||||||
super(_Popen, self).__init__(*args, **kw)
|
super(_Popen, self).__init__(*args, **kw)
|
||||||
|
|||||||
@@ -533,8 +533,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
|||||||
def clearJobs(self):
|
def clearJobs(self):
|
||||||
GUI.jobList.clear()
|
GUI.jobList.clear()
|
||||||
|
|
||||||
# noinspection PyCallByClass,PyTypeChecker
|
|
||||||
def openWiki(self):
|
def openWiki(self):
|
||||||
|
# noinspection PyCallByClass
|
||||||
QtGui.QDesktopServices.openUrl(QtCore.QUrl('https://github.com/ciromattia/kcc/wiki'))
|
QtGui.QDesktopServices.openUrl(QtCore.QUrl('https://github.com/ciromattia/kcc/wiki'))
|
||||||
|
|
||||||
def modeChange(self, mode):
|
def modeChange(self, mode):
|
||||||
|
|||||||
@@ -16,12 +16,11 @@
|
|||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
from zipfile import is_zipfile, ZipFile
|
from zipfile import is_zipfile, ZipFile
|
||||||
from subprocess import STDOUT, PIPE
|
from subprocess import STDOUT, PIPE
|
||||||
from psutil import Popen
|
from psutil import Popen
|
||||||
from shutil import move, copy
|
from shutil import move
|
||||||
from . import rarfile
|
from . import rarfile
|
||||||
from .shared import check7ZFile as is_7zfile
|
from .shared import check7ZFile as is_7zfile
|
||||||
|
|
||||||
|
|||||||
@@ -259,7 +259,8 @@ def main(argv=None, qtGUI=None):
|
|||||||
raise UserWarning("Conversion interrupted.")
|
raise UserWarning("Conversion interrupted.")
|
||||||
if len(mergeWorkerOutput) > 0:
|
if len(mergeWorkerOutput) > 0:
|
||||||
rmtree(options.targetDir, True)
|
rmtree(options.targetDir, True)
|
||||||
raise RuntimeError("One of workers crashed. Cause: " + mergeWorkerOutput[0][0], mergeWorkerOutput[0][1])
|
raise RuntimeError("One of workers crashed. Cause: " + mergeWorkerOutput[0][0],
|
||||||
|
mergeWorkerOutput[0][1])
|
||||||
print("Splitting images...")
|
print("Splitting images...")
|
||||||
for root, _, files in os.walk(options.targetDir, False):
|
for root, _, files in os.walk(options.targetDir, False):
|
||||||
for name in files:
|
for name in files:
|
||||||
@@ -282,7 +283,8 @@ def main(argv=None, qtGUI=None):
|
|||||||
raise UserWarning("Conversion interrupted.")
|
raise UserWarning("Conversion interrupted.")
|
||||||
if len(splitWorkerOutput) > 0:
|
if len(splitWorkerOutput) > 0:
|
||||||
rmtree(options.targetDir, True)
|
rmtree(options.targetDir, True)
|
||||||
raise RuntimeError("One of workers crashed. Cause: " + splitWorkerOutput[0][0], splitWorkerOutput[0][1])
|
raise RuntimeError("One of workers crashed. Cause: " + splitWorkerOutput[0][0],
|
||||||
|
splitWorkerOutput[0][1])
|
||||||
if options.inPlace:
|
if options.inPlace:
|
||||||
rmtree(options.sourceDir)
|
rmtree(options.sourceDir)
|
||||||
move(options.targetDir, options.sourceDir)
|
move(options.targetDir, options.sourceDir)
|
||||||
|
|||||||
@@ -17,11 +17,9 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from sys import version_info
|
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from distutils.version import StrictVersion
|
from distutils.version import StrictVersion
|
||||||
from time import sleep
|
|
||||||
from shutil import rmtree, copy
|
from shutil import rmtree, copy
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from zipfile import ZipFile, ZIP_DEFLATED
|
from zipfile import ZipFile, ZIP_DEFLATED
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import sys
|
|||||||
from . import __version__
|
from . import __version__
|
||||||
from .shared import dependencyCheck
|
from .shared import dependencyCheck
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
dependencyCheck(3)
|
dependencyCheck(3)
|
||||||
from . import KCC_gui
|
from . import KCC_gui
|
||||||
@@ -40,14 +41,16 @@ def start():
|
|||||||
KCCUI.handleMessage(sys.argv[1])
|
KCCUI.handleMessage(sys.argv[1])
|
||||||
sys.exit(KCCAplication.exec_())
|
sys.exit(KCCAplication.exec_())
|
||||||
|
|
||||||
|
|
||||||
def startC2E():
|
def startC2E():
|
||||||
dependencyCheck(2)
|
dependencyCheck(2)
|
||||||
from .comic2ebook import main
|
from .comic2ebook import main
|
||||||
print('comic2ebook v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.')
|
print('comic2ebook v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.')
|
||||||
sys.exit(main(sys.argv[1:]))
|
sys.exit(main(sys.argv[1:]))
|
||||||
|
|
||||||
|
|
||||||
def startC2P():
|
def startC2P():
|
||||||
dependencyCheck(1)
|
dependencyCheck(1)
|
||||||
from .comic2panel import main
|
from .comic2panel import main
|
||||||
print('comic2panel v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.')
|
print('comic2panel v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.')
|
||||||
sys.exit(main(sys.argv[1:]))
|
sys.exit(main(sys.argv[1:]))
|
||||||
|
|||||||
22
setup.py
22
setup.py
@@ -2,10 +2,10 @@
|
|||||||
"""
|
"""
|
||||||
pip/pyinstaller build script for KCC.
|
pip/pyinstaller build script for KCC.
|
||||||
|
|
||||||
Usage (Windows):
|
Install as Python package:
|
||||||
py -3 setup.py build_binary
|
python3 setup.py install
|
||||||
|
|
||||||
Usage (Linux/OS X):
|
Create EXE/APP/DEB:
|
||||||
python3 setup.py build_binary
|
python3 setup.py build_binary
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -14,32 +14,22 @@ import sys
|
|||||||
import shutil
|
import shutil
|
||||||
import setuptools
|
import setuptools
|
||||||
import distutils.cmd
|
import distutils.cmd
|
||||||
from distutils.command.build import build
|
|
||||||
from kindlecomicconverter import __version__
|
from kindlecomicconverter import __version__
|
||||||
|
|
||||||
NAME = 'KindleComicConverter'
|
NAME = 'KindleComicConverter'
|
||||||
MAIN = 'kcc.py'
|
MAIN = 'kcc.py'
|
||||||
VERSION = __version__
|
VERSION = __version__
|
||||||
|
|
||||||
|
|
||||||
class BuildBinaryCommand(distutils.cmd.Command):
|
class BuildBinaryCommand(distutils.cmd.Command):
|
||||||
description = 'build binary release'
|
description = 'build binary release'
|
||||||
user_options = [
|
|
||||||
('pyz', None, 'build PYZ package'),
|
|
||||||
]
|
|
||||||
|
|
||||||
def initialize_options(self):
|
|
||||||
# noinspection PyAttributeOutsideInit
|
|
||||||
self.pyz = False
|
|
||||||
|
|
||||||
def finalize_options(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
if os.path.isfile('Kindle Comic Converter.spec'):
|
if os.path.isfile('Kindle Comic Converter.spec'):
|
||||||
os.system('pyinstaller "Kindle Comic Converter.spec"')
|
os.system('pyinstaller "Kindle Comic Converter.spec"')
|
||||||
else:
|
else:
|
||||||
os.system('pyinstaller -y -F -i icons/comic2ebook.icns -n "Kindle Comic Converter" -w -s --noupx kcc.py')
|
os.system('pyinstaller -y -F -i icons/comic2ebook.icns -n "Kindle Comic Converter" -w -s kcc.py')
|
||||||
shutil.copy('other/osx/7za', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
shutil.copy('other/osx/7za', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||||
shutil.copy('other/osx/unrar', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
shutil.copy('other/osx/unrar', 'dist/Kindle Comic Converter.app/Contents/Resources')
|
||||||
shutil.copy('other/osx/Info.plist', 'dist/Kindle Comic Converter.app/Contents')
|
shutil.copy('other/osx/Info.plist', 'dist/Kindle Comic Converter.app/Contents')
|
||||||
@@ -92,6 +82,6 @@ setuptools.setup(
|
|||||||
'python-slugify>=1.2.1',
|
'python-slugify>=1.2.1',
|
||||||
'raven>=6.0.0',
|
'raven>=6.0.0',
|
||||||
],
|
],
|
||||||
classifiers = [],
|
classifiers=[],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user