Add a simpler way to query properties.

This commit is contained in:
Sergio Martínez Portela 2020-12-28 14:34:18 +01:00
parent f1be0c3a72
commit c522afd290

View File

@ -187,6 +187,13 @@ class Headline:
else: else:
return list(self.shallow_tags) + self.parent.tags 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): def get_links(self):
for content in self.contents: for content in self.contents:
yield from get_links_from_content(content) yield from get_links_from_content(content)