<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from datetime import date <EOL> from calendar import HTMLCalendar <EOL> from django . utils . dates import MONTHS <EOL> from django . utils . dates import WEEKDAYS_ABBR <EOL> from django . utils . formats import get_format <EOL> from django . utils . formats import date_format <EOL> from django . core . urlresolvers import reverse <EOL> from zinnia . models . entry import Entry <EOL> AMERICAN_TO_EUROPEAN_WEEK_DAYS = [ <NUM_LIT:6> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] <EOL> class Calendar ( HTMLCalendar ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> HTMLCalendar . __init__ ( self , AMERICAN_TO_EUROPEAN_WEEK_DAYS [ <EOL> get_format ( '<STR_LIT>' ) ] ) <EOL> def formatday ( self , day , weekday ) : <EOL> """<STR_LIT>""" <EOL> if day and day in self . day_entries : <EOL> day_date = date ( self . current_year , self . current_month , day ) <EOL> archive_day_url = reverse ( '<STR_LIT>' , <EOL> args = [ day_date . strftime ( '<STR_LIT>' ) , <EOL> day_date . strftime ( '<STR_LIT>' ) , <EOL> day_date . strftime ( '<STR_LIT>' ) ] ) <EOL> return '<STR_LIT>' '<STR_LIT>' % ( <EOL> self . cssclasses [ weekday ] , archive_day_url , day ) <EOL> return super ( Calendar , self ) . formatday ( day , weekday ) <EOL> def formatweekday ( self , day ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' % ( self . cssclasses [ day ] , <EOL> WEEKDAYS_ABBR [ day ] . title ( ) ) <EOL> def formatweekheader ( self ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' % super ( Calendar , self ) . formatweekheader ( ) <EOL> def formatfooter ( self , previous_month , next_month ) : <EOL> """<STR_LIT>""" <EOL> footer = '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' <EOL> if previous_month : <EOL> previous_content = '<STR_LIT>' % ( <EOL> reverse ( '<STR_LIT>' , args = [ <EOL> previous_month . strftime ( '<STR_LIT>' ) , <EOL> previous_month . strftime ( '<STR_LIT>' ) ] ) , <EOL> date_format ( previous_month , '<STR_LIT>' ) ) <EOL> else : <EOL> previous_content = '<STR_LIT>' <EOL> if next_month : <EOL> next_content = '<STR_LIT>' % ( <EOL> reverse ( '<STR_LIT>' , args = [ <EOL> next_month . strftime ( '<STR_LIT>' ) , <EOL> next_month . strftime ( '<STR_LIT>' ) ] ) , <EOL> date_format ( next_month , '<STR_LIT>' ) ) <EOL> else : <EOL> next_content = '<STR_LIT>' <EOL> return footer % ( previous_content , next_content ) <EOL> def formatmonthname ( self , theyear , themonth , withyear = True ) : <EOL> """<STR_LIT>""" <EOL> monthname = '<STR_LIT>' % ( MONTHS [ themonth ] . title ( ) , theyear ) <EOL> return '<STR_LIT>' % monthname <EOL> def formatmonth ( self , theyear , themonth , withyear = True , <EOL> previous_month = None , next_month = None ) : <EOL> """<STR_LIT>""" <EOL> self . current_year = theyear <EOL> self . current_month = themonth <EOL> self . day_entries = [ date . day <EOL> for date in Entry . published . filter ( <EOL> publication_date__year = theyear , <EOL> publication_date__month = themonth <EOL> ) . datetimes ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> v = [ ] <EOL> a = v . append <EOL> a ( '<STR_LIT>' % ( <EOL> self . day_entries and '<STR_LIT>' or '<STR_LIT>' ) ) <EOL> a ( '<STR_LIT:\n>' ) <EOL> a ( self . formatmonthname ( theyear , themonth , withyear = withyear ) ) <EOL> a ( '<STR_LIT:\n>' ) <EOL> a ( self . formatweekheader ( ) ) <EOL> a ( '<STR_LIT:\n>' ) <EOL> a ( self . formatfooter ( previous_month , next_month ) ) <EOL> a ( '<STR_LIT>' ) <EOL> for week in self . monthdays2calendar ( theyear , themonth ) : <EOL> a ( self . formatweek ( week ) ) <EOL> a ( '<STR_LIT:\n>' ) <EOL> a ( '<STR_LIT>' ) <EOL> a ( '<STR_LIT:\n>' ) <EOL> return '<STR_LIT>' . join ( v ) </s>
