feat/improvements #1

Merged
kenkeiras merged 10 commits from lyz/org-rw:feat/improvements into develop 2024-07-29 14:17:18 +00:00
Showing only changes of commit f640521b56 - Show all commits

View File

@ -302,6 +302,9 @@ class Headline:
is_todo: bool, is_todo: bool,
is_done: bool, is_done: bool,
spacing, spacing,
scheduled: Optional[Time] = None,
deadline: Optional[Time] = None,
closed: Optional[Time] = None,
): ):
self.start_line = start_line self.start_line = start_line
self.depth = depth self.depth = depth
@ -324,9 +327,9 @@ class Headline:
self.parent = parent self.parent = parent
self.is_todo = is_todo self.is_todo = is_todo
self.is_done = is_done self.is_done = is_done
self.scheduled: Time = None self.scheduled = scheduled
self.deadline: Time = None self.deadline = deadline
self.closed: Time = None self.closed = closed
self.spacing = spacing self.spacing = spacing
# Read planning line # Read planning line
@ -712,7 +715,7 @@ class Headline:
time_seg = content[len("CLOCK:") :].strip() time_seg = content[len("CLOCK:") :].strip()
parsed: Time = None parsed: Optional[Time] = None
if "--" in time_seg: if "--" in time_seg:
# TODO: Consider duration # TODO: Consider duration
start, end = time_seg.split("=")[0].split("--") start, end = time_seg.split("=")[0].split("--")
@ -1522,10 +1525,10 @@ def timestamp_to_string(ts: Timestamp, end_time: Optional[Timestamp] = None) ->
return "[{}]".format(base) return "[{}]".format(base)
Time = Union[None, TimeRange, OrgTime] Time = Union[TimeRange, OrgTime]
def parse_time(value: str) -> Time: def parse_time(value: str) -> Optional[Time]:
if (value.count(">--<") == 1) or (value.count("]--[") == 1): if (value.count(">--<") == 1) or (value.count("]--[") == 1):
# Time ranges with two different dates # Time ranges with two different dates
# @TODO properly consider "=> DURATION" section # @TODO properly consider "=> DURATION" section
@ -2151,7 +2154,9 @@ class OrgDoc:
for keyword in keywords: for keyword in keywords:
if keyword.key in ("TODO", "SEQ_TODO"): if keyword.key in ("TODO", "SEQ_TODO"):
todo_kws, done_kws = re.sub(r"\([^)]+\)", "", keyword.value).split("|", 1) todo_kws, done_kws = re.sub(r"\([^)]+\)", "", keyword.value).split(
"|", 1
)
self.todo_keywords = re.sub(r"\s{2,}", " ", todo_kws.strip()).split() self.todo_keywords = re.sub(r"\s{2,}", " ", todo_kws.strip()).split()
self.done_keywords = re.sub(r"\s{2,}", " ", done_kws.strip()).split() self.done_keywords = re.sub(r"\s{2,}", " ", done_kws.strip()).split()