"Fossies" - the Fresh Open Source Software Archive

Member "email-reminder-0.8.1/EmailReminder/Anniversary.py" (19 Sep 2020, 2054 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 "Anniversary.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.Birthday import BirthdayModel
   20 
   21 
   22 class AnniversaryModel(BirthdayModel):
   23     LABEL = 'Anniversaries'
   24     TYPE = 'anniversary'
   25     COLUMN_NAMES = ["Person 1", "Date", "Email 1", "Person 2", "Email 2"]
   26 
   27     def fillNewEvent(self, event):
   28         super().fillNewEvent(event)
   29         writeXMLValue(self.document, event, 'partner_name', '')
   30         writeXMLValue(self.document, event, 'partner_email', '')
   31 
   32     def getDataInternal(self, column, row):
   33         parentData = super().getDataInternal(column, row)
   34         if parentData:
   35             return parentData
   36         if column == 3:
   37             return readXMLValue(self.events[row], 'partner_name')
   38         if column == 4:
   39             return readXMLValue(self.events[row], 'partner_email')
   40 
   41         return None
   42 
   43     def setDataInternal(self, column, row, value):
   44         if column == 3:
   45             writeXMLValue(self.document, self.events[row], 'partner_name',
   46                           value)
   47         elif column == 4:
   48             if not EMAIL_REGEX.fullmatch(value):
   49                 value = ''
   50             writeXMLValue(self.document, self.events[row], 'partner_email',
   51                           value)
   52         else:
   53             super().setDataInternal(column, row, value)