docs: def main():
  	"""
  	Scrapes Apple's iCal feed for Australian public holidays and generates per-
  	state listings.
  	
  	"""
  	print "Downloading Holidays from Apple's server..."
  	r = requests.get('http://files.apple.com/calendars/Australian32Holidays.ics')
  	
  	cal = Calendar.from_ical(r.text)
  	
  	print "Processing calendar data..."
  	
  	valid_states = ['ACT', 'NSW', 'NT', 'QLD', 'SA', 'TAS', 'VIC', 'WA']
  	
  	state_cal = {}
  	all_cal = make_calendar()
  	
  	for state in valid_states:
  		state_cal[state] = make_calendar()
  	
  	for event in cal.walk('VEVENT'):
  		event_name = event.decoded('SUMMARY').lower()
  		if filter(lambda x: x in event_name, IGNORED_EVENTS):
  			continue
  		
  		# see if there is a state or if it is for all
  		if '(' in event_name: # and not 'day in lieu' in event_name:
  			# it is just for certain states.
  			# eg:
  			#  - Easter Tuesday (TAS)
  			#  - Labour Day (ACT, NSW, SA, QLD)
  			states = event_name.split('(', 2)[1].split(')')[0].split(',')
  			
  			if states == ['day in lieu']:
  				# only a day in lieu, switch to all-cal logic
  				all_cal.add_component(event)
  				continue
  
  			for state in states:
  				state = state.strip().upper()
  				assert state in valid_states, 'state=%r' % state
  				state_cal[state].add_component(event)
  		else:
  			# for all states
  			all_cal.add_component(event)
  
  	print "Writing to disk..."
  	# done, write calendars.
  	with open('au_holidays.ics', 'wb') as f:
  		f.write(all_cal.to_ical())
  
  	for state in state_cal.keys():
  		with open('%s_holidays.ics' % state.lower(), 'wb') as f:
  			f.write(state_cal[state].to_ical())
  	
  	print "All done!"