mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Create OrgNode hasBody method. Use it in org_to_jsonl checks
This commit is contained in:
@@ -106,8 +106,8 @@ def convert_org_nodes_to_entries(entries: list[orgnode.Orgnode], entry_to_file_m
|
||||
for entry in entries:
|
||||
entry_dict = dict()
|
||||
|
||||
# Ignore title notes i.e notes with just headings and empty body
|
||||
if not entry.Body() or re.sub(r'\n|\t|\r| ', '', entry.Body()) == "":
|
||||
if not entry.hasBody():
|
||||
# Ignore title notes i.e notes with just headings and empty body
|
||||
continue
|
||||
|
||||
entry_dict["compiled"] = f'{entry.Heading()}.'
|
||||
@@ -130,7 +130,7 @@ def convert_org_nodes_to_entries(entries: list[orgnode.Orgnode], entry_to_file_m
|
||||
if state.verbose > 2:
|
||||
logger.debug(f'Scheduled: {entry.Scheduled().strftime("%Y-%m-%d")}')
|
||||
|
||||
if entry.Body():
|
||||
if entry.hasBody():
|
||||
entry_dict["compiled"] += f'\n {entry.Body()}'
|
||||
if state.verbose > 2:
|
||||
logger.debug(f"Body: {entry.Body()}")
|
||||
|
||||
@@ -262,6 +262,12 @@ class Orgnode(object):
|
||||
"""
|
||||
return self.body
|
||||
|
||||
def hasBody(self):
|
||||
"""
|
||||
Returns True if node has non empty body, else False
|
||||
"""
|
||||
return self.body and re.sub(r'\n|\t|\r| ', '', self.body) != ''
|
||||
|
||||
def Level(self):
|
||||
"""
|
||||
Returns an integer corresponding to the level of the node.
|
||||
|
||||
Reference in New Issue
Block a user