From 53b495249bc685ad6f7a1b90ff100d91dc1e26f1 Mon Sep 17 00:00:00 2001 From: randogoth Date: Sat, 24 Oct 2026 21:26:05 +0300 Subject: [PATCH] fix: scan the current folder when otag scan gets no path --- orvanitag/orvani.py | 3 ++- tests/test_plugins.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/orvanitag/orvani.py b/orvanitag/orvani.py index e9bda06..3067456 100644 --- a/orvanitag/orvani.py +++ b/orvanitag/orvani.py @@ -567,7 +567,8 @@ class OrvaniTag: def scan(self, path: str, recursive: bool=False): - for (root,dirs,files) in os.walk(path, topdown=True): + # os.walk('') yields nothing, so an empty path means the current folder + for (root,dirs,files) in os.walk(path or '.', topdown=True): # process every file with a reader plugin if self.ENABLE_PLUGINS: diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 5d4281c..aaa923c 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -131,3 +131,15 @@ def test_write_uses_config_of_the_files_folder(cwd): OrvaniTag().add('sub/doc.pdf', '#lofi') assert OrvaniTag().write_metadata('sub/doc.pdf', 'pdf') == [6, 'pdf'] + + +def test_cmd_scan_defaults_to_current_folder(cwd, monkeypatch): + (cwd / 'sub').mkdir() + writer = PdfWriter() + writer.add_blank_page(72, 72) + writer.add_metadata({'/Keywords': '#lofi'}) + writer.write(cwd / 'sub' / 'doc.pdf') + + monkeypatch.setattr(sys, 'argv', ['otag', 's']) + main() + assert (cwd / 'sub' / orvani.CONTEXT_FILE).read_text() == 'doc.pdf --- #lofi\n'