mirror of
https://github.com/ciromattia/kcc
synced 2026-07-15 17:26:09 +00:00
Small tweaks
This commit is contained in:
+3
-1
@@ -91,7 +91,9 @@ class VersionThread(QtCore.QThread):
|
|||||||
latestVersion = XML.childNodes[0].getElementsByTagName('latest')[0].childNodes[0].toxml()
|
latestVersion = XML.childNodes[0].getElementsByTagName('latest')[0].childNodes[0].toxml()
|
||||||
if tuple(map(int, (latestVersion.split(".")))) > tuple(map(int, (__version__.split(".")))):
|
if tuple(map(int, (latestVersion.split(".")))) > tuple(map(int, (__version__.split(".")))):
|
||||||
self.emit(QtCore.SIGNAL("addMessage"), '<a href="http://kcc.vulturis.eu/">'
|
self.emit(QtCore.SIGNAL("addMessage"), '<a href="http://kcc.vulturis.eu/">'
|
||||||
'<b>New version is available!</b></a>', 'warning')
|
'<b>New version is available!</b></a> '
|
||||||
|
'(<a href="https://github.com/ciromattia/kcc/releases/">'
|
||||||
|
'Changelog</a>)', 'warning')
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
|
|||||||
+8
-12
@@ -537,7 +537,6 @@ def getWorkFolder(afile):
|
|||||||
raise UserWarning("Path is too long.")
|
raise UserWarning("Path is too long.")
|
||||||
if os.path.isdir(afile):
|
if os.path.isdir(afile):
|
||||||
workdir = tempfile.mkdtemp('', 'KCC-TMP-')
|
workdir = tempfile.mkdtemp('', 'KCC-TMP-')
|
||||||
#workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.join(os.path.splitext(afile)[0], '..'))
|
|
||||||
try:
|
try:
|
||||||
os.rmdir(workdir) # needed for copytree() fails if dst already exists
|
os.rmdir(workdir) # needed for copytree() fails if dst already exists
|
||||||
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
|
fullPath = os.path.join(workdir, 'OEBPS', 'Images')
|
||||||
@@ -557,7 +556,6 @@ def getWorkFolder(afile):
|
|||||||
raise UserWarning("Failed to extract images.")
|
raise UserWarning("Failed to extract images.")
|
||||||
else:
|
else:
|
||||||
workdir = tempfile.mkdtemp('', 'KCC-TMP-')
|
workdir = tempfile.mkdtemp('', 'KCC-TMP-')
|
||||||
#workdir = tempfile.mkdtemp('', 'KCC-TMP-', os.path.dirname(afile))
|
|
||||||
cbx = cbxarchive.CBxArchive(afile)
|
cbx = cbxarchive.CBxArchive(afile)
|
||||||
if cbx.isCbxFile():
|
if cbx.isCbxFile():
|
||||||
try:
|
try:
|
||||||
@@ -633,10 +631,8 @@ def getDirectorySize(start_path='.'):
|
|||||||
return total_size
|
return total_size
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyUnusedLocal
|
def createNewTome():
|
||||||
def createNewTome(parentPath):
|
|
||||||
tomePathRoot = tempfile.mkdtemp('', 'KCC-TMP-')
|
tomePathRoot = tempfile.mkdtemp('', 'KCC-TMP-')
|
||||||
#tomePathRoot = tempfile.mkdtemp('', 'KCC-TMP-', parentPath)
|
|
||||||
tomePath = os.path.join(tomePathRoot, 'OEBPS', 'Images')
|
tomePath = os.path.join(tomePathRoot, 'OEBPS', 'Images')
|
||||||
os.makedirs(tomePath)
|
os.makedirs(tomePath)
|
||||||
return tomePath, tomePathRoot
|
return tomePath, tomePathRoot
|
||||||
@@ -653,7 +649,7 @@ def walkLevel(some_dir, level=1):
|
|||||||
del dirs[:]
|
del dirs[:]
|
||||||
|
|
||||||
|
|
||||||
def splitDirectory(path, mode, parentPath):
|
def splitDirectory(path, mode):
|
||||||
output = []
|
output = []
|
||||||
currentSize = 0
|
currentSize = 0
|
||||||
currentTarget = path
|
currentTarget = path
|
||||||
@@ -662,7 +658,7 @@ def splitDirectory(path, mode, parentPath):
|
|||||||
for name in files:
|
for name in files:
|
||||||
size = os.path.getsize(os.path.join(root, name))
|
size = os.path.getsize(os.path.join(root, name))
|
||||||
if currentSize + size > 262144000:
|
if currentSize + size > 262144000:
|
||||||
currentTarget, pathRoot = createNewTome(parentPath)
|
currentTarget, pathRoot = createNewTome()
|
||||||
output.append(pathRoot)
|
output.append(pathRoot)
|
||||||
currentSize = size
|
currentSize = size
|
||||||
else:
|
else:
|
||||||
@@ -674,7 +670,7 @@ def splitDirectory(path, mode, parentPath):
|
|||||||
for name in dirs:
|
for name in dirs:
|
||||||
size = getDirectorySize(os.path.join(root, name))
|
size = getDirectorySize(os.path.join(root, name))
|
||||||
if currentSize + size > 262144000:
|
if currentSize + size > 262144000:
|
||||||
currentTarget, pathRoot = createNewTome(parentPath)
|
currentTarget, pathRoot = createNewTome()
|
||||||
output.append(pathRoot)
|
output.append(pathRoot)
|
||||||
currentSize = size
|
currentSize = size
|
||||||
else:
|
else:
|
||||||
@@ -689,7 +685,7 @@ def splitDirectory(path, mode, parentPath):
|
|||||||
currentSize = 0
|
currentSize = 0
|
||||||
if size > 262144000:
|
if size > 262144000:
|
||||||
if not firstTome:
|
if not firstTome:
|
||||||
currentTarget, pathRoot = createNewTome(parentPath)
|
currentTarget, pathRoot = createNewTome()
|
||||||
output.append(pathRoot)
|
output.append(pathRoot)
|
||||||
else:
|
else:
|
||||||
firstTome = False
|
firstTome = False
|
||||||
@@ -697,7 +693,7 @@ def splitDirectory(path, mode, parentPath):
|
|||||||
for nameInside in dirsInside:
|
for nameInside in dirsInside:
|
||||||
size = getDirectorySize(os.path.join(rootInside, nameInside))
|
size = getDirectorySize(os.path.join(rootInside, nameInside))
|
||||||
if currentSize + size > 262144000:
|
if currentSize + size > 262144000:
|
||||||
currentTarget, pathRoot = createNewTome(parentPath)
|
currentTarget, pathRoot = createNewTome()
|
||||||
output.append(pathRoot)
|
output.append(pathRoot)
|
||||||
currentSize = size
|
currentSize = size
|
||||||
else:
|
else:
|
||||||
@@ -706,7 +702,7 @@ def splitDirectory(path, mode, parentPath):
|
|||||||
move(os.path.join(rootInside, nameInside), os.path.join(currentTarget, nameInside))
|
move(os.path.join(rootInside, nameInside), os.path.join(currentTarget, nameInside))
|
||||||
else:
|
else:
|
||||||
if not firstTome:
|
if not firstTome:
|
||||||
currentTarget, pathRoot = createNewTome(parentPath)
|
currentTarget, pathRoot = createNewTome()
|
||||||
output.append(pathRoot)
|
output.append(pathRoot)
|
||||||
move(os.path.join(root, name), os.path.join(currentTarget, name))
|
move(os.path.join(root, name), os.path.join(currentTarget, name))
|
||||||
else:
|
else:
|
||||||
@@ -767,7 +763,7 @@ def preSplitDirectory(path):
|
|||||||
GUI.emit(QtCore.SIGNAL("addMessage"), '')
|
GUI.emit(QtCore.SIGNAL("addMessage"), '')
|
||||||
return [path]
|
return [path]
|
||||||
# Split directories
|
# Split directories
|
||||||
split = splitDirectory(os.path.join(path, 'OEBPS', 'Images'), mode, os.path.join(path, '..'))
|
split = splitDirectory(os.path.join(path, 'OEBPS', 'Images'), mode)
|
||||||
path = [path]
|
path = [path]
|
||||||
for tome in split:
|
for tome in split:
|
||||||
path.append(tome)
|
path.append(tome)
|
||||||
|
|||||||
@@ -393,7 +393,6 @@ class ComicPage:
|
|||||||
while ImageStat.Stat(self.image.crop((0, 0, widthImg, diff))).var[0] < threshold and diff < heightImg:
|
while ImageStat.Stat(self.image.crop((0, 0, widthImg, diff))).var[0] < threshold and diff < heightImg:
|
||||||
diff += delta
|
diff += delta
|
||||||
diff -= delta
|
diff -= delta
|
||||||
# print "Top crop: %s"%diff
|
|
||||||
self.image = self.image.crop((0, diff, widthImg, heightImg))
|
self.image = self.image.crop((0, diff, widthImg, heightImg))
|
||||||
widthImg, heightImg = self.image.size
|
widthImg, heightImg = self.image.size
|
||||||
diff = delta
|
diff = delta
|
||||||
@@ -401,7 +400,6 @@ class ComicPage:
|
|||||||
while ImageStat.Stat(self.image.crop((0, 0, diff, heightImg))).var[0] < threshold and diff < widthImg:
|
while ImageStat.Stat(self.image.crop((0, 0, diff, heightImg))).var[0] < threshold and diff < widthImg:
|
||||||
diff += delta
|
diff += delta
|
||||||
diff -= delta
|
diff -= delta
|
||||||
# print "Left crop: %s"%diff
|
|
||||||
self.image = self.image.crop((diff, 0, widthImg, heightImg))
|
self.image = self.image.crop((diff, 0, widthImg, heightImg))
|
||||||
widthImg, heightImg = self.image.size
|
widthImg, heightImg = self.image.size
|
||||||
diff = delta
|
diff = delta
|
||||||
@@ -410,7 +408,6 @@ class ComicPage:
|
|||||||
and diff < heightImg:
|
and diff < heightImg:
|
||||||
diff += delta
|
diff += delta
|
||||||
diff -= delta
|
diff -= delta
|
||||||
# print "Down crop: %s"%diff
|
|
||||||
self.image = self.image.crop((0, 0, widthImg, heightImg - diff))
|
self.image = self.image.crop((0, 0, widthImg, heightImg - diff))
|
||||||
widthImg, heightImg = self.image.size
|
widthImg, heightImg = self.image.size
|
||||||
diff = delta
|
diff = delta
|
||||||
@@ -419,9 +416,7 @@ class ComicPage:
|
|||||||
and diff < widthImg:
|
and diff < widthImg:
|
||||||
diff += delta
|
diff += delta
|
||||||
diff -= delta
|
diff -= delta
|
||||||
# print "Right crop: %s"%diff
|
|
||||||
self.image = self.image.crop((0, 0, widthImg - diff, heightImg))
|
self.image = self.image.crop((0, 0, widthImg - diff, heightImg))
|
||||||
# print "New size: %sx%s"%(self.image.size[0],self.image.size[1])
|
|
||||||
return self.image
|
return self.image
|
||||||
|
|
||||||
def getImageHistogram(self, image):
|
def getImageHistogram(self, image):
|
||||||
|
|||||||
Reference in New Issue
Block a user