Skip to content

request: support pathlib objects #8

@armijnhemel

Description

@armijnhemel

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions