Package emma :: Package interface :: Module message
[hide private]
[frames] | no frames]

Source Code for Module emma.interface.message

 1  """ 
 2  generic message for interfaces 
 3   
 4  @copyright: (c) 2011 hackmeeting U{http://sindominio.net/hackmeeting} 
 5  @author: Ruben Pollan 
 6  @organization: hackmeeting U{http://sindominio.net/hackmeeting} 
 7  @contact: meskio@sindominio.net 
 8  @license: 
 9    This program is free software; you can redistribute it and/or 
10    modify it under the terms of the Do What The Fuck You Want To 
11    Public License, Version 2, as published by Sam Hocevar. See 
12    U{http://sam.zoy.org/projects/COPYING.WTFPL} for more details. 
13  """ 
14   
15  from datetime import datetime 
16   
17   
18 -class Message(dict):
19 """ 20 Message is basically a dictionary 21 """
22 - def __init__(self, body=None, to=None, frm=None, tpe=None, 23 date=datetime.utcnow()):
24 """ 25 @type body: string 26 @param body: content 27 @type to: string 28 @param to: target 29 @type frm: string 30 @param frm: source 31 @type tpe: string 32 @param tpe: message type 33 @type date: datetime 34 @param date: message date 35 """ 36 super(Message, self).__init__(From=frm, To=to, Body=body, Type=tpe, 37 Date=date)
38
39 - def __getitem__(self, item):
40 if item not in self: 41 return "" 42 else: 43 return super(Message, self).__getitem__(item)
44