Extract the checkpoints and store in self.tracking_data

def Extract_Checkpoints(self):
		'''
			Extract the checkpoints and store in self.tracking_data
		'''

		# Make sure page is available
		if self.page is None:
			raise Exception("The HTML data was not fetched due to some reasons")

		soup = BeautifulSoup(self.page,'html.parser')

		# Check for invalid tracking number by checking if table element is present
		if soup.find('thead') == None:
			raise ValueError('Invalid tracking number')

		
		# Assign the current status of the shipment - self.status

		if 'Returned' in self.page:	
			self.status = 'R'
		elif 'Signed for by:' in self.page:
			self.status = 'C'
		else:											 # The shipment is in Transit
			self.status = 'T'

		# The full checkpoints table div.
		table = soup.find('table',{'class':'result-checkpoints'}).contents
		cur_date = None		# The date of the next few checkpoints, initially None
		checkpoint = None

		for element in table:
			if element.name == 'thead':
				# This has the date for the next few checkpoints
				cur_date = element.find('th',{'colspan':'2'}).string.strip() + ' '

			elif element.name == 'tbody':
				# A checkpoint whose date = cur_date
				checkpoint = {'status':'','date':cur_date,'location':''}
				tds = element.findAll('td')
				checkpoint['status'] = tds[1].string.strip()
				checkpoint['location'] = tds[2].string.strip()
				checkpoint['date'] += tds[3].string.strip()
				date_time_format = "%d-%b-%Y %H:%M"
				checkpoint['date'] = parse(checkpoint['date'])
				self.tracking_data.append(checkpoint)

		self.tracking_data = sorted(self.tracking_data, key=lambda k: k['date'])