mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 05:39: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:
|
for entry in entries:
|
||||||
entry_dict = dict()
|
entry_dict = dict()
|
||||||
|
|
||||||
|
if not entry.hasBody():
|
||||||
# Ignore title notes i.e notes with just headings and empty body
|
# 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
|
continue
|
||||||
|
|
||||||
entry_dict["compiled"] = f'{entry.Heading()}.'
|
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:
|
if state.verbose > 2:
|
||||||
logger.debug(f'Scheduled: {entry.Scheduled().strftime("%Y-%m-%d")}')
|
logger.debug(f'Scheduled: {entry.Scheduled().strftime("%Y-%m-%d")}')
|
||||||
|
|
||||||
if entry.Body():
|
if entry.hasBody():
|
||||||
entry_dict["compiled"] += f'\n {entry.Body()}'
|
entry_dict["compiled"] += f'\n {entry.Body()}'
|
||||||
if state.verbose > 2:
|
if state.verbose > 2:
|
||||||
logger.debug(f"Body: {entry.Body()}")
|
logger.debug(f"Body: {entry.Body()}")
|
||||||
|
|||||||
@@ -262,6 +262,12 @@ class Orgnode(object):
|
|||||||
"""
|
"""
|
||||||
return self.body
|
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):
|
def Level(self):
|
||||||
"""
|
"""
|
||||||
Returns an integer corresponding to the level of the node.
|
Returns an integer corresponding to the level of the node.
|
||||||
|
|||||||
Reference in New Issue
Block a user