diff options
author | Paweł Jastrzębski <pawelj@iosphe.re> | 2015-09-15 15:44:52 +0200 |
---|---|---|
committer | Paweł Jastrzębski <pawelj@iosphe.re> | 2015-09-15 15:44:52 +0200 |
commit | 14f677ec68389382c4554d96fd02f8e5e8d076ec (patch) | |
tree | d5cd246c2141e4cc04d3564b31f1493dd212a294 | |
parent | Yet another Windows file lock fixes (diff) | |
download | kcc-14f677ec68389382c4554d96fd02f8e5e8d076ec.tar.gz kcc-14f677ec68389382c4554d96fd02f8e5e8d076ec.tar.bz2 kcc-14f677ec68389382c4554d96fd02f8e5e8d076ec.zip |
Python 3.5+ include scandir
-rw-r--r-- | kcc/cbxarchive.py | 5 | ||||
-rwxr-xr-x | kcc/comic2ebook.py | 5 | ||||
-rw-r--r-- | kcc/comic2panel.py | 5 | ||||
-rw-r--r-- | kcc/shared.py | 14 | ||||
-rwxr-xr-x | setup.py | 10 |
5 files changed, 26 insertions, 13 deletions
diff --git a/kcc/cbxarchive.py b/kcc/cbxarchive.py index 9332eef..97c26ba 100644 --- a/kcc/cbxarchive.py +++ b/kcc/cbxarchive.py @@ -22,7 +22,10 @@ from zipfile import is_zipfile, ZipFile from subprocess import STDOUT, PIPE from psutil import Popen from shutil import move, copy -from scandir import walk +try: + from scandir import walk +except ImportError: + walk = os.walk from . import rarfile from .shared import check7ZFile as is_7zfile, saferReplace diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index 200c634..dfb3994 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -37,12 +37,15 @@ from slugify import slugify as slugifyExt from PIL import Image from subprocess import STDOUT, PIPE from psutil import Popen, virtual_memory -from scandir import walk from html import escape try: from PyQt5 import QtCore except ImportError: QtCore = None +try: + from scandir import walk +except ImportError: + walk = os.walk from .shared import md5Checksum, getImageFileName, walkSort, walkLevel, saferReplace from . import comic2panel from . import image diff --git a/kcc/comic2panel.py b/kcc/comic2panel.py index 2bfe3d9..8625fb8 100644 --- a/kcc/comic2panel.py +++ b/kcc/comic2panel.py @@ -24,12 +24,15 @@ from shutil import rmtree, copytree, move from optparse import OptionParser, OptionGroup from multiprocessing import Pool from PIL import Image, ImageStat, ImageOps -from scandir import walk from .shared import getImageFileName, walkLevel, walkSort try: from PyQt5 import QtCore except ImportError: QtCore = None +try: + from scandir import walk +except ImportError: + walk = os.walk def mergeDirectoryTick(output): diff --git a/kcc/shared.py b/kcc/shared.py index eac6bf8..89d5990 100644 --- a/kcc/shared.py +++ b/kcc/shared.py @@ -17,6 +17,7 @@ # import os +from sys import version_info from hashlib import md5 from html.parser import HTMLParser from distutils.version import StrictVersion @@ -29,7 +30,7 @@ from traceback import format_tb try: from scandir import walk except ImportError: - walk = None + walk = os.walk class HTMLStripper(HTMLParser): @@ -156,12 +157,13 @@ def dependencyCheck(level): missing.append('Pillow 2.8.2+') except ImportError: missing.append('Pillow 2.8.2+') - try: - from scandir import __version__ as scandirVersion - if StrictVersion('1.1') > StrictVersion(scandirVersion): + if version_info[1] < 5: + try: + from scandir import __version__ as scandirVersion + if StrictVersion('1.1') > StrictVersion(scandirVersion): + missing.append('scandir 1.1+') + except ImportError: missing.append('scandir 1.1+') - except ImportError: - missing.append('scandir 1.1+') if len(missing) > 0: print('ERROR: ' + ', '.join(missing) + ' is not installed!') exit(1) diff --git a/setup.py b/setup.py index 8a7c8cc..0857e8f 100755 --- a/setup.py +++ b/setup.py @@ -11,17 +11,17 @@ Usage (Linux): Usage (Mac OS X): python3 setup.py py2app """ + from sys import platform, version_info, argv from kcc import __version__ -if version_info[0] != 3: - print('ERROR: This is Python 3 script!') - exit(1) + NAME = 'KindleComicConverter' VERSION = __version__ MAIN = 'kcc.py' extra_options = {} + if platform == 'darwin': from setuptools import setup from os import chmod, makedirs, system @@ -136,10 +136,12 @@ else: 'Pillow>=2.8.2', 'psutil>=3.0.0', 'python-slugify>=1.1.3', - 'scandir>=1.1.0', ], zip_safe=False, ) + if version_info[1] < 5: + extra_options['install_requires'].append('scandir>=1.1.0') + setup( name=NAME, |