Repository: karlicoss/promnesia (language: python)

Issue:
URLs in PROPERTY drawers not recognized?
Hi!
In the following function to get URLs from an orgmode source: https://github.com/karlicoss/promnesia/blob/8eb9ef3ec30ad045bea7a6a4e89e9579b60e0b1c/src/promnesia/sources/org.py#L103 currently only headings or body are tested for the presence of URLs. The property drawers are only tested for time stamps. I have a setup where notes are captured with a :LINK: property with a URL. Is it possible to add a check to loop over the key-value pairs in the property drawers to test for presence of URLS?
I tried to hack this together, and it works for me for now, but is there a correct way of accomplishing this?
```
    if not n.is_root():        
        try:
            propertydraw = '\n'.join(str(v) for v in n.properties.values()) #ugly hack to get values as single string, can iterate over values?
        except Exception as e:
            logger.exception(e)
            yield e
        else:
            yield from iter_urls(propertydraw, syntax='org')        
```




Discussion / hints:
Hi, yeah this looks good! And yeah I think iterating over values makes sense?
I'm also in need of this, please merge to master! :-)

This (using values directly) also seems to work, but I'm using promnesia for the first time, testing required:

``` py
    if not n.is_root():
        try:
            values = n.properties.values()
        except Exception as e:
            logger.exception(e)
            yield e
        else:
            for v in values:
                assert isinstance(v, str), repr(v)
                yield from iter_urls(str(v), syntax='org')

```

Tell me if a PR would be helpful using this code.

@hrehfeld this looks good, thanks! Although best to replace `isinstance` assert with if statement though -- for some historic reasons some properties could be int, so this assert might legitimately trigger :) 
https://github.com/karlicoss/orgparse/blob/45b366eb5c23e4149d8bc7a319f10dc74888fe51/orgparse/node.py#L123

For tests -- CI runs tests, could you add a short tests here? https://github.com/karlicoss/promnesia/blob/8eb9ef3ec30ad045bea7a6a4e89e9579b60e0b1c/tests/test_org_indexer.py

Can create a new file under https://github.com/karlicoss/promnesia/tree/8eb9ef3ec30ad045bea7a6a4e89e9579b60e0b1c/tests/testdata/auto/orgs and add a new test, or maybe you can just add a new outline to `file.org` and modify `test_org_indexer` -- up to you!

Fix patch:
diff --git a/setup.py b/setup.py
index e2d2fddd..85029ce3 100644
--- a/setup.py
+++ b/setup.py
@@ -96,7 +96,7 @@ def main() -> None:
         'mistletoe',
     ],
     ('org'     , 'dependencies for sources.org'     ): [
-        'orgparse>=0.2.0',
+        'orgparse>=0.3.0',
     ],
     ('telegram', 'dependencies for sources.telegram'): [
         'dataset',
diff --git a/src/promnesia/sources/org.py b/src/promnesia/sources/org.py
index b67217f9..a021faea 100644
--- a/src/promnesia/sources/org.py
+++ b/src/promnesia/sources/org.py
@@ -111,6 +111,15 @@ def iter_org_urls(n: OrgNode) -> Iterator[Res[Url]]:
     else:
         yield from iter_urls(heading, syntax='org')
 
+    try:
+        values = n.properties.values()
+    except Exception as e:
+        logger.exception(e)
+        yield e
+    else:
+        for v in values:
+            yield from iter_urls(str(v), syntax='org')
+
     try:
         content = get_body_compat(n)
     except Exception as e:


Test patch:
diff --git a/tests/test_org_indexer.py b/tests/test_org_indexer.py
index 023878d9..10d9f908 100644
--- a/tests/test_org_indexer.py
+++ b/tests/test_org_indexer.py
@@ -50,3 +50,9 @@ def test_heading() -> None:
     }
 
 
+def test_url_in_properties() -> None:
+    items = [v if isinstance(v, Visit) else throw(v) for v in extract_from_file(tdata('auto/orgs/file4.org'))]
+
+    assert len(items) == 2, items
+    assert items[0].url == 'https://example.org/ref_example'
+    assert items[1].url == 'http://example.org/a_test'
diff --git a/tests/testdata/auto/orgs/file4.org b/tests/testdata/auto/orgs/file4.org
new file mode 100644
index 00000000..4a44562c
--- /dev/null
+++ b/tests/testdata/auto/orgs/file4.org
@@ -0,0 +1,7 @@
+:PROPERTIES:
+:ID:       1554c141-9567-4345-99d9-7c5e2853dbaa
+:ROAM_REFS: https://example.org/ref_example
+:END:
+#+title: A Ref Example
+
+We need [[http://example.org/a_test][a test]]!