Beispiel #1
0
	def testsequence(self):
		data = [
			{ 'input': 'http://test.com asdfasdf http://twitpic.com/adsfk32', 'expected': '<a href="http://test.com">http://test.com</a> asdfasdf <div class="twitpic_img"><a href="http://twitpic.com/adsfk32"><img src="http://twitpic.com/show/large/adsfk32" width="350" alt="adsfk32"/></a></div>' }
		]
		# just testing that we get the same result regardless of the order
		f1 = lambda str: Utils.twitpic_to_img(Utils.links_to_anchors(str))
		f2 = lambda str: Utils.links_to_anchors(Utils.twitpic_to_img(str))		
		self._runTests( data, f1 )
		self._runTests( data, f2 )
Beispiel #2
0
	def toEntry(self, status):
		from app.utils import StringHelper			
		e = Entry(external_id=str(status['id']),
		source = self.source_id,
		text = Utils.links_to_anchors(Utils.twitpic_to_img(status['text'])),
		title = StringHelper().remove_new_lines(status['text']),
		url='http://twitter.com/' + str(status['user']['screen_name']) + '/statuses/' + str(status['id']))
		e.created = parse(status['created_at'])
		
		# extract the tags
		e.tags = StringHelper().extract_twitter_tags(status['text'])
		
		# process the location coordinates if they're available
		if status['coordinates'] != None:
			e.lat = str(status['coordinates']['coordinates'][1])
			e.lng = str(status['coordinates']['coordinates'][0])	
			
		# is this entry a reply-to?
		logging.debug(e.text[0])
		e.twitter_reply = (e.text[0] == '@')
		
		return(e)