示例#1
0
def year_view(year):
	
	tbl = render_calendar(year)
	soup = BeautifulSoup(tbl)
	soup = transforms.format_table(soup)
	soup = transforms.add_month_links(soup,year)

	return template("main",cal_table=str(soup),
		prev=_a(year-1),next=_a(year+1),_type="year")
示例#2
0
def add_month_links(soup,year):

	headers = soup.find_all("th")

	for header in headers:
		cls = header.get('class')

		if cls and 'month' in cls:
			month_num = _month_lookup[header.string]

			a = soup.new_tag("a")
			a['href'] = _a(year,month_num)

			header.string.wrap(a)

	return soup
示例#3
0
def month_view(year = None, month = None):

	if not (year or month):
		now = datetime.datetime.now()
		year = now.year
		month = now.month

	tbl = render_calendar(year,month)

	soup = BeautifulSoup(tbl)
	soup = transforms.format_table(soup)
	soup = transforms.add_weather(soup,year,month,True)
	
	prev_next = _prev_next_month(year,month)

	return template("main",cal_table=str(soup),
		prev=prev_next[0],next=prev_next[1],
		year=_a(year),_type="month")