"Fossies" - the Fresh Open Source Software Archive

Member "email-reminder-0.8.1/EmailReminder/Birthday.py" (19 Sep 2020, 1677 Bytes) of package /linux/privat/email-reminder-0.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "Birthday.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.8.0_vs_0.8.1.

    1 # This file is part of Email-Reminder.
    2 #
    3 # Copyright (C) 2020 by Francois Marier
    4 #
    5 # This program is free software: you can redistribute it and/or modify
    6 # it under the terms of the GNU Affero General Public License as published by
    7 # the Free Software Foundation, either version 3 of the License, or
    8 # (at your option) any later version.
    9 #
   10 # This program is distributed in the hope that it will be useful,
   11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 # GNU Affero General Public License for more details.
   14 #
   15 # You should have received a copy of the GNU Affero General Public License
   16 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
   17 
   18 from EmailReminder.Utils import readXMLValue, writeXMLValue, EMAIL_REGEX
   19 from EmailReminder.Yearly import YearlyModel
   20 
   21 
   22 class BirthdayModel(YearlyModel):
   23     LABEL = 'Birthdays'
   24     TYPE = 'birthday'
   25     COLUMN_NAMES = ["Name", "Birth Date", "Email"]
   26 
   27     def fillNewEvent(self, event):
   28         super().fillNewEvent(event)
   29         writeXMLValue(self.document, event, 'email', '')
   30 
   31     def getDataInternal(self, column, row):
   32         parentData = super().getDataInternal(column, row)
   33         if parentData:
   34             return parentData
   35         if column == 2:
   36             return readXMLValue(self.events[row], 'email')
   37 
   38         return None
   39 
   40     def setDataInternal(self, column, row, value):
   41         if column == 2:
   42             if not EMAIL_REGEX.fullmatch(value):
   43                 value = ''
   44             writeXMLValue(self.document, self.events[row], 'email', value)
   45         else:
   46             super().setDataInternal(column, row, value)