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

Method __init__

O365/tasks.py:24–84  ·  view source on GitHub ↗

A Microsoft To-Do task :param parent: parent object :type parent: ToDo :param Connection con: connection to use if no parent specified :param Protocol protocol: protocol to use if no parent specified (kwargs) :param str main_resource: use this resou

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

Source from the content-addressed store, hash-verified

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

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 3

TrackerSetClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected