mathause / filefinder

find and parse file and folder names
MIT License
3 stars 1 forks source link

allow passing scalar numbers #58

Closed mathause closed 8 months ago

mathause commented 1 year ago

The following currently throws an error (TypeError: 'int' object is not iterable):

import filefinder
ff = filefinder.FileFinder("", "{num}", test_paths=["1", "2"])
ff.find_files(num=1)

the workaround is:

ff.find_files(num=[1])
mathause commented 1 year ago

I do wonder why this works for strings - it should not iterate the individual letters?

mathause commented 1 year ago

They are wrapped in:

https://github.com/mathause/filefinder/blob/ab49e18fe0563dcb526cdc62d1ee05342cc67b7b/filefinder/_filefinder.py#L86-L89

mathause commented 1 year ago

Maybe:

if isinstance(value, str) or np.ndim(value) == 0:
    ...