MCPcopy Create free account
hub / github.com/canonical/cloud-init / _multi_part_count

Method _multi_part_count

cloudinit/user_data.py:326–342  ·  view source on GitHub ↗

Return the number of attachments to this MIMEMultipart by looking at its 'Number-Attachments' header.

(self, outer_msg, new_count=None)

Source from the content-addressed store, hash-verified

324 self._attach_part(append_msg, msg)
325
326 def _multi_part_count(self, outer_msg, new_count=None):
327 """
328 Return the number of attachments to this MIMEMultipart by looking
329 at its 'Number-Attachments' header.
330 """
331 if ATTACHMENT_FIELD not in outer_msg:
332 outer_msg[ATTACHMENT_FIELD] = "0"
333
334 if new_count is not None:
335 _replace_header(outer_msg, ATTACHMENT_FIELD, str(new_count))
336
337 fetched_count = 0
338 try:
339 fetched_count = int(outer_msg.get(ATTACHMENT_FIELD))
340 except (ValueError, TypeError):
341 _replace_header(outer_msg, ATTACHMENT_FIELD, str(fetched_count))
342 return fetched_count
343
344 def _attach_part(self, outer_msg, part):
345 """

Callers 1

_attach_partMethod · 0.95

Calls 2

_replace_headerFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected