iro/anbieter/content.py
changeset 62 35228d665310
parent 58 fb161058bcab
equal deleted inserted replaced
61:04dfd43dfecc 62:35228d665310
    22         pass
    22         pass
    23 
    23 
    24     def getContent(self):
    24     def getContent(self):
    25         return self.content
    25         return self.content
    26 
    26 
       
    27     def __eq__(self,other):
       
    28         return self.content == other.content
       
    29 
       
    30     def __ne__(self,other):
       
    31         return not self.__eq__(other)
       
    32 
    27 class SMS(content):
    33 class SMS(content):
    28     def __init__(self, cont):
    34     def __init__(self, cont):
    29         content.__init__(self,cont)
    35         content.__init__(self,cont)
    30 
    36 
    31     def sendto(self,anbieter,recipients):
    37     def sendto(self,anbieter,recipients):
    32         anbieter.sendSMS(self,recipients)
    38         anbieter.sendSMS(self,recipients)
       
    39 
    33 
    40 
    34 class FAX(content):
    41 class FAX(content):
    35     def __init__(self,header,cont,attachments):
    42     def __init__(self,header,cont,attachments):
    36         content.__init__(self,cont)
    43         content.__init__(self,cont)
    37         self.header=header
    44         self.header=header
    39 
    46 
    40     def sendto(self,anbieter,recipients):
    47     def sendto(self,anbieter,recipients):
    41         anbieter.sendFAX(self,recipients)
    48         anbieter.sendFAX(self,recipients)
    42 
    49 
    43     def getAttachment(self,i):
    50     def getAttachment(self,i):
    44         print self.attachments
       
    45         return self.attachments[i]
    51         return self.attachments[i]
       
    52 
       
    53     def __eq__(self,other):
       
    54         if not  content.__eq__(self,other):
       
    55             return False
       
    56 
       
    57         if self.header != other.header:
       
    58             return False
       
    59 
       
    60         if len(self.attachments) != len(other.attachments):
       
    61             return False
       
    62 
       
    63         for i in range(len(self.attachments)):
       
    64             if self.attachments[i] != other.attachments[i]:
       
    65                 return False
       
    66 
       
    67         return True
       
    68 
       
    69 
    46 
    70 
    47 class Mail(content):
    71 class Mail(content):
    48     def __init__(self, subject, body, frm):
    72     def __init__(self, subject, body, frm):
    49         con=MIMEText(body.encode("utf-8"), _charset='utf-8')
    73         con=MIMEText(body.encode("utf-8"), _charset='utf-8')
    50         sub=Header(subject.encode('utf-8'), 'utf-8')
    74         sub=Header(subject.encode('utf-8'), 'utf-8')
    58     def as_string(self):
    82     def as_string(self):
    59         return self.content.as_string()
    83         return self.content.as_string()
    60 
    84 
    61     def getFrom(self):
    85     def getFrom(self):
    62         return self.frm
    86         return self.frm
       
    87     
       
    88     def __eq__(self,other):
       
    89         if self.as_string() != other.as_string():
       
    90             return False
       
    91 
       
    92         if self.frm != other.frm:
       
    93             return False
       
    94 
       
    95         return True