From 570e6bb76494d1d602b2ba0a34baa0345745dddc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sun, 1 Sep 2024 23:35:33 +0200 Subject: [PATCH] Implement OrgDoc `.tags`. --- org_rw/org_rw.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index 99ac122..7c6d931 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -753,10 +753,7 @@ class Headline: @property def tags(self): - if isinstance(self.parent, OrgDoc): - return list(self.shallow_tags) - else: - return list(self.shallow_tags) + self.parent.tags + return list(self.shallow_tags) + self.parent.tags def add_tag(self, tag: str): self.shallow_tags.append(tag) @@ -2280,6 +2277,13 @@ class OrgDoc: def path(self): return self._path + @property + def tags(self) -> list[str]: + for kw in self.keywords: + if kw.key == "FILETAGS": + return kw.value.strip(':').split(':') + return [] + ## Querying def get_links(self): for headline in self.headlines: