mirror of
https://github.com/ciromattia/kcc
synced 2025-12-15 02:36:44 +00:00
Python 3.5+ include scandir
This commit is contained in:
@@ -22,7 +22,10 @@ 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, copy
|
||||||
from scandir import walk
|
try:
|
||||||
|
from scandir import walk
|
||||||
|
except ImportError:
|
||||||
|
walk = os.walk
|
||||||
from . import rarfile
|
from . import rarfile
|
||||||
from .shared import check7ZFile as is_7zfile, saferReplace
|
from .shared import check7ZFile as is_7zfile, saferReplace
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,15 @@ from slugify import slugify as slugifyExt
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
from subprocess import STDOUT, PIPE
|
from subprocess import STDOUT, PIPE
|
||||||
from psutil import Popen, virtual_memory
|
from psutil import Popen, virtual_memory
|
||||||
from scandir import walk
|
|
||||||
from html import escape
|
from html import escape
|
||||||
try:
|
try:
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
except ImportError:
|
except ImportError:
|
||||||
QtCore = None
|
QtCore = None
|
||||||
|
try:
|
||||||
|
from scandir import walk
|
||||||
|
except ImportError:
|
||||||
|
walk = os.walk
|
||||||
from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace
|
from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace
|
||||||
from . import comic2panel
|
from . import comic2panel
|
||||||
from . import image
|
from . import image
|
||||||
|
|||||||
@@ -24,12 +24,15 @@ from shutil import rmtree, copytree, move
|
|||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
from multiprocessing import Pool
|
from multiprocessing import Pool
|
||||||
from PIL import Image, ImageStat, ImageOps
|
from PIL import Image, ImageStat, ImageOps
|
||||||
from scandir import walk
|
|
||||||
from .shared import getImageFileName, walkLevel, walkSort
|
from .shared import getImageFileName, walkLevel, walkSort
|
||||||
try:
|
try:
|
||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
except ImportError:
|
except ImportError:
|
||||||
QtCore = None
|
QtCore = None
|
||||||
|
try:
|
||||||
|
from scandir import walk
|
||||||
|
except ImportError:
|
||||||
|
walk = os.walk
|
||||||
|
|
||||||
|
|
||||||
def mergeDirectoryTick(output):
|
def mergeDirectoryTick(output):
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
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
|
||||||
@@ -29,7 +30,7 @@ from traceback import format_tb
|
|||||||
try:
|
try:
|
||||||
from scandir import walk
|
from scandir import walk
|
||||||
except ImportError:
|
except ImportError:
|
||||||
walk = None
|
walk = os.walk
|
||||||
|
|
||||||
|
|
||||||
class HTMLStripper(HTMLParser):
|
class HTMLStripper(HTMLParser):
|
||||||
@@ -156,12 +157,13 @@ def dependencyCheck(level):
|
|||||||
missing.append('Pillow 2.8.2+')
|
missing.append('Pillow 2.8.2+')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('Pillow 2.8.2+')
|
missing.append('Pillow 2.8.2+')
|
||||||
try:
|
if version_info[1] < 5:
|
||||||
from scandir import __version__ as scandirVersion
|
try:
|
||||||
if StrictVersion('1.1') > StrictVersion(scandirVersion):
|
from scandir import __version__ as scandirVersion
|
||||||
|
if StrictVersion('1.1') > StrictVersion(scandirVersion):
|
||||||
|
missing.append('scandir 1.1+')
|
||||||
|
except ImportError:
|
||||||
missing.append('scandir 1.1+')
|
missing.append('scandir 1.1+')
|
||||||
except ImportError:
|
|
||||||
missing.append('scandir 1.1+')
|
|
||||||
if len(missing) > 0:
|
if len(missing) > 0:
|
||||||
print('ERROR: ' + ', '.join(missing) + ' is not installed!')
|
print('ERROR: ' + ', '.join(missing) + ' is not installed!')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|||||||
10
setup.py
10
setup.py
@@ -11,17 +11,17 @@ Usage (Linux):
|
|||||||
Usage (Mac OS X):
|
Usage (Mac OS X):
|
||||||
python3 setup.py py2app
|
python3 setup.py py2app
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from sys import platform, version_info, argv
|
from sys import platform, version_info, argv
|
||||||
from kcc import __version__
|
from kcc import __version__
|
||||||
if version_info[0] != 3:
|
|
||||||
print('ERROR: This is Python 3 script!')
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
NAME = 'KindleComicConverter'
|
NAME = 'KindleComicConverter'
|
||||||
VERSION = __version__
|
VERSION = __version__
|
||||||
MAIN = 'kcc.py'
|
MAIN = 'kcc.py'
|
||||||
extra_options = {}
|
extra_options = {}
|
||||||
|
|
||||||
|
|
||||||
if platform == 'darwin':
|
if platform == 'darwin':
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from os import chmod, makedirs, system
|
from os import chmod, makedirs, system
|
||||||
@@ -136,10 +136,12 @@ else:
|
|||||||
'Pillow>=2.8.2',
|
'Pillow>=2.8.2',
|
||||||
'psutil>=3.0.0',
|
'psutil>=3.0.0',
|
||||||
'python-slugify>=1.1.3',
|
'python-slugify>=1.1.3',
|
||||||
'scandir>=1.1.0',
|
|
||||||
],
|
],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
if version_info[1] < 5:
|
||||||
|
extra_options['install_requires'].append('scandir>=1.1.0')
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=NAME,
|
name=NAME,
|
||||||
|
|||||||
Reference in New Issue
Block a user