Skip to content

Commit

Permalink
switching to os.scandir
Browse files Browse the repository at this point in the history
  • Loading branch information
brno32 committed Jul 19, 2023
1 parent 337cc04 commit 224339e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
18 changes: 0 additions & 18 deletions src/smbclient/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,24 +1172,6 @@ def _set_basic_information(
set_info(transaction, basic_info)


class LocalDirEntry:
"""Mimics the structure of SMBDirEntry, but instead encapsulates a directory/file on a local filesystem"""

def __init__(self, path) -> None:
self.path = path

@property
def name(self):
"""The entry's base filename, relative to the os.listdir() path argument."""
return os.path.basename(self.path)

def is_symlink(self):
return os.path.islink(self.path)

def is_dir(self):
return os.path.isdir(self.path)


class SMBDirEntry:
def __init__(self, raw, dir_info, connection_cache=None):
self._smb_raw = raw
Expand Down
4 changes: 2 additions & 2 deletions src/smbclient/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import sys

from smbclient._io import SMBFileTransaction, SMBRawIO, query_info, set_info
from smbclient._os import LocalDirEntry, SMBDirEntry
from smbclient._os import SMBDirEntry
from smbclient._os import copyfile as smbclient_copyfile
from smbclient._os import (
is_remote_path,
Expand Down Expand Up @@ -296,7 +296,7 @@ def copytree(
if is_remote_path(src):
dir_entries = list(scandir(src, **kwargs))
else:
dir_entries = [LocalDirEntry(os.path.join(src, result)) for result in os.listdir(src)]
dir_entries = list(os.scandir(src))

if is_remote_path(dst):
makedirs(dst, exist_ok=dirs_exist_ok, **kwargs)
Expand Down

0 comments on commit 224339e

Please # to comment.