Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Message Class Reference
Inheritance diagram for Message:
Message Message SubMessage

Public Member Functions

def __init__
 
def __repr__
 
def getheadertext
 
def getbodytext
 
def getbodyparts
 
def getbody
 
- Public Member Functions inherited from Message
def __init__
 
def parsetype
 
def parseplist
 
def getplist
 
def getparam
 
def getparamnames
 
def getencoding
 
def gettype
 
def getmaintype
 
def getsubtype
 
- Public Member Functions inherited from Message
def __init__
 
def rewindbody
 
def readheaders
 
def isheader
 
def islast
 
def iscomment
 
def getallmatchingheaders
 
def getfirstmatchingheader
 
def getrawheader
 
def getheader
 
def getheaders
 
def getaddr
 
def getaddrlist
 
def getdate
 
def getdate_tz
 
def __len__
 
def __getitem__
 
def __setitem__
 
def __delitem__
 
def get
 
def setdefault
 
def has_key
 
def keys
 
def values
 
def items
 
def __str__
 

Data Fields

 folder
 
 number
 
- Data Fields inherited from Message
 encodingheader
 
 typeheader
 
 plisttext
 
 type
 
 maintype
 
 subtype
 
 plist
 
- Data Fields inherited from Message
 fp
 
 seekable
 
 startofheaders
 
 startofbody
 
 dict
 
 unixfrom
 
 headers
 
 status
 

Additional Inherited Members

- Static Public Attributes inherited from Message
 get = getheader
 

Detailed Description

Definition at line 662 of file mhlib.py.

Constructor & Destructor Documentation

def __init__ (   self,
  f,
  n,
  fp = None 
)
Constructor.

Definition at line 664 of file mhlib.py.

665  def __init__(self, f, n, fp = None):
666  """Constructor."""
667  self.folder = f
668  self.number = n
669  if not fp:
670  path = f.getmessagefilename(n)
671  fp = open(path, 'r')

Member Function Documentation

def __repr__ (   self)
String representation.

Definition at line 673 of file mhlib.py.

References Message.folder, Breakpoint.number, and Message.number.

674  def __repr__(self):
675  """String representation."""
676  return 'Message(%s, %s)' % (repr(self.folder), self.number)
def getbody (   self)
Return body, either a string or a list of messages.

Definition at line 728 of file mhlib.py.

References Message.getbodyparts(), Message.getbodytext(), and Message.getmaintype().

729  def getbody(self):
730  """Return body, either a string or a list of messages."""
731  if self.getmaintype() == 'multipart':
732  return self.getbodyparts()
733  else:
734  return self.getbodytext()
735 
def getbodyparts (   self)
Only for multipart messages: return the message's body as a
list of SubMessage objects.  Each submessage object behaves
(almost) as a Message object.

Definition at line 708 of file mhlib.py.

References Message.folder, _Mailbox.fp, _Subfile.fp, MultiFile.fp, Message.fp, HTTPResponse.fp, FieldStorage.fp, Message.getmaintype(), Message.getparam(), Breakpoint.number, Message.number, Message.startofbody, and locale.str().

709  def getbodyparts(self):
710  """Only for multipart messages: return the message's body as a
711  list of SubMessage objects. Each submessage object behaves
712  (almost) as a Message object."""
713  if self.getmaintype() != 'multipart':
714  raise Error, 'Content-Type is not multipart/*'
715  bdry = self.getparam('boundary')
716  if not bdry:
717  raise Error, 'multipart/* without boundary param'
718  self.fp.seek(self.startofbody)
719  mf = multifile.MultiFile(self.fp)
720  mf.push(bdry)
721  parts = []
722  while mf.next():
723  n = str(self.number) + '.' + `1 + len(parts)`
724  part = SubMessage(self.folder, n, mf)
725  parts.append(part)
726  mf.pop()
727  return parts
def getbodytext (   self,
  decode = 1 
)
Return the message's body text as string.  This undoes a
Content-Transfer-Encoding, but does not interpret other MIME
features (e.g. multipart messages).  To suppress decoding,
pass 0 as an argument.

Definition at line 694 of file mhlib.py.

References mimetools.decode(), _Mailbox.fp, _Subfile.fp, MultiFile.fp, Message.fp, HTTPResponse.fp, FieldStorage.fp, Message.getencoding(), and Message.startofbody.

695  def getbodytext(self, decode = 1):
696  """Return the message's body text as string. This undoes a
697  Content-Transfer-Encoding, but does not interpret other MIME
698  features (e.g. multipart messages). To suppress decoding,
699  pass 0 as an argument."""
700  self.fp.seek(self.startofbody)
701  encoding = self.getencoding()
702  if not decode or encoding in ('', '7bit', '8bit', 'binary'):
703  return self.fp.read()
704  from StringIO import StringIO
705  output = StringIO()
706  mimetools.decode(self.fp, output, encoding)
707  return output.getvalue()
def getheadertext (   self,
  pred = None 
)
Return the message's header text as a string.  If an
argument is specified, it is used as a filter predicate to
decide which headers to return (its argument is the header
name converted to lower case).

Definition at line 677 of file mhlib.py.

References Message.headers, BaseHTTPRequestHandler.headers, MiniFieldStorage.headers, FieldStorage.headers, HTTP.headers, dospath.join(), and string.lower().

678  def getheadertext(self, pred = None):
679  """Return the message's header text as a string. If an
680  argument is specified, it is used as a filter predicate to
681  decide which headers to return (its argument is the header
682  name converted to lower case)."""
683  if not pred:
684  return ''.join(self.headers)
685  headers = []
686  hit = 0
687  for line in self.headers:
688  if not line[0].isspace():
689  i = line.find(':')
690  if i > 0:
691  hit = pred(line[:i].lower())
692  if hit: headers.append(line)
693  return ''.join(headers)

Field Documentation

folder

Definition at line 666 of file mhlib.py.

number

Definition at line 667 of file mhlib.py.


The documentation for this class was generated from the following file: