mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Create OrgNode hasBody method. Use it in org_to_jsonl checks
This commit is contained in:
parent
b4878d76ea
commit
db37e38df7
2 changed files with 9 additions and 3 deletions
|
@ -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()
|
||||
|
||||
if not entry.hasBody():
|
||||
# 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()) == "":
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue