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

Method __init__

O365/message.py:233–343  ·  view source on GitHub ↗

Makes a new message wrapper for sending and receiving messages. :param parent: parent folder/account to create the message in :type parent: mailbox.Folder or Account :param Connection con: connection to use if no parent specified :param Protocol protocol: protocol t

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

Source from the content-addressed store, hash-verified

231 }
232
233 def __init__(self, *, parent=None, con=None, **kwargs):
234 """ Makes a new message wrapper for sending and receiving messages.
235
236 :param parent: parent folder/account to create the message in
237 :type parent: mailbox.Folder or Account
238 :param Connection con: connection to use if no parent specified
239 :param Protocol protocol: protocol to use if no parent specified
240 (kwargs)
241 :param str main_resource: use this resource instead of parent resource
242 (kwargs)
243 :param bool download_attachments: whether or not to
244 download attachments (kwargs)
245 """
246 if parent and con:
247 raise ValueError('Need a parent or a connection but not both')
248 self.con = parent.con if parent else con
249
250 # Choose the main_resource passed in kwargs over parent main_resource
251 main_resource = kwargs.pop('main_resource', None) or (
252 getattr(parent, 'main_resource', None) if parent else None)
253
254 super().__init__(
255 protocol=parent.protocol if parent else kwargs.get('protocol'),
256 main_resource=main_resource,
257 attachment_name_property='subject', attachment_type='message_type')
258
259 download_attachments = kwargs.get('download_attachments')
260
261 cloud_data = kwargs.get(self._cloud_data_key, {})
262 cc = self._cc # alias to shorten the code
263
264 # internal to know which properties need to be updated on the server
265 self._track_changes = TrackerSet(casing=cc)
266 self.object_id = cloud_data.get(cc('id'), kwargs.get('object_id', None))
267
268 self.__inference_classification = cloud_data.get(cc('inferenceClassification'), None)
269
270 self.__created = cloud_data.get(cc('createdDateTime'), None)
271 self.__modified = cloud_data.get(cc('lastModifiedDateTime'), None)
272 self.__received = cloud_data.get(cc('receivedDateTime'), None)
273 self.__sent = cloud_data.get(cc('sentDateTime'), None)
274
275 local_tz = self.protocol.timezone
276 self.__created = parse(self.__created).astimezone(
277 local_tz) if self.__created else None
278 self.__modified = parse(self.__modified).astimezone(
279 local_tz) if self.__modified else None
280 self.__received = parse(self.__received).astimezone(
281 local_tz) if self.__received else None
282 self.__sent = parse(self.__sent).astimezone(
283 local_tz) if self.__sent else None
284
285 self.__attachments = MessageAttachments(parent=self, attachments=[])
286 self.__attachments.add({self._cloud_data_key: cloud_data.get(cc('attachments'), [])})
287 self.__has_attachments = cloud_data.get(cc('hasAttachments'), False)
288 self.__subject = cloud_data.get(cc('subject'), '')
289 self.__body_preview = cloud_data.get(cc('bodyPreview'), '')
290 body = cloud_data.get(cc('body'), {})

Callers 1

__init__Method · 0.45

Calls 9

TrackerSetClass · 0.85
MessageAttachmentsClass · 0.85
MessageFlagClass · 0.85
download_attachmentsMethod · 0.80
_recipient_from_cloudMethod · 0.80
from_valueMethod · 0.80
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected