19.0 vanilla

This commit is contained in:
Ernad Husremovic 2025-10-03 18:07:25 +02:00
parent 0a7ae8db93
commit 991d2234ca
416 changed files with 646602 additions and 300844 deletions

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
""" Which - locate a command
* adapted from Brian Curtin's http://bugs.python.org/file15381/shutil_which.patch
@ -39,7 +39,7 @@
"""
__docformat__ = 'restructuredtext en'
__all__ = 'which which_files pathsep defpath defpathext F_OK R_OK W_OK X_OK'.split()
__all__ = ['F_OK', 'R_OK', 'W_OK', 'X_OK', 'defpath', 'defpathext', 'dirname', 'pathsep', 'which', 'which_files']
import sys
from os import access, defpath, pathsep, environ, F_OK, R_OK, W_OK, X_OK
@ -70,13 +70,15 @@ def which_files(file, mode=F_OK | X_OK, path=None, pathext=None):
>>> def test_which(expected, *args, **argd):
... result = list(which_files(*args, **argd))
... assert result == expected, 'which_files: %s != %s' % (result, expected)
... assert all(path in result for path in expected) if expected else not result, 'which_files: %s != %s' % (result, expected)
...
... try:
... result = [ which(*args, **argd) ]
... result = which(*args, **argd)
... path = expected[0]
... assert split(result)[1] == split(expected[0])[1], 'which: %s not same binary %s' % (result, expected)
... except IOError:
... result = []
... assert result[:1] == expected[:1], 'which: %s != %s' % (result[:1], expected[:1])
... result = None
... assert not expected, 'which: expecting %s' % expected
>>> if windows: cmd = environ['COMSPEC']
>>> if windows: test_which([cmd], 'cmd')