def sp_index(self, r): ### Is modified if self.projects[0]['_id'] == 'St_Miguel': cal = st_miguel() extra = cal.get_extras(r.year) if cal.is_holiday(r, extra): sp = 100 else: if r.dayofweek == 6: sp = 50 else: sp = 0 else: cal = Greece() # {'New year','Epiphany','Clean Monday','Independence Day','Good Friday','Easter Saturday','Easter Sunday', # 'Easter Monday','Labour Day','Pentecost','Whit Monday','Assumption of Mary to Heaven','Ohi Day', # 'Christmas Eve','Christmas Day','Glorifying Mother of God','Last day of year'} if cal.is_holiday(r): sp = 100 else: if r.dayofweek == 6: sp = 50 else: sp = 0 return sp
def sp_index(self, r): ### Is modified cal = Greece() # {'New year','Epiphany','Clean Monday','Independence Day','Good Friday','Easter Saturday','Easter Sunday','Easter Monday','Labour Day','Pentecost','Whit Monday','Assumption of Mary to Heaven','Ohi Day','Christmas Eve' # ,'Christmas Day','Glorifying Mother of God','Last day of year'} if cal.is_holiday(r): sp = 100 else: if r.dayofweek == 6: sp = 50 else: sp = 0 return sp
def get_cal_from_country(bmk_country): """ Function returning a calendar based on the 'benchmark_country' of the csv file # Python package to manage holidays per country # >> See : https://github.com/peopledoc/workalendar from 'benchmark_country' column (to be parsed) in the Derivation Script Warning : Tuples may appear like [USA, Japon] or [USA, China] instead of China [Germany, China] instead of Russia [USA, China] instead of Moyen-Orient [USA, China] instead of Brasil Currently missing : China, Russia @TODO : ADD HONG-KONG !!! (for 'HSI_Index') NOTE : 5 avril 2018 : Ching Ming Festival (jour férié Hong-Kong !) :param bmk_country: benchmark country (type: string) :return: - cal: calendar related to the country (type: workalendar type ?) """ cal = [] if ',' in bmk_country: # '[A, B]' => ['A', 'B'] print "[WARNING] Tuple for the 'benchmark_country : {}, returning the first one..".format( bmk_country) bmk_country = bmk_country.replace('[', '').replace(']', '').split(',') bmk_country = bmk_country[0] # TO BE DEFINED ! if bmk_country == 'USA': cal = UnitedStates() elif bmk_country == 'Germany': cal = Germany() elif bmk_country == 'Japan': cal = Japan() elif bmk_country == 'France': cal = France() elif bmk_country == 'UK': cal = UnitedKingdom() elif bmk_country == 'Grèce': cal = Greece() elif bmk_country == 'Italie': cal = Italy() elif bmk_country == 'Espagne': cal = Spain() elif bmk_country == 'Brasil': cal = Brazil() return cal