def _process_status(self, status_entry = {}): tweets_table_row = [] user = status_entry.getElementsByTagName('user')[0] userinfo = twitter.ttuser() userinfo.load_user_info(user) tweets_table_row.append('') statusinfo = twitter.ttstatus(self.link_color) try: statusinfo.load_status(status_entry) except: return if statusinfo.tweets_id > self.tweets_max_id: self.tweets_max_id = statusinfo.tweets_id if self.tweets_min_id == 0: self.tweets_min_id = statusinfo.tweets_id else: if statusinfo.tweets_id < self.tweets_min_id: self.tweets_min_id = statusinfo.tweets_id print "tweets id is : %s" % statusinfo.tweets_id tweets_body = template.TWEETS_TEMPLATE % ( self.link_color, \ userinfo.screen_name, \ userinfo.screen_name, \ userinfo.name + ' ', \ statusinfo.create_at, \ statusinfo.source, \ statusinfo.status_text) print tweets_body try: tweets_paragraph = Paragraph(tweets_body, self.text_font) tweets_table_row.append(tweets_paragraph) tweets_table_row.append(userinfo) self.tweets_table_data.append(tweets_table_row) except: pass
def generate_cover(self): # Fetching User Information self.main_panel.update_status(status_fetch_user_information) response = self.oauth_client.fetch_user_information(self.screen_name) if type(response) != types.StringType: try: if response.code == 404: self.main_panel.show_done('@%s not exist' % self.screen_name) return False else: self.main_panel.show_done('Twitter API limited,please retry later.') return False except: self.main_panel.show_done('Twitter API limited,please retry later.') return False doc = minidom.parseString(response).documentElement userinfo = twitter.ttuser() userinfo.load_user_info(doc) self.screen_name = userinfo.screen_name if self.tweets_count is None or self.tweets_count == 0: self.tweets_count = int(userinfo.status_count) if not self.has_cover: return True # generate information of the user table_data = [] table_row = [] table_data.append([Spacer(0, 100)]) profile_image_name = self.oauth_client.fetch_profile_image( screen_name = userinfo.screen_name, size = 'bigger', file_type = userinfo.image_type) try: profile_image = Image(profile_image_name, 73, 73) table_row.append(profile_image) except: table_row.append('') if userinfo.url == '#': desc = Paragraph(template.PROFILE_TEMPLATE_NO_URL % ( \ userinfo.name + ' ', \ userinfo.screen_name, \ userinfo.location, \ userinfo.description ), self.text_font) else: desc = Paragraph(template.PROFILE_TEMPLATE % ( \ userinfo.name + ' ', \ userinfo.screen_name, \ userinfo.location, \ userinfo.description, \ userinfo.url, \ self.link_color, \ userinfo.url ), self.text_font) table_row.append(desc) table_data.append(table_row) cover_table = Table(table_data, colWidths = [80, self.cover_table_width - 120]) self.elements.append(cover_table) table_data = [] table_data.append([ Paragraph('<b>Tweets </b><font color="blue">%s</font>' % \ userinfo.status_count, self.text_font) ]) status_node = doc.getElementsByTagName('status') if len(status_node) > 0: statusinfo = twitter.ttstatus(self.link_color) statusinfo.load_status(status_node[0]) table_data.append([ Paragraph('<font color="grey"><b>%s: </b></font>%s' % \ ( statusinfo.create_at, statusinfo.status_text), self.text_font) ]) table_data.append([ Spacer(0, 10)]) table_data.append([ Paragraph('<b>Followers </b><font color="blue">%s</font>' % \ userinfo.followers_count, self.text_font) ]) table_data = self._generate_grid(table_data, self.screen_name, 'follower') table_data.append([ Paragraph('<b>Following </b><font color="blue">%s</font>' % \ userinfo.friends_count, self.text_font) ]) #generate information of the following account table_data = self._generate_grid(table_data, self.screen_name, 'following') table_data.append([Spacer(0, 20)]) cover_table = Table(table_data, colWidths = [self.cover_table_width]) self.elements.append(cover_table) return True