[Python-checkins] python/dist/src/Lib/email Message.py,1.26,1.27

barry@users.sourceforge.net barry@users.sourceforge.net
Mon, 30 Sep 2002 11:17:38 -0700


Update of /cvsroot/python/python/dist/src/Lib/email
In directory usw-pr-cvs1:/tmp/cvs-serv22645

Modified Files:
	Message.py 
Log Message:
__contains__(): Change the second argument to `name' for consistency.
I seriously doubt this will break any deployed code.

Docstring consistency with the updated .tex files.


Index: Message.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/email/Message.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Message.py	28 Sep 2002 20:41:39 -0000	1.26
--- Message.py	30 Sep 2002 18:17:35 -0000	1.27
***************
*** 67,77 ****
  
  class Message:
!     """Basic message object for use inside the object tree.
  
      A message object is defined as something that has a bunch of RFC 2822
!     headers and a payload.  If the body of the message is a multipart, then
!     the payload is a list of Messages, otherwise it is a string.
  
!     These objects implement part of the `mapping' interface, which assumes
      there is exactly one occurrance of the header per message.  Some headers
      do in fact appear multiple times (e.g. Received) and for those headers,
--- 67,79 ----
  
  class Message:
!     """Basic message object.
  
      A message object is defined as something that has a bunch of RFC 2822
!     headers and a payload.  It may optionally have an envelope header
!     (a.k.a. Unix-From or From_ header).  If the message is a container (i.e. a
!     multipart or a message/rfc822), then the payload is a list of Message
!     objects, otherwise it is a string.
  
!     Message objects implement part of the `mapping' interface, which assumes
      there is exactly one occurrance of the header per message.  Some headers
      do in fact appear multiple times (e.g. Received) and for those headers,
***************
*** 91,95 ****
      def __str__(self):
          """Return the entire formatted message as a string.
!         This includes the headers, body, and `unixfrom' line.
          """
          return self.as_string(unixfrom=True)
--- 93,97 ----
      def __str__(self):
          """Return the entire formatted message as a string.
!         This includes the headers, body, and envelope header.
          """
          return self.as_string(unixfrom=True)
***************
*** 129,132 ****
--- 131,136 ----
          If the current payload is empty, then the current payload will be made
          a scalar, set to the given value.
+ 
+         Note: This method is deprecated.  Use .attach() instead.
          """
          warnings.warn('add_payload() is deprecated, use attach() instead.',
***************
*** 146,151 ****
  
          The current payload will always be a list of objects after this method
!         is called.  If you want to set the payload to a scalar object
!         (e.g. because you're attaching a message/rfc822 subpart), use
          set_payload() instead.
          """
--- 150,154 ----
  
          The current payload will always be a list of objects after this method
!         is called.  If you want to set the payload to a scalar object, use
          set_payload() instead.
          """
***************
*** 158,172 ****
          """Return a reference to the payload.
  
!         The payload is typically either a list object or a string.  If you
!         mutate the list object, you modify the message's payload in place.
!         Optional i returns that index into the payload.
  
!         Optional decode is a flag indicating whether the payload should be
!         decoded or not, according to the Content-Transfer-Encoding header.
!         When True and the message is not a multipart, the payload will be
!         decoded if this header's value is `quoted-printable' or `base64'.  If
!         some other encoding is used, or the header is missing, the payload is
!         returned as-is (undecoded).  If the message is a multipart and the
!         decode flag is True, then None is returned.
          """
          if i is None:
--- 161,176 ----
          """Return a reference to the payload.
  
!         The payload will either be a list object or a string.  If you mutate
!         the list object, you modify the message's payload in place.  Optional
!         i returns that index into the payload.
  
!         Optional decode is a flag (defaulting to False) indicating whether the
!         payload should be decoded or not, according to the
!         Content-Transfer-Encoding header.  When True and the message is not a
!         multipart, the payload will be decoded if this header's value is
!         `quoted-printable' or `base64'.  If some other encoding is used, or
!         the header is missing, the payload is returned as-is (undecoded).  If
!         the message is a multipart and the decode flag is True, then None is
!         returned.
          """
          if i is None:
***************
*** 191,195 ****
          """Set the payload to the given value.
  
!         Optionally set the charset, which must be a Charset instance."""
          self._payload = payload
          if charset is not None:
--- 195,201 ----
          """Set the payload to the given value.
  
!         Optional charset sets the message's default character set.  See
!         set_charset() for details.
!         """
          self._payload = payload
          if charset is not None:
***************
*** 199,213 ****
          """Set the charset of the payload to a given character set.
  
!         charset can be a string or a Charset object.  If it is a string, it
!         will be converted to a Charset object by calling Charset's
!         constructor.  If charset is None, the charset parameter will be
!         removed from the Content-Type field.  Anything else will generate a
!         TypeError.
  
!         The message will be assumed to be a text message encoded with
          charset.input_charset.  It will be converted to charset.output_charset
          and encoded properly, if needed, when generating the plain text
          representation of the message.  MIME headers (MIME-Version,
          Content-Type, Content-Transfer-Encoding) will be added as needed.
          """
          if charset is None:
--- 205,219 ----
          """Set the charset of the payload to a given character set.
  
!         charset can be a Charset instance, a string naming a character set, or
!         None.  If it is a string it will be converted to a Charset instance.
!         If charset is None, the charset parameter will be removed from the
!         Content-Type field.  Anything else will generate a TypeError.
  
!         The message will be assumed to be of type text/* encoded with
          charset.input_charset.  It will be converted to charset.output_charset
          and encoded properly, if needed, when generating the plain text
          representation of the message.  MIME headers (MIME-Version,
          Content-Type, Content-Transfer-Encoding) will be added as needed.
+ 
          """
          if charset is None:
***************
*** 237,241 ****
  
      def get_charset(self):
!         """Return the Charset object associated with the message's payload."""
          return self._charset
  
--- 243,248 ----
  
      def get_charset(self):
!         """Return the Charset instance associated with the message's payload.
!         """
          return self._charset
  
***************
*** 278,283 ****
          self._headers = newheaders
  
!     def __contains__(self, key):
!         return key.lower() in [k.lower() for k, v in self._headers]
  
      def has_key(self, name):
--- 285,290 ----
          self._headers = newheaders
  
!     def __contains__(self, name):
!         return name.lower() in [k.lower() for k, v in self._headers]
  
      def has_key(self, name):
***************
*** 290,295 ****
  
          These will be sorted in the order they appeared in the original
!         message, and may contain duplicates.  Any fields deleted and
!         re-inserted are always appended to the header list.
          """
          return [k for k, v in self._headers]
--- 297,303 ----
  
          These will be sorted in the order they appeared in the original
!         message, or were added to the message, and may contain duplicates.
!         Any fields deleted and re-inserted are always appended to the header
!         list.
          """
          return [k for k, v in self._headers]
***************
*** 299,304 ****
  
          These will be sorted in the order they appeared in the original
!         message, and may contain duplicates.  Any fields deleted and
!         re-inserted are always appended to the header list.
          """
          return [v for k, v in self._headers]
--- 307,313 ----
  
          These will be sorted in the order they appeared in the original
!         message, or were added to the message, and may contain duplicates.
!         Any fields deleted and re-inserted are always appended to the header
!         list.
          """
          return [v for k, v in self._headers]
***************
*** 308,313 ****
  
          These will be sorted in the order they appeared in the original
!         message, and may contain duplicates.  Any fields deleted and
!         re-inserted are always appended to the header list.
          """
          return self._headers[:]
--- 317,323 ----
  
          These will be sorted in the order they appeared in the original
!         message, or were added to the message, and may contain duplicates.
!         Any fields deleted and re-inserted are always appended to the header
!         list.
          """
          return self._headers[:]
***************
*** 427,441 ****
  
      def get_content_type(self):
!         """Returns the message's content type.
  
!         The returned string is coerced to lowercase and returned as a ingle
!         string of the form `maintype/subtype'.  If there was no Content-Type
!         header in the message, the default type as give by get_default_type()
!         will be returned.  Since messages always have a default type this will
!         always return a value.
  
!         The current state of RFC standards define a message's default type to
!         be text/plain unless it appears inside a multipart/digest container,
!         in which case it would be message/rfc822.
          """
          missing = []
--- 437,451 ----
  
      def get_content_type(self):
!         """Return the message's content type.
  
!         The returned string is coerced to lower case of the form
!         `maintype/subtype'.  If there was no Content-Type header in the
!         message, the default type as given by get_default_type() will be
!         returned.  Since according to RFC 2045, messages always have a default
!         type this will always return a value.
  
!         RFC 2045 defines a message's default type to be text/plain unless it
!         appears inside a multipart/digest container, in which case it would be
!         message/rfc822.
          """
          missing = []
***************
*** 451,459 ****
  
      def get_content_maintype(self):
!         """Returns the message's main content type.
  
          This is the `maintype' part of the string returned by
!         get_content_type().  If no slash is found in the full content type, a
!         ValueError is raised.
          """
          ctype = self.get_content_type()
--- 461,468 ----
  
      def get_content_maintype(self):
!         """Return the message's main content type.
  
          This is the `maintype' part of the string returned by
!         get_content_type().
          """
          ctype = self.get_content_type()
***************
*** 461,469 ****
  
      def get_content_subtype(self):
!         """Returns the message's sub content type.
  
          This is the `subtype' part of the string returned by
!         get_content_type().  If no slash is found in the full content type, a
!         ValueError is raised.
          """
          ctype = self.get_content_type()
--- 470,477 ----
  
      def get_content_subtype(self):
!         """Returns the message's sub-content type.
  
          This is the `subtype' part of the string returned by
!         get_content_type().
          """
          ctype = self.get_content_type()
***************
*** 475,479 ****
          Most messages have a default content type of text/plain, except for
          messages that are subparts of multipart/digest containers.  Such
!         subparts then have a default content type of message/rfc822.
          """
          return self._default_type
--- 483,487 ----
          Most messages have a default content type of text/plain, except for
          messages that are subparts of multipart/digest containers.  Such
!         subparts have a default content type of message/rfc822.
          """
          return self._default_type
***************
*** 571,583 ****
          replaced with the new value.
  
!         If header is Content-Type and has not yet been defined in this
          message, it will be set to "text/plain" and the new parameter and
!         value will be appended, as per RFC 2045.
  
          An alternate header can specified in the header argument, and all
!         parameters will be quoted as appropriate unless requote is False.
  
!         If charset is specified the parameter will be encoded according to RFC
!         2231.  In this case language is optional.
          """
          if not isinstance(value, TupleType) and charset:
--- 579,592 ----
          replaced with the new value.
  
!         If header is Content-Type and has not yet been defined for this
          message, it will be set to "text/plain" and the new parameter and
!         value will be appended as per RFC 2045.
  
          An alternate header can specified in the header argument, and all
!         parameters will be quoted as necessary unless requote is False.
  
!         If charset is specified, the parameter will be encoded according to RFC
!         2231.  Optional language specifies the RFC 2231 language, defaulting
!         to the empty string.  Both charset and language should be strings.
          """
          if not isinstance(value, TupleType) and charset:
***************
*** 614,619 ****
          """Remove the given parameter completely from the Content-Type header.
  
!         The header will be re-written in place without param or its value.
!         All values will be quoted as appropriate unless requote is False.
          """
          if not self.has_key(header):
--- 623,630 ----
          """Remove the given parameter completely from the Content-Type header.
  
!         The header will be re-written in place without the parameter or its
!         value. All values will be quoted as necessary unless requote is
!         False.  Optional header specifies an alternative to the Content-Type
!         header.
          """
          if not self.has_key(header):
***************
*** 642,647 ****
          default).
  
!         An alternate header can be specified in the header argument.  When the
!         Content-Type header is set, we'll always also add a MIME-Version
          header.
          """
--- 653,658 ----
          default).
  
!         An alternative header can be specified in the header argument.  When
!         the Content-Type header is set, we'll always also add a MIME-Version
          header.
          """