diff --git a/src/diskcollections/interfaces.py b/src/diskcollections/interfaces.py index c604544..cc6af99 100644 --- a/src/diskcollections/interfaces.py +++ b/src/diskcollections/interfaces.py @@ -1,4 +1,4 @@ -import collections +import collections.abc class ISerializer: diff --git a/src/diskcollections/iterables/clients.py b/src/diskcollections/iterables/clients.py index 9a6ab03..e1870bd 100644 --- a/src/diskcollections/iterables/clients.py +++ b/src/diskcollections/iterables/clients.py @@ -3,7 +3,6 @@ from typing import Optional from diskcollections.interfaces import IClientSequence -from diskcollections.py2to3 import TemporaryDirectory mode_str = "w+" mode_bytes = "w+b" @@ -25,7 +24,7 @@ def __init__(self, iterable=(), mode=mode_bytes): self.__mode = mode self.__available_modes = modes - {mode} self.__files = [] - self.__directory = TemporaryDirectory() + self.__directory = tempfile.TemporaryDirectory() self.extend(iterable) def __repr__(self): @@ -238,4 +237,4 @@ def safe_write(self, file_path, value): except TypeError as e: exc = e - raise exc \ No newline at end of file + raise exc diff --git a/src/diskcollections/iterables/iterables.py b/src/diskcollections/iterables/iterables.py index c2a56ef..59a2b83 100644 --- a/src/diskcollections/iterables/iterables.py +++ b/src/diskcollections/iterables/iterables.py @@ -1,10 +1,9 @@ -import collections import inspect +from collections.abc import MutableSequence from functools import partial -from diskcollections.py2to3 import izip -class List(collections.abc.MutableSequence): +class List(MutableSequence): def __init__( self, iterable=None, client_class=None, serializer_class=None ): @@ -76,7 +75,7 @@ def insert(self, index, value): self.__client.insert(index, encoded_value) -class Deque(collections.abc.MutableSequence): +class Deque(MutableSequence): def __init__( self, iterable=(), @@ -124,7 +123,7 @@ def __eq__(self, other): if len(self) != len(other): return False - for i, j in izip(self, other): + for i, j in zip(self, other): if i != j: return False @@ -134,14 +133,14 @@ def __ne__(self, other): if len(self) != len(other): return True - for i, j in izip(self, other): + for i, j in zip(self, other): if i != j: return True return False def __lt__(self, other): - for i, j in izip(self, other): + for i, j in zip(self, other): if i >= j: return False @@ -151,7 +150,7 @@ def __lt__(self, other): return True def __le__(self, other): - for i, j in izip(self, other): + for i, j in zip(self, other): if i > j: return False @@ -161,14 +160,14 @@ def __le__(self, other): return True def __gt__(self, other): - for i, j in izip(self, other): + for i, j in zip(self, other): if i <= j: return False return True def __ge__(self, other): - for i, j in izip(self, other): + for i, j in zip(self, other): if i < j: return False diff --git a/src/diskcollections/py2to3.py b/src/diskcollections/py2to3.py deleted file mode 100644 index 21812bd..0000000 --- a/src/diskcollections/py2to3.py +++ /dev/null @@ -1,26 +0,0 @@ -import itertools -import shutil -import sys -import tempfile - -if sys.version_info >= (3, 0): - basestring = str - izip = zip -else: - basestring = basestring - izip = itertools.izip - -if sys.version_info >= (3, 4): - TemporaryDirectory = tempfile.TemporaryDirectory -else: - - class TemporaryDirectory: - def __init__(self): - self._directory_path = tempfile.mkdtemp() - - @property - def name(self): - return self._directory_path - - def cleanup(self): - shutil.rmtree(self.name)