From 964358c1f209cd323f4af4337e98c3b0b98209ce Mon Sep 17 00:00:00 2001 From: Anna Date: Sun, 23 May 2010 11:50:14 -0400 Subject: [PATCH] Made some bug fixes related to unassigned variables --- TODO | 5 ++--- apithreads.py | 8 +++++--- twitterwidgets.py | 20 ++++++++++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 12d506b..f95ec3c 100644 --- a/TODO +++ b/TODO @@ -15,9 +15,8 @@ features: bugs: -* Direct Messages have no names, only screen names (may not be fixable without - considerable tweaks to python-twitter) +* Searches and Direct Messages have no names, only screen names (may not be fixable without considerable tweaks to python-twitter?) +* Search results have html-escaped character strings * "ValueError: list.remove(x): x not in list" when trying to close a tab (error recurred after adding conversation support). Tabs can be reordered, then closed, as a workaround. * Links must be right-clicked on to activate - can't left-click on the link directly. This seems to be a pygtk issue * If an @ appears anywhere in a status update, links after it try to resolve to user: links... need to work on my regexes -* "/home/user/code/hrafn/apithreads.py", line 241: UnboundLocalError: local variable 'user' referenced before assignment diff --git a/apithreads.py b/apithreads.py index fb6e36c..ba4dc06 100644 --- a/apithreads.py +++ b/apithreads.py @@ -235,11 +235,11 @@ class GetUserInfo(ApiThread): try: with self.api.lock: user = self.api.GetUser(screen_name) + avcache.add_to_cache(user) except (HTTPError, URLError): verified = False + user = None - avcache.add_to_cache(user) - gtk.gdk.threads_enter() try: self.pane.user_box.update_info(user) @@ -417,7 +417,7 @@ def results_to_statuses(results, api): status.id = result.id status.user = User() status.user.screen_name = result.from_user - status.user.name = "" + status.user.name = '' status.user.profile.image_url = result.profile_image_url status.in_reply_to_screen_name = result.to_user # The Twitter Search API has different timestamps than the @@ -461,6 +461,8 @@ def dms_to_statuses(direct_messages): status.created_at = dm.created_at status.text = dm.text status.source = None + status.in_reply_to_status_id = None + status.in_reply_to_screen_name = None statuses.append(status) return statuses diff --git a/twitterwidgets.py b/twitterwidgets.py index 0549aae..4a7c9a8 100644 --- a/twitterwidgets.py +++ b/twitterwidgets.py @@ -285,9 +285,9 @@ class TweetBox(gtk.HBox): app_button_eb = gtk.EventBox() app_button_eb.add(self.app_button) - via_label = gtk.Label(' via ') + self.via_label = gtk.Label(' via ') via_label_eb = gtk.EventBox() - via_label_eb.add(via_label) + via_label_eb.add(self.via_label) self.header = gtk.Button() label_box = gtk.HBox() @@ -307,7 +307,7 @@ class TweetBox(gtk.HBox): time_label_eb.modify_text(gtk.STATE_NORMAL,gtk.gdk.color_parse("#ffffff")) time_label_eb.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse("#8888ff")) - via_label.set_alignment(0.0, 0.5) + self.via_label.set_alignment(0.0, 0.5) via_label_eb.modify_text(gtk.STATE_NORMAL,gtk.gdk.color_parse("#ffffff")) via_label_eb.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse("#8888ff")) @@ -402,9 +402,17 @@ class TweetBox(gtk.HBox): timestring = timestamp.astimezone(timezone).strftime(time_format) # Set the header - self.app_url = re.sub(r'.*(.*).*', r'\1', status.source) - self.app_button.set_label(app_name) + if status.source is not None: + self.app_url = re.sub(r'.*(.*).*', r'\1', status.source) + self.app_button.set_label(app_name) + self.app_button.show() + self.via_label.show() + else: + self.app_button.hide() + self.via_label.hide() + self.app_url = '' + if re.match('/', self.app_url): self.app_url = 'http://twitter.com' + self.app_url