MCPcopy Index your code
hub / github.com/O365/python-o365 / __init__

Method __init__

O365/tasks_graph.py:30–98  ·  view source on GitHub ↗

Representation of a Microsoft To-Do task. :param parent: parent object :type parent: Folder :param Connection con: connection to use if no parent specified :param Protocol protocol: protocol to use if no parent specified (kwargs) :param str main_reso

(self, *, parent=None, con=None, **kwargs)

Source from the content-addressed store, hash-verified

28 }
29
30 def __init__(self, *, parent=None, con=None, **kwargs):
31 """Representation of a Microsoft To-Do task.
32
33 :param parent: parent object
34 :type parent: Folder
35 :param Connection con: connection to use if no parent specified
36 :param Protocol protocol: protocol to use if no parent specified
37 (kwargs)
38 :param str main_resource: use this resource instead of parent resource
39 (kwargs)
40 :param str folder_id: id of the calender to add this task in
41 (kwargs)
42 :param str subject: subject of the task (kwargs)
43 """
44 if parent and con:
45 raise ValueError("Need a parent or a connection but not both")
46 self.con = parent.con if parent else con
47
48 cloud_data = kwargs.get(self._cloud_data_key, {})
49
50 self.task_id = cloud_data.get("id")
51
52 # Choose the main_resource passed in kwargs over parent main_resource
53 main_resource = kwargs.pop("main_resource", None) or (
54 getattr(parent, "main_resource", None) if parent else None
55 )
56
57 super().__init__(
58 protocol=parent.protocol if parent else kwargs.get("protocol"),
59 main_resource=main_resource,
60 )
61
62 cc = self._cc # pylint: disable=invalid-name
63 # internal to know which properties need to be updated on the server
64 self._track_changes = TrackerSet(casing=cc)
65 self.folder_id = kwargs.get("folder_id")
66 cloud_data = kwargs.get(self._cloud_data_key, {})
67
68 self.task_id = cloud_data.get(cc("id"), None)
69 self.__subject = cloud_data.get(cc("title"), kwargs.get("subject", "") or "")
70 body = cloud_data.get(cc("body"), {})
71 self.__body = body.get(cc("content"), "")
72 self.body_type = body.get(
73 cc("contentType"), "html"
74 ) # default to HTML for new messages
75
76 self.__created = cloud_data.get(cc("createdDateTime"), None)
77 self.__modified = cloud_data.get(cc("lastModifiedDateTime"), None)
78 self.__status = cloud_data.get(cc("status"), None)
79 self.__is_completed = self.__status == "completed"
80 self.__importance = cloud_data.get(cc("importance"), None)
81
82 local_tz = self.protocol.timezone
83 self.__created = (
84 parse(self.__created).astimezone(local_tz) if self.__created else None
85 )
86 self.__modified = (
87 parse(self.__modified).astimezone(local_tz) if self.__modified else None

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 3

TrackerSetClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected