Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_mailbox.FakeMailBox Class Reference
Inheritance diagram for test.test_mailbox.FakeMailBox:
Inheritance graph
[legend]
Collaboration diagram for test.test_mailbox.FakeMailBox:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def get_file
def add
def remove
def __delitem__
def discard
def __setitem__
def get
def __getitem__
def get_message
def get_string
def get_bytes
def iterkeys
def keys
def itervalues
def __iter__
def values
def iteritems
def items
def __contains__
def __len__
def clear
def pop
def popitem
def update
def flush
def lock
def unlock
def close

Public Attributes

 files

Detailed Description

Definition at line 1220 of file test_mailbox.py.


Constructor & Destructor Documentation

Definition at line 1222 of file test_mailbox.py.

01222 
01223     def __init__(self):
01224         mailbox.Mailbox.__init__(self, '', lambda file: None)
01225         self.files = [FakeFileLikeObject() for i in range(10)]

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def mailbox.Mailbox.__contains__ (   self,
  key 
) [inherited]
Return True if the keyed message exists, False otherwise.

Reimplemented in mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 139 of file mailbox.py.

00139 
00140     def __contains__(self, key):
00141         """Return True if the keyed message exists, False otherwise."""
00142         raise NotImplementedError('Method must be implemented by subclass')

def mailbox.Mailbox.__delitem__ (   self,
  key 
) [inherited]

Definition at line 54 of file mailbox.py.

00054 
00055     def __delitem__(self, key):
00056         self.remove(key)

Here is the call graph for this function:

def mailbox.Mailbox.__getitem__ (   self,
  key 
) [inherited]
Return the keyed message; raise KeyError if it doesn't exist.

Definition at line 75 of file mailbox.py.

00075 
00076     def __getitem__(self, key):
00077         """Return the keyed message; raise KeyError if it doesn't exist."""
00078         if not self._factory:
00079             return self.get_message(key)
00080         else:
00081             with contextlib.closing(self.get_file(key)) as file:
00082                 return self._factory(file)

Here is the call graph for this function:

Here is the caller graph for this function:

def mailbox.Mailbox.__iter__ (   self) [inherited]

Definition at line 119 of file mailbox.py.

00119 
00120     def __iter__(self):
00121         return self.itervalues()

Here is the call graph for this function:

def mailbox.Mailbox.__len__ (   self) [inherited]
Return a count of messages in the mailbox.

Reimplemented in mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 143 of file mailbox.py.

00143 
00144     def __len__(self):
00145         """Return a count of messages in the mailbox."""
00146         raise NotImplementedError('Method must be implemented by subclass')

def mailbox.Mailbox.__setitem__ (   self,
  key,
  message 
) [inherited]
Replace the keyed message; raise KeyError if it doesn't exist.

Reimplemented in mailbox.Babyl, mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 64 of file mailbox.py.

00064 
00065     def __setitem__(self, key, message):
00066         """Replace the keyed message; raise KeyError if it doesn't exist."""
00067         raise NotImplementedError('Method must be implemented by subclass')

def mailbox.Mailbox.add (   self,
  message 
) [inherited]
Add message and return assigned key.

Reimplemented in mailbox.Babyl, mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 46 of file mailbox.py.

00046 
00047     def add(self, message):
00048         """Add message and return assigned key."""
00049         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def mailbox.Mailbox.clear (   self) [inherited]
Delete all messages.

Definition at line 147 of file mailbox.py.

00147 
00148     def clear(self):
00149         """Delete all messages."""
00150         for key in self.keys():
00151             self.discard(key)

Here is the call graph for this function:

def mailbox.Mailbox.close (   self) [inherited]
Flush and close the mailbox.

Reimplemented in mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 197 of file mailbox.py.

00197 
00198     def close(self):
00199         """Flush and close the mailbox."""
00200         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def mailbox.Mailbox.discard (   self,
  key 
) [inherited]
If the keyed message exists, remove it.

Reimplemented in mailbox.Maildir.

Definition at line 57 of file mailbox.py.

00057 
00058     def discard(self, key):
00059         """If the keyed message exists, remove it."""
00060         try:
00061             self.remove(key)
00062         except KeyError:
00063             pass

Here is the call graph for this function:

Here is the caller graph for this function:

def mailbox.Mailbox.flush (   self) [inherited]
Write any pending changes to the disk.

Reimplemented in mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 185 of file mailbox.py.

00185 
00186     def flush(self):
00187         """Write any pending changes to the disk."""
00188         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def mailbox.Mailbox.get (   self,
  key,
  default = None 
) [inherited]
Return the keyed message, or default if it doesn't exist.

Definition at line 68 of file mailbox.py.

00068 
00069     def get(self, key, default=None):
00070         """Return the keyed message, or default if it doesn't exist."""
00071         try:
00072             return self.__getitem__(key)
00073         except KeyError:
00074             return default

Here is the call graph for this function:

Here is the caller graph for this function:

def mailbox.Mailbox.get_bytes (   self,
  key 
) [inherited]
Return a byte string representation or raise a KeyError.

Reimplemented in mailbox.Babyl, mailbox.MH, and mailbox.Maildir.

Definition at line 94 of file mailbox.py.

00094 
00095     def get_bytes(self, key):
00096         """Return a byte string representation or raise a KeyError."""
00097         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def test.test_mailbox.FakeMailBox.get_file (   self,
  key 
)
Return a file-like representation or raise a KeyError.

Reimplemented from mailbox.Mailbox.

Definition at line 1226 of file test_mailbox.py.

01226 
01227     def get_file(self, key):
01228         return self.files[key]
01229 

def mailbox.Mailbox.get_message (   self,
  key 
) [inherited]
Return a Message representation or raise a KeyError.

Reimplemented in mailbox.Babyl, mailbox.MH, mailbox._mboxMMDF, and mailbox.Maildir.

Definition at line 83 of file mailbox.py.

00083 
00084     def get_message(self, key):
00085         """Return a Message representation or raise a KeyError."""
00086         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def mailbox.Mailbox.get_string (   self,
  key 
) [inherited]
Return a string representation or raise a KeyError.

Uses email.message.Message to create a 7bit clean string
representation of the message.

Definition at line 87 of file mailbox.py.

00087 
00088     def get_string(self, key):
00089         """Return a string representation or raise a KeyError.
00090 
00091         Uses email.message.Message to create a 7bit clean string
00092         representation of the message."""
00093         return email.message_from_bytes(self.get_bytes(key)).as_string()

Here is the call graph for this function:

def mailbox.Mailbox.items (   self) [inherited]
Return a list of (key, message) tuples. Memory intensive.

Definition at line 135 of file mailbox.py.

00135 
00136     def items(self):
00137         """Return a list of (key, message) tuples. Memory intensive."""
00138         return list(self.iteritems())

Here is the call graph for this function:

Here is the caller graph for this function:

def mailbox.Mailbox.iteritems (   self) [inherited]
Return an iterator over (key, message) tuples.

Definition at line 126 of file mailbox.py.

00126 
00127     def iteritems(self):
00128         """Return an iterator over (key, message) tuples."""
00129         for key in self.keys():
00130             try:
00131                 value = self[key]
00132             except KeyError:
00133                 continue
00134             yield (key, value)

Here is the call graph for this function:

Here is the caller graph for this function:

def mailbox.Mailbox.iterkeys (   self) [inherited]
Return an iterator over keys.

Reimplemented in mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 102 of file mailbox.py.

00102 
00103     def iterkeys(self):
00104         """Return an iterator over keys."""
00105         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def mailbox.Mailbox.itervalues (   self) [inherited]
Return an iterator over all messages.

Definition at line 110 of file mailbox.py.

00110 
00111     def itervalues(self):
00112         """Return an iterator over all messages."""
00113         for key in self.keys():
00114             try:
00115                 value = self[key]
00116             except KeyError:
00117                 continue
00118             yield value

Here is the call graph for this function:

Here is the caller graph for this function:

def mailbox.Mailbox.keys (   self) [inherited]
Return a list of keys.

Definition at line 106 of file mailbox.py.

00106 
00107     def keys(self):
00108         """Return a list of keys."""
00109         return list(self.iterkeys())

Here is the call graph for this function:

Here is the caller graph for this function:

def mailbox.Mailbox.lock (   self) [inherited]
Lock the mailbox.

Reimplemented in mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 189 of file mailbox.py.

00189 
00190     def lock(self):
00191         """Lock the mailbox."""
00192         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def mailbox.Mailbox.pop (   self,
  key,
  default = None 
) [inherited]
Delete the keyed message and return it, or default.

Definition at line 152 of file mailbox.py.

00152 
00153     def pop(self, key, default=None):
00154         """Delete the keyed message and return it, or default."""
00155         try:
00156             result = self[key]
00157         except KeyError:
00158             return default
00159         self.discard(key)
00160         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def mailbox.Mailbox.popitem (   self) [inherited]
Delete an arbitrary (key, message) pair and return it.

Definition at line 161 of file mailbox.py.

00161 
00162     def popitem(self):
00163         """Delete an arbitrary (key, message) pair and return it."""
00164         for key in self.keys():
00165             return (key, self.pop(key))     # This is only run once.
00166         else:
00167             raise KeyError('No messages in mailbox')

Here is the call graph for this function:

def mailbox.Mailbox.remove (   self,
  key 
) [inherited]
Remove the keyed message; raise KeyError if it doesn't exist.

Reimplemented in mailbox.Babyl, mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 50 of file mailbox.py.

00050 
00051     def remove(self, key):
00052         """Remove the keyed message; raise KeyError if it doesn't exist."""
00053         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def mailbox.Mailbox.unlock (   self) [inherited]
Unlock the mailbox if it is locked.

Reimplemented in mailbox.MH, mailbox._singlefileMailbox, and mailbox.Maildir.

Definition at line 193 of file mailbox.py.

00193 
00194     def unlock(self):
00195         """Unlock the mailbox if it is locked."""
00196         raise NotImplementedError('Method must be implemented by subclass')

Here is the caller graph for this function:

def mailbox.Mailbox.update (   self,
  arg = None 
) [inherited]
Change the messages that correspond to certain keys.

Definition at line 168 of file mailbox.py.

00168 
00169     def update(self, arg=None):
00170         """Change the messages that correspond to certain keys."""
00171         if hasattr(arg, 'iteritems'):
00172             source = arg.items()
00173         elif hasattr(arg, 'items'):
00174             source = arg.items()
00175         else:
00176             source = arg
00177         bad_key = False
00178         for key, message in source:
00179             try:
00180                 self[key] = message
00181             except KeyError:
00182                 bad_key = True
00183         if bad_key:
00184             raise KeyError('No message with key(s)')

Here is the caller graph for this function:

def mailbox.Mailbox.values (   self) [inherited]
Return a list of messages. Memory intensive.

Definition at line 122 of file mailbox.py.

00122 
00123     def values(self):
00124         """Return a list of messages. Memory intensive."""
00125         return list(self.itervalues())

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 1224 of file test_mailbox.py.


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