mfarragher / obsidiantools

Obsidian tools - a Python package for analysing an Obsidian.md vault
Other
402 stars 28 forks source link

get_md_relpaths_from_dir() globbing issue #12

Closed stepsal closed 2 years ago

stepsal commented 2 years ago

Hello. Thanks for this library

I have tried this with 3.9 as suggested. But I'm getting an error straight away on gather.

File "/home/steve/.pyenv/versions/obsidian-python3.9.0/lib/python3.9/site-packages/obsidiantools/md_utils.py", line 29, in get_md_relpaths_from_dir
    for p in glob(str(dir_path / '**/*.md'), recursive=True)]
TypeError: unsupported operand type(s) for /: 'str' and 'str'

I have to change the /' to a + in the line in get_md_relpaths_from_dir() to get the globbing working!

change from

return [Path(p).relative_to(dir_path)
for p in glob(str(dir_path / '**/*.md'), recursive=True)]

to

return [Path(p).relative_to(dir_path)
for p in glob(str(dir_path + '**/*.md'), recursive=True)]
stepsal commented 2 years ago

Im on Ubuntu...

mfarragher commented 2 years ago

Thanks - I have added comment in the Mac issue. Will be able to dedicate some time for development in next few weeks.

mfarragher commented 2 years ago

@stepsal does the code in this PR work for you?: https://github.com/mfarragher/obsidiantools/pull/11

Code snippet if you sub in your vault directory path:

from pathlib import Path
from glob import glob

[Path(p).relative_to(dir_path)
 for p in glob(f"{dir_path}/**/*.md", recursive=True)]

I've merged the PR in the dev branch. If the code works then I'll close this issue.

stepsal commented 2 years ago

that works now. thanks