def _readConfig(self): ''' ''' defaultConfig = { 'locataire': 'Locataire', 'start': '11/8/2018', 'end': '25/8/2018', 'automatic': True, 'price': 1600, 'cleaning': 70, 'avelmor': True, 'tyagathe': False, 'tytania': False, 'typapy': False, 'cleaninginc': False, } config = copy(defaultConfig) try: filename = 'contrats.ini' if not isfile(filename): return defaultConfig # end if with open(filename, 'r') as f: lines = f.readlines() # end with for line in lines: pos = line.find('=') if pos == -1: continue # end if key = line[:pos].strip() value = line[pos + 1:].strip() if key not in defaultConfig.keys(): return defaultConfig else: if value.lower() == 'true': value = True elif value.lower() == 'false': value = False # end if if key in ['start', 'end']: DateTools.strToDate(value) # end if config[key] = value # end if # end for except: return defaultConfig # end try return config
def _getSeason(self, start, end): ''' ''' for s in Seasons: if (DateTools.strToDate(start) >= DateTools.strToDate(s.start)) \ and (DateTools.strToDate(end) <= DateTools.strToDate(s.end)): return s.seasonType # end if # end for raise ValueError('Saison non définie pour la période du %s au %s' % (start, end))
def _getend(self): return DateTools.strToDate(self._getText('end'))
def _getstart(self): return DateTools.strToDate(self._getText('start'), source='Début de location')