Module weekly :: Class SendWeekly
[show private | hide private]
[frames | no frames]

Class SendWeekly


Read all entries of a week from a diary file and send the entries as a mail to a receiver.

Format of an entry:
   Every entry starts with the date on a single line. This line has a
   leading "-- " and a european styled date "DD.MM.YYYY".
   
   The text of the entry in the next lines can be free formated.
Example diary entries:
 -- 30.12.2004
 Programming
 - today I finished a small script to make the ldap query 
   
 -- 31.12.2004
 on Call
 - fix a small cpu load issue

Method Summary
  __init__(self, bcopy, copy, file, sender, receiver, subject, server, dayinweek, startingweek)
Initialize the class and set the important values
  createSMTPMessage(self)
create a full formated SMTP message with the header lines "From:", "To:", "Subject:" and optionally "cc:" and "bcc:"
  createSubject(self, subject)
Replace the wildcards in the subject string with current values
  createweekly(self)
create the weekly message from the diary entries stored in the dictionary
  linedate2iso(self, dateline)
convert a line starting with "-- DD.MM.YYYY" to the ISO-Format YYYYMMDD
  processAll(self)
Process all steps to send a email with the diary entries
  readdiary(self, filename)
read the diary file into the internal structures
  searchdays(self, date)
search the first and the last day of the week with the "date" inside
  searchfirstday(self, date)
search the first entry of this week
  searchlastday(self, date)
search the last entry of this week
  sendSMTPMessage(self, server)
send the preformated smtp message

Instance Variable Summary
str dayinweek: One day in the week to process
str diaryfile: file with the diary entries
str mailbcopy: BCC address of the mail sended by this script
str mailcopy: CC address of the mail sended by this script
str mailreceiver: Receiver address of the mail sended by this script
str mailsender: Sender address of the mail sended by this script
str mailserver: SMTP server to send this mail
str mailsubject: Subject of the weekly mail
str startingweek: First weekday of a week; valid values are sunday or monday

Method Details

__init__(self, bcopy='', copy='', file='', sender='', receiver='', subject='', server='', dayinweek='', startingweek='')
(Constructor)

Initialize the class and set the important values
Parameters:
bcopy - bcc address of the email
copy - cc address of the email
file - diary file
sender - sender address of the email
receiver - receiver address of the email
subject - subject of the email
server - delivery smtp server
dayinweek - date of the to processed week
startingweek - first day of week (sunday or monday are only valid)

createSMTPMessage(self)

create a full formated SMTP message with the header lines "From:", "To:", "Subject:" and optionally "cc:" and "bcc:"

createSubject(self, subject='')

Replace the wildcards in the subject string with current values

%B replaced by the date of the first entry

%E replaced by the date of the last entry
Parameters:
subject - Subject with wildcards
Returns:
Subject with current values instead of wildcards

Note: The format of the dates is always YYYYMMDD.

createweekly(self)

create the weekly message from the diary entries stored in the dictionary

See Also: self.__dates and self.__message

linedate2iso(self, dateline)

convert a line starting with "-- DD.MM.YYYY" to the ISO-Format YYYYMMDD
Returns:
date in iso format YYYYMMDD

processAll(self)

Process all steps to send a email with the diary entries

readdiary(self, filename='')

read the diary file into the internal structures
Parameters:
filename - filename of the diary file

searchdays(self, date='')

search the first and the last day of the week with the "date" inside
Parameters:
date - date of one day in the searched week in iso format

searchfirstday(self, date)

search the first entry of this week
Parameters:
date - date of one day in the current week in YYYYMMDD
Returns:
date of the first entry of a week in iso format or None if it failed

searchlastday(self, date)

search the last entry of this week
Parameters:
date - date of one day in the current week in YYYYMMDD
Returns:
date of the last entry of a week in iso format

sendSMTPMessage(self, server='')

send the preformated smtp message
Parameters:
server - smtp server

See Also: createSMTPMessage


Instance Variable Details

dayinweek

One day in the week to process
Type:
str
Value:
''                                                                     

diaryfile

file with the diary entries
Type:
str
Value:
'./today.log'                                                          

mailbcopy

BCC address of the mail sended by this script
Type:
str
Value:
''                                                                     

mailcopy

CC address of the mail sended by this script
Type:
str
Value:
''                                                                     

mailreceiver

Receiver address of the mail sended by this script
Type:
str
Value:
''                                                                     

mailsender

Sender address of the mail sended by this script
Type:
str
Value:
''                                                                     

mailserver

SMTP server to send this mail
Type:
str
Value:
'localhost'                                                            

mailsubject

Subject of the weekly mail
Type:
str
Value:
'weekly %B - %E'                                                       

startingweek

First weekday of a week; valid values are sunday or monday
Type:
str
Value:
'monday'                                                               

Generated by Epydoc 2.1 on Wed Oct 11 22:31:42 2006 http://epydoc.sf.net