From c522afd290fbba28d6d9c8fa0a0fcf810fb52caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Mon, 28 Dec 2020 14:34:18 +0100 Subject: [PATCH] Add a simpler way to query properties. --- org_rw/org_rw.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index bc5ae06..005156d 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -187,6 +187,13 @@ class Headline: else: return list(self.shallow_tags) + self.parent.tags + def get_property(self, name: str, default=None): + for prop in self.properties: + if prop.key == name: + return prop.value + + return default + def get_links(self): for content in self.contents: yield from get_links_from_content(content)