Package lib :: Module holiday :: Class HolidayProvider
[hide private]
[frames] | no frames]

Class HolidayProvider

source code

object --+
         |
        HolidayProvider

class holding the holidays throught the year(s)

Instance Methods [hide private]
 
__init__(self, s_normal, s_weekend, s_holiday, s_weekend_holiday, s_multi, s_weekend_multi, multiday_markers=True)
initialize a HolidayProvider object
source code
(char,type(ddef),str,str,int)
_parse_day_record(self, fields)
return tuple (etype,ddef,footer,header,flags)
source code
(Holiday,Holiday,Holiday,Holiday)
_multi_holiday_tuple(self, header, footer, flags)
returns a 4-tuple of Holiday objects representing (beginning, end, first-day-of-month, rest)
source code
 
load_holiday_file(self, filename)
load a holiday file into the HolidayProvider object
source code
Holiday
get_holiday(self, y, m, d)
return a Holiday object for the specified date (y,m,d) or None if no holiday is defined
source code
Style
get_style(self, flags, dow)
return appropriate style object, depending on flags and dow
source code
(str,str,Style)
__call__(self, year, month, dom, dow)
returns (header,footer,day_style)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  annual
dict of events occuring annually, indexed by tuple (day,month).
  cache
for each year requested, all holidays occuring within that year (annual, monthly, easter-based etc.) are precomputed and stored into dict cache, indexed by a date() object
  cath_easter
dict of events relative to the catholic easter Sunday, indexed by an integer days offset
  fixed
fixed date events, indexed by a date() object
  george
events occuring on St George's day (orthodox calendar special computation)
  monthly
event occuring monthly, indexed by int day
  orth_easter
dict of events relative to the orthodox easter Sunday, indexed by an integer days offset
  ycache
set holding cached years; each new year requested, triggers a cache-fill operation
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, s_normal, s_weekend, s_holiday, s_weekend_holiday, s_multi, s_weekend_multi, multiday_markers=True)
(Constructor)

source code 

initialize a HolidayProvider object

Parameters:
  • s_normal - style class object for normal (weekday) day cells
  • s_weekend - style for weekend day cells
  • s_holiday - style for holiday day cells
  • s_weekend_holiday - style for holiday cells on weekends
  • s_multi - style for multi-day holiday weekday cells
  • s_weekend_multi - style for multi-day holiday weekend cells
  • multiday_markers - if True, then use end-of-multiday-holiday markers and range markers (with dots), otherwise only first day and first-day-of-month are marked
Overrides: object.__init__

_parse_day_record(self, fields)

source code 

return tuple (etype,ddef,footer,header,flags)

Returns: (char,type(ddef),str,str,int)

Note: ddef is one of the following:

  • None
  • int
  • ((y,m,d),)
  • ((y,m,d),(y,m,d))

_multi_holiday_tuple(self, header, footer, flags)

source code 

returns a 4-tuple of Holiday objects representing (beginning, end, first-day-of-month, rest)

Parameters:
  • header - passed as [header] of the generated Holiday object
  • footer - passed as [footer] of the generated Holiday object
  • flags - flags of the generated Holiday object
Returns: (Holiday,Holiday,Holiday,Holiday)

load_holiday_file(self, filename)

source code 

load a holiday file into the HolidayProvider object

File Format:

  • type|date*span|footer|header|flags
  • type|date1-date2|footer|header|flags
  • type|date|footer|header|flags

type:

  • d: event occurs annually fixed day/month; date=MMDD
  • d: event occurs monthly, fixed day; date=DD
  • d: fixed day/month/year combination (e.g. deadline, trip, etc.); date=YYYYMMDD
  • oe: Orthodox Easter-dependent holiday, annually; date=integer offset in days
  • ge: Georgios' name day, Orthodox Easter dependent holiday, annually; date field is ignored
  • ce: Catholic Easter holiday; date=integer offset in days

date*span and range date1-date2 supported only for date=YYYYMMDD (fixed) events

flags: comma-separated list of the following:

  1. off
  2. multi
  3. reminder (or any prefix of it)

Example:

   d|0101||New year's|off
   d|0501||Labour day|off
   ce|-2||Good Friday|
   ce|0||Easter|off
   ce|1||Easter Monday|off
   d|20130223-20130310|winter vacations (B)||multi
Parameters:
  • filename - file to be loaded

get_holiday(self, y, m, d)

source code 

return a Holiday object for the specified date (y,m,d) or None if no holiday is defined

Returns: Holiday

Note: If year y has not been requested before, the cache is updated first with all holidays that belong in y, indexed by date() objects.

get_style(self, flags, dow)

source code 

return appropriate style object, depending on flags and dow

Parameters:
  • flags - bit combination of holiday flags
  • dow - day of week
Returns: Style

__call__(self, year, month, dom, dow)
(Call operator)

source code 

returns (header,footer,day_style)

Parameters:
  • month - month (0-12)
  • dom - day of month (1-31)
  • dow - day of week (0-6)
Returns: (str,str,Style)

Instance Variable Details [hide private]

annual

dict of events occuring annually, indexed by tuple (day,month). Note each dict entry is actually a list of Holiday objects. This is also true for the other instance variables: monthly, fixed, orth_easter, george, cath_easter.