Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.6 compatibility; Path.glob() #49

Open
mikewaters opened this issue Mar 17, 2017 · 3 comments
Open

Python 3.6 compatibility; Path.glob() #49

mikewaters opened this issue Mar 17, 2017 · 3 comments

Comments

@mikewaters
Copy link

Hi,

It appears that globbing behavior in Pathlib has changed/optimized to use scandir in 3.6: https://bugs.python.org/issue26032

  File "/usr/lib/python3.6/pathlib.py", line 1081, in glob
    for p in selector.select_from(self):
  File "/usr/lib/python3.6/pathlib.py", line 489, in select_from
    scandir = parent_path._accessor.scandir
AttributeError: '_ArtifactoryAccessor' object has no attribute 'scandir'

Trivially implementing scandir on _ArtifactoryAccessor results in a second failure, so this may be more than just adding a new method that wraps listdir.

@Xcelled
Copy link

Xcelled commented Jun 16, 2018

scandir() is supposed to return a list of DirEntry. listdir() returns strings. I was able to hack around it with this, though I have no idea if this is the best way to convert the strings to DirEntry-ish things:

from artifactory import _ArtifactoryAccessor

def scandir(self, pathobj):
	for x in _ArtifactoryAccessor.listdir(self, pathobj):
		yield pathobj.joinpath(x)

_ArtifactoryAccessor.scandir = scandir

@allburov
Copy link
Contributor

@Nicholas-Autio-Mitchell

Perhaps worth noting, in case it is used elsewhere:

the DirEntry objects hold both the filenames as well as the full path - as two separate attributes. This version obviously doesn't provide both, only yielding the full paths, as that is the output of os.listdir().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants