def get_body_compat(node: OrgNode) -> str: try: return node.get_body(format='raw') except Exception as e: if node.is_root(): # get_body was only added to root in 0.2.0 for x in warn_old_orgparse_once(): # ugh. really crap, but it will at least only warn once... (becaue it caches) raise x return UPDATE_ORGPARSE_WARNING else: raise e
def _parse_node(n: OrgNode) -> Parsed: if n.is_root(): return Parsed(dt=None, heading='') heading = n.get_heading('raw') pp = n.properties or {} createds = pp.get('CREATED', None) if createds is None: # TODO replace with 'match', but need to strip off priority etc first? # see _parse_heading in orgparse m = rgx.search(heading) if m is not None: createds = m.group(0) # could be None # TODO a bit hacky.. heading = heading.replace(createds + ' ', '') if createds is not None: [odt] = OrgDate.list_from_str(createds) dt = odt.start else: dt = None return Parsed(dt=dt, heading=heading)
def _parse_node(n: OrgNode) -> Parsed: if n.is_root(): return Parsed(dt=None, heading='') heading = n.get_heading('raw') pp = n.properties createds = cast(Optional[str], pp.get('CREATED', None)) if createds is None: # TODO replace with 'match', but need to strip off priority etc first? # see _parse_heading in orgparse # todo maybe use n.get_timestamps(inactive=True, point=True)? only concern is that it's searching in the body as well? m = CREATED_RGX.search(heading) if m is not None: createds = m.group(0) # could be None # todo a bit hacky.. heading = heading.replace(createds + ' ', '') if createds is not None: [odt] = OrgDate.list_from_str(createds) dt = odt.start else: dt = None return Parsed(dt=dt, heading=heading)
def _get_heading(n: OrgNode): # todo not sure if it's really that useful to distinguish root and non-root... # maybe have a mode that returns uniform entries, and just relies on the convention return '' if n.is_root() else n.get_heading(format='raw')
def _get_body(n: OrgNode): if n.is_root(): return '\n'.join(n._lines) else: return n.get_body(format='raw')
def _get_heading(n: OrgNode): return '' if n.is_root() else n.get_heading( format='raw') # TODO convert links to html?