Skip to content

Commit

Permalink
fix #280
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvladus committed May 16, 2024
1 parent 24a8eb5 commit 70e474c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 4 additions & 6 deletions errands/lib/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ def to_ical(self, as_calendar: bool = False) -> str:
@staticmethod
def from_ical(ical: str | bytes, list_uid: str) -> TaskData:
"""Build TaskData from iCal string"""

ical: str = str(ical)
task: TaskData = TaskData(list_uid=list_uid)

assert ical != ""
Expand All @@ -186,8 +184,8 @@ def from_ical(ical: str | bytes, list_uid: str) -> TaskData:
task.parent = value
elif "STATUS" in prop:
task.completed = True if value == "COMPLETED" else False
elif "SUMMARY" in prop:
task.text = value.replace("\\,", ",").replace("\\\\", "\\")
# elif "SUMMARY" in prop:
# task.text = value.replace("\\,", ",").replace("\\\\", "\\")
elif "UID" in prop:
task.uid = value
elif "DUE" in prop:
Expand All @@ -198,8 +196,8 @@ def from_ical(ical: str | bytes, list_uid: str) -> TaskData:
task.start_date = value.strip("Z")
if task.start_date and "T" not in task.start_date:
task.start_date += "T000000"
elif "DESCRIPTION" in prop:
task.notes = value.replace("\\,", ",").replace("\\\\", "\\")
# elif "DESCRIPTION" in prop:
# task.notes = value.replace("\\,", ",").replace("\\\\", "\\")
elif "CATEGORIES" in prop:
task.tags = value.split(",") if value else []
elif "X-ERRANDS-COLOR" in prop:
Expand Down
10 changes: 8 additions & 2 deletions errands/lib/sync/providers/caldav.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,14 @@ def __get_tasks(self, calendar: Calendar) -> list[TaskData]:
try:
Log.debug(f"Sync: Getting tasks for list '{calendar.id}'")
todos: list[Todo] = calendar.todos(include_completed=True)
return [TaskData.from_ical(todo.data, calendar.id) for todo in todos]
except Exception as e:
tasks: list[TaskData] = []
for todo in todos:
task: TaskData = TaskData.from_ical(todo.data, calendar.id)
task.text = str(todo.icalendar_component.get("summary", ""))
task.notes = str(todo.icalendar_component.get("description", ""))
tasks.append(task)
return tasks
except BaseException as e:
Log.error(f"Sync: Can't get tasks from remote. {e}")
return []

Expand Down

0 comments on commit 70e474c

Please sign in to comment.