telfhash icon indicating copy to clipboard operation
telfhash copied to clipboard

request: support pathlib objects

Open armijnhemel opened this issue 4 years ago • 1 comments

Currently telfhash doesn't support pathlib objects https://docs.python.org/3/library/pathlib.html and gives an error:

>>> import telfhash
>>> import pathlib
>>> a = pathlib.Path('/bin/ls')
>>> type(a)
<class 'pathlib.PosixPath'>
>>> telfhash.telfhash(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/g4a5izmyv29k6jibzmwa9a8yv2gyj1nw-python3-3.9.6-env/lib/python3.9/site-packages/telfhash/telfhash.py", line 487, in telfhash
    files_list += expand_filepath(path, recursive=recursive)
  File "/nix/store/g4a5izmyv29k6jibzmwa9a8yv2gyj1nw-python3-3.9.6-env/lib/python3.9/site-packages/telfhash/telfhash.py", line 353, in expand_filepath
    for filepath in glob.glob(input_filepath):
  File "/nix/store/81lwy2hfqj4c1943b1x8a0qsivjhdhw9-python3-3.9.6/lib/python3.9/glob.py", line 22, in glob
    return list(iglob(pathname, recursive=recursive))
  File "/nix/store/81lwy2hfqj4c1943b1x8a0qsivjhdhw9-python3-3.9.6/lib/python3.9/glob.py", line 44, in _iglob
    if not has_magic(pathname):
  File "/nix/store/81lwy2hfqj4c1943b1x8a0qsivjhdhw9-python3-3.9.6/lib/python3.9/glob.py", line 156, in has_magic
    match = magic_check.search(s)
TypeError: expected string or bytes-like object

It would be nice if pathlib could be supported in the future.

armijnhemel avatar Aug 25 '21 18:08 armijnhemel

Thanks for your suggestion. I'll take a look.

merces avatar Feb 09 '22 10:02 merces