Discard python 2.7 compatibility

This commit is contained in:
Cédric Leporcq 2021-04-17 17:00:39 +02:00
parent 0363fd4302
commit 21ed551a54
29 changed files with 9 additions and 100 deletions

View File

@ -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.
"""

View File

@ -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)

View File

@ -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

View File

@ -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:

View File

@ -3,7 +3,6 @@ General file system methods.
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
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

View File

@ -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

View File

@ -3,7 +3,6 @@ General file system methods.
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
import sys

View File

@ -5,7 +5,6 @@ class.
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import absolute_import
from .video import Video

View File

@ -8,7 +8,6 @@ are used to represent the actual files.
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
import os
import six

View File

@ -4,8 +4,6 @@ image objects (JPG, DNG, etc.).
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
from __future__ import absolute_import
import imghdr
import os

View File

@ -4,9 +4,6 @@ objects (AVI, MOV, etc.).
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
# load modules
from datetime import datetime

View File

@ -3,7 +3,6 @@ Dummy plugin object used for tests.
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
from elodie.plugins.plugins import PluginBase

View File

@ -19,7 +19,6 @@ Upload code adapted from https://github.com/eshmu/gphotos-upload
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
import json

View File

@ -3,7 +3,6 @@ Plugin object.
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
from builtins import object
import io

View File

@ -3,7 +3,6 @@ RuntimeError plugin object used for tests.
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
from elodie.plugins.plugins import PluginBase

View File

@ -3,7 +3,6 @@ ThrowError plugin object used for tests.
.. moduleauthor:: Jaisen Mathai <jaisen@jmathai.com>
"""
from __future__ import print_function
from elodie.plugins.plugins import PluginBase, ElodiePluginError

View File

@ -1,4 +1,3 @@
from __future__ import print_function
import os
import re

View File

@ -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'

View File

@ -1,4 +1,3 @@
from __future__ import absolute_import
# Project imports
import os

View File

@ -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

View File

@ -1,4 +1,3 @@
from __future__ import absolute_import
# Project imports
import mock
import os

View File

@ -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

View File

@ -1,5 +1,3 @@
from __future__ import print_function
from __future__ import absolute_import
# Project imports
import os
import sys

View File

@ -1,4 +1,3 @@
from __future__ import absolute_import
# Project imports
import os

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8
# Project imports
from __future__ import print_function
import os
import sys

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8
# Project imports
from __future__ import unicode_literals
import os
import sys

View File

@ -1,4 +1,3 @@
from __future__ import absolute_import
# Project imports
import mock
import os

View File

@ -1,4 +1,3 @@
from __future__ import absolute_import
# Project imports
import mock
import os

View File

@ -1,4 +1,3 @@
from __future__ import absolute_import
# Project imports
import os