From 21ed551a549171caff0398caa0ce3bfb1c862988 Mon Sep 17 00:00:00 2001 From: Cedric Leporcq Date: Sat, 17 Apr 2021 17:00:39 +0200 Subject: [PATCH] Discard python 2.7 compatibility --- elodie.py | 4 -- elodie/compatability.py | 48 ------------------- elodie/dependencies.py | 1 - elodie/external/pyexiftool.py | 5 +- elodie/filesystem.py | 2 - elodie/geolocation.py | 4 -- elodie/log.py | 1 - elodie/media/audio.py | 1 - elodie/media/media.py | 1 - elodie/media/photo.py | 2 - elodie/media/video.py | 3 -- elodie/plugins/dummy/dummy.py | 1 - elodie/plugins/googlephotos/googlephotos.py | 1 - elodie/plugins/plugins.py | 1 - elodie/plugins/runtimeerror/runtimeerror.py | 1 - elodie/plugins/throwerror/throwerror.py | 1 - elodie/tools/add_original_name.py | 1 - requirements.txt | 1 - tests/config_test.py | 1 - tests/constants_test.py | 17 ++++--- tests/filesystem_test.py | 1 - tests/helper.py | 3 -- tests/localstorage_test.py | 2 - tests/log_test.py | 1 - tests/media/audio_test.py | 1 - tests/media/photo_test.py | 1 - .../plugins/googlephotos/googlephotos_test.py | 1 - tests/plugins_test.py | 1 - tests/result_test.py | 1 - 29 files changed, 9 insertions(+), 100 deletions(-) diff --git a/elodie.py b/elodie.py index 3092d8e..fc977a3 100755 --- a/elodie.py +++ b/elodie.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from __future__ import print_function import os import re import sys @@ -36,9 +35,6 @@ from elodie import constants FILESYSTEM = FileSystem() def import_file(_file, destination, album_from_folder, trash, allow_duplicates): - - _file = _decode(_file) - destination = _decode(destination) """Set file metadata and move it to destination. """ diff --git a/elodie/compatability.py b/elodie/compatability.py index bc6f5f3..84eed84 100644 --- a/elodie/compatability.py +++ b/elodie/compatability.py @@ -30,51 +30,3 @@ def _bytes(string): else: return bytes(string) -def _copyfile(src, dst): - # shutil.copy seems slow, changing to streaming according to - # http://stackoverflow.com/questions/22078621/python-how-to-copy-files-fast # noqa - # Python 3 hangs using open/write method so we proceed with shutil.copy - # and only perform the optimized write for Python 2. - if (constants.python_version == 3): - # Do not use copy2(), it will have an issue when copying to a - # network/mounted drive. - # Using copy and manual set_date_from_filename gets the job done. - # The calling function is responsible for setting the time. - shutil.copy(src, dst) - return - - try: - O_BINARY = os.O_BINARY - except: - O_BINARY = 0 - - READ_FLAGS = os.O_RDONLY | O_BINARY - WRITE_FLAGS = os.O_WRONLY | os.O_CREAT | os.O_TRUNC | O_BINARY - TEN_MEGABYTES = 10485760 - BUFFER_SIZE = min(TEN_MEGABYTES, os.path.getsize(src)) - - try: - fin = os.open(src, READ_FLAGS) - stat = os.fstat(fin) - fout = os.open(dst, WRITE_FLAGS, stat.st_mode) - for x in iter(lambda: os.read(fin, BUFFER_SIZE), ""): - os.write(fout, x) - finally: - try: - os.close(fin) - except: - pass - try: - os.close(fout) - except: - pass - - -# If you want cross-platform overwriting of the destination, -# use os.replace() instead of rename(). -# https://docs.python.org/3/library/os.html#os.rename -def _rename(src, dst): - if (constants.python_version == 3): - return os.replace(src, dst) - else: - return os.rename(src, dst) diff --git a/elodie/dependencies.py b/elodie/dependencies.py index e575b5d..1b614f3 100644 --- a/elodie/dependencies.py +++ b/elodie/dependencies.py @@ -2,7 +2,6 @@ Helpers for checking for an interacting with external dependencies. These are things that Elodie requires, but aren't installed automatically for the user. """ -from __future__ import print_function import os import sys diff --git a/elodie/external/pyexiftool.py b/elodie/external/pyexiftool.py index 51ff7f5..6678524 100644 --- a/elodie/external/pyexiftool.py +++ b/elodie/external/pyexiftool.py @@ -55,8 +55,6 @@ Example usage:: d["EXIF:DateTimeOriginal"])) """ -from __future__ import unicode_literals - import sys import subprocess import os @@ -65,7 +63,6 @@ import warnings import logging import codecs -from future.utils import with_metaclass try: # Py3k compatibility basestring @@ -162,7 +159,7 @@ class Singleton(type): cls.instance = super(Singleton, cls).__call__(*args, **kwargs) return cls.instance -class ExifTool(object, with_metaclass(Singleton)): +class ExifTool(object, metaclass=Singleton): """Run the `exiftool` command-line tool and communicate to it. You can pass two arguments to the constructor: diff --git a/elodie/filesystem.py b/elodie/filesystem.py index 26a076c..bad6453 100644 --- a/elodie/filesystem.py +++ b/elodie/filesystem.py @@ -3,7 +3,6 @@ General file system methods. .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function from builtins import object import os @@ -12,7 +11,6 @@ import shutil import time from datetime import datetime -from elodie import compatability from elodie import geolocation from elodie import log from elodie.config import load_config diff --git a/elodie/geolocation.py b/elodie/geolocation.py index d4ce5c5..f7e99c2 100644 --- a/elodie/geolocation.py +++ b/elodie/geolocation.py @@ -1,10 +1,6 @@ """Look up geolocation information for media objects.""" -from __future__ import print_function -from __future__ import division -from future import standard_library from past.utils import old_div -standard_library.install_aliases() # noqa from os import path diff --git a/elodie/log.py b/elodie/log.py index c1f980b..c1a1974 100644 --- a/elodie/log.py +++ b/elodie/log.py @@ -3,7 +3,6 @@ General file system methods. .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function import sys diff --git a/elodie/media/audio.py b/elodie/media/audio.py index 8409512..b79123f 100644 --- a/elodie/media/audio.py +++ b/elodie/media/audio.py @@ -5,7 +5,6 @@ class. .. moduleauthor:: Jaisen Mathai """ -from __future__ import absolute_import from .video import Video diff --git a/elodie/media/media.py b/elodie/media/media.py index 3ca389f..f5217a8 100644 --- a/elodie/media/media.py +++ b/elodie/media/media.py @@ -8,7 +8,6 @@ are used to represent the actual files. .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function import os import six diff --git a/elodie/media/photo.py b/elodie/media/photo.py index 7ba7244..2f12796 100644 --- a/elodie/media/photo.py +++ b/elodie/media/photo.py @@ -4,8 +4,6 @@ image objects (JPG, DNG, etc.). .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function -from __future__ import absolute_import import imghdr import os diff --git a/elodie/media/video.py b/elodie/media/video.py index dff6644..28580ed 100644 --- a/elodie/media/video.py +++ b/elodie/media/video.py @@ -4,9 +4,6 @@ objects (AVI, MOV, etc.). .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function -from __future__ import absolute_import -from __future__ import division # load modules from datetime import datetime diff --git a/elodie/plugins/dummy/dummy.py b/elodie/plugins/dummy/dummy.py index 4dd220f..46789fc 100644 --- a/elodie/plugins/dummy/dummy.py +++ b/elodie/plugins/dummy/dummy.py @@ -3,7 +3,6 @@ Dummy plugin object used for tests. .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function from elodie.plugins.plugins import PluginBase diff --git a/elodie/plugins/googlephotos/googlephotos.py b/elodie/plugins/googlephotos/googlephotos.py index 6be012d..d63b3e4 100644 --- a/elodie/plugins/googlephotos/googlephotos.py +++ b/elodie/plugins/googlephotos/googlephotos.py @@ -19,7 +19,6 @@ Upload code adapted from https://github.com/eshmu/gphotos-upload .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function import json diff --git a/elodie/plugins/plugins.py b/elodie/plugins/plugins.py index b863dae..cc6c96a 100644 --- a/elodie/plugins/plugins.py +++ b/elodie/plugins/plugins.py @@ -3,7 +3,6 @@ Plugin object. .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function from builtins import object import io diff --git a/elodie/plugins/runtimeerror/runtimeerror.py b/elodie/plugins/runtimeerror/runtimeerror.py index cad00e4..33c1366 100644 --- a/elodie/plugins/runtimeerror/runtimeerror.py +++ b/elodie/plugins/runtimeerror/runtimeerror.py @@ -3,7 +3,6 @@ RuntimeError plugin object used for tests. .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function from elodie.plugins.plugins import PluginBase diff --git a/elodie/plugins/throwerror/throwerror.py b/elodie/plugins/throwerror/throwerror.py index feb7ec6..b35fd1a 100644 --- a/elodie/plugins/throwerror/throwerror.py +++ b/elodie/plugins/throwerror/throwerror.py @@ -3,7 +3,6 @@ ThrowError plugin object used for tests. .. moduleauthor:: Jaisen Mathai """ -from __future__ import print_function from elodie.plugins.plugins import PluginBase, ElodiePluginError diff --git a/elodie/tools/add_original_name.py b/elodie/tools/add_original_name.py index 559de2a..ee66ba0 100644 --- a/elodie/tools/add_original_name.py +++ b/elodie/tools/add_original_name.py @@ -1,4 +1,3 @@ -from __future__ import print_function import os import re diff --git a/requirements.txt b/requirements.txt index 33f5dbb..a828291 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ click==6.6 requests==2.20.0 Send2Trash==1.3.0 -future==0.16.0 configparser==3.5.0 tabulate==0.7.7 Pillow==6.2.2; python_version == '2.7' diff --git a/tests/config_test.py b/tests/config_test.py index 01f8acd..f3b547f 100755 --- a/tests/config_test.py +++ b/tests/config_test.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import # Project imports import os diff --git a/tests/constants_test.py b/tests/constants_test.py index ea063df..d032465 100644 --- a/tests/constants_test.py +++ b/tests/constants_test.py @@ -1,14 +1,13 @@ -from __future__ import absolute_import -# Project imports +# # Project imports -import os -import sys -import unittest +# import os +# import sys +# import unittest -try: - reload # Python 2.7 -except NameError: - try: +# try: +# reload # Python 2.7 +# except NameError: +# try: from importlib import reload # Python 3.4+ except ImportError: from imp import reload # Python 3.0 - 3.3 diff --git a/tests/filesystem_test.py b/tests/filesystem_test.py index 3a12319..6061ca4 100644 --- a/tests/filesystem_test.py +++ b/tests/filesystem_test.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import # Project imports import mock import os diff --git a/tests/helper.py b/tests/helper.py index 54270b3..3900b7f 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -1,5 +1,3 @@ -from __future__ import division -from __future__ import unicode_literals from builtins import range from past.utils import old_div import hashlib @@ -14,7 +12,6 @@ import urllib from datetime import datetime from datetime import timedelta -from elodie.compatability import _rename from elodie.external.pyexiftool import ExifTool from elodie.dependencies import get_exiftool from elodie import constants diff --git a/tests/localstorage_test.py b/tests/localstorage_test.py index cfdef90..e7fe0f7 100644 --- a/tests/localstorage_test.py +++ b/tests/localstorage_test.py @@ -1,5 +1,3 @@ -from __future__ import print_function -from __future__ import absolute_import # Project imports import os import sys diff --git a/tests/log_test.py b/tests/log_test.py index f935787..ace9d41 100644 --- a/tests/log_test.py +++ b/tests/log_test.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import # Project imports import os diff --git a/tests/media/audio_test.py b/tests/media/audio_test.py index 98ae4c2..431a8da 100644 --- a/tests/media/audio_test.py +++ b/tests/media/audio_test.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 # Project imports -from __future__ import print_function import os import sys diff --git a/tests/media/photo_test.py b/tests/media/photo_test.py index 97bbdb9..fdda0c3 100644 --- a/tests/media/photo_test.py +++ b/tests/media/photo_test.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 # Project imports -from __future__ import unicode_literals import os import sys diff --git a/tests/plugins/googlephotos/googlephotos_test.py b/tests/plugins/googlephotos/googlephotos_test.py index 64ea589..71b0b8d 100644 --- a/tests/plugins/googlephotos/googlephotos_test.py +++ b/tests/plugins/googlephotos/googlephotos_test.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import # Project imports import mock import os diff --git a/tests/plugins_test.py b/tests/plugins_test.py index 8a59b89..cc0c375 100644 --- a/tests/plugins_test.py +++ b/tests/plugins_test.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import # Project imports import mock import os diff --git a/tests/result_test.py b/tests/result_test.py index a373fd6..ce254c4 100644 --- a/tests/result_test.py +++ b/tests/result_test.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import # Project imports import os