We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The following program illustrates some possible variations:
#!/usr/bin/python3 import pathspec import os print("A. String pattern, string path:\n ", end="") try: s = pathspec.PathSpec.from_lines('gitwildmatch', ['*.py']) for p in os.listdir('pathspec'): if s.match_file(p): print(p, end=" ") print() except Exception as e: print("FAILED '%s'" % e) print("B. String pattern, binary path:\n ", end="") try: s = pathspec.PathSpec.from_lines('gitwildmatch', ['*.py']) for p in os.listdir(b'pathspec'): if s.match_file(p): print(p, end=' ') print() except Exception as e: print("FAILED '%s'" % e) print("C. String pattern, binary path + surrogateescape:\n ", end="") try: s = pathspec.PathSpec.from_lines('gitwildmatch', ['*.py']) for p in os.listdir(b'pathspec'): if s.match_file(p.decode('utf8','surrogateescape')): print(p, end=' ') print() except Exception as e: print("FAILED '%s'" % e) print("D. Binary pattern, binary path:\n ", end="") s = pathspec.PathSpec.from_lines('gitwildmatch', [b'*.py']) try: for p in os.listdir(b'pathspec'): if s.match_file(p): print(p, end=' ') print() except Exception as e: print("FAILED '%s'" % e)
Gives the following result when run in the source directory:
A. String pattern, string path: util.py pattern.py pathspec.py __init__.py compat.py B. String pattern, binary path: FAILED 'cannot use a string pattern on a bytes-like object' C. String pattern, binary path + surrogateescape: b'util.py' b'pattern.py' b'pathspec.py' b'__init__.py' b'compat.py' D. Binary pattern, binary path:
IMHO examples A-C behaves as expected, while example D does not match any files, neither does it complain on the pattern.
The text was updated successfully, but these errors were encountered:
@AndersBlomdell I agree that cases A-C behave correctly. I would have expected case D to yield the same results as case C. I'll look into this.
Sorry, something went wrong.
@AndersBlomdell Okay, I've fixed the issue. Your example now outputs:
A. String pattern, string path: util.py compat.py pathspec.py __init__.py pattern.py B. String pattern, binary path: FAILED 'cannot use a string pattern on a bytes-like object' C. String pattern, binary path + surrogateescape: b'util.py' b'compat.py' b'pathspec.py' b'__init__.py' b'pattern.py' D. Binary pattern, binary path: b'util.py' b'compat.py' b'pathspec.py' b'__init__.py' b'pattern.py'
No branches or pull requests
The following program illustrates some possible variations:
Gives the following result when run in the source directory:
IMHO examples A-C behaves as expected, while example D does not match any files, neither does it complain on the pattern.
The text was updated successfully, but these errors were encountered: