Remove scandir compatibility

This commit is contained in:
Dave Halter
2020-07-24 01:28:40 +02:00
parent be5429c02c
commit a2fc850dc9
2 changed files with 1 additions and 28 deletions

View File

@@ -2,7 +2,6 @@
To ensure compatibility from Python ``2.7`` - ``3.3``, a module has been
created. Clearly there is huge need to use conforming syntax.
"""
import os
import sys
import platform
@@ -42,28 +41,3 @@ def u(string):
if not isinstance(string, unicode):
return unicode(str(string), 'UTF-8')
return string
if sys.version_info < (3, 5):
"""
A super-minimal shim around listdir that behave like
scandir for the information we need.
"""
class _DirEntry:
def __init__(self, name, basepath):
self.name = name
self.basepath = basepath
@property
def path(self):
return os.path.join(self.basepath, self.name)
def stat(self):
# won't follow symlinks
return os.lstat(os.path.join(self.basepath, self.name))
def scandir(dir):
return [_DirEntry(name, dir) for name in os.listdir(dir)]
else:
from os import scandir

View File

@@ -14,7 +14,6 @@ try:
except:
import pickle
from parso._compatibility import scandir
from parso.file_io import FileIO
LOG = logging.getLogger(__name__)
@@ -232,7 +231,7 @@ def clear_inactive_cache(
version_path = os.path.join(cache_path, version_path)
if not os.path.isdir(version_path):
continue
for file in scandir(version_path):
for file in os.scandir(version_path):
if (
file.stat().st_atime + _CACHED_FILE_MAXIMUM_SURVIVAL
<= time.time()