From: Bruno Abinader Date: Mon, 2 Mar 2009 14:25:11 +0000 (-0400) Subject: Replaced all 'dict.has_key(item)' with 'item in dict' expressions. X-Git-Url: http://git.maemo.org/git/?p=python-purple;a=commitdiff_plain;h=7752e0f4a14a32ede02b8b86c83d9510338a59ed Replaced all 'dict.has_key(item)' with 'item in dict' expressions. FIXES: - Replaced all 'dict.has_key(item)' with 'item in dict' expressions (Performance gain). - Indentation fixes. Signed-off-by: Bruno Abinader --- diff --git a/account.pyx b/account.pyx index 36902a7..5935ba9 100644 --- a/account.pyx +++ b/account.pyx @@ -327,7 +327,7 @@ cdef class Account: sett = str( setting) - if not po.has_key(sett): + if sett not in po: iter = iter.next continue diff --git a/account_cbs.pxd b/account_cbs.pxd index e6bdee8..2d8bf68 100644 --- a/account_cbs.pxd +++ b/account_cbs.pxd @@ -58,7 +58,7 @@ cdef void notify_added(account.PurpleAccount *c_account, \ their buddy list. """ cdef connection.PurpleConnection *gc = \ - account.purple_account_get_connection(c_account) + account.purple_account_get_connection(c_account) debug.purple_debug_info("account", "%s", "notify-added\n") @@ -81,10 +81,10 @@ cdef void notify_added(account.PurpleAccount *c_account, \ else: message = None - if account_cbs.has_key("notify-added"): + if "notify-added" in account_cbs: ( account_cbs["notify-added"])( \ - ( remote_user, remote_alias), \ - (username, protocol_id), message) + ( remote_user, remote_alias), \ + (username, protocol_id), message) cdef void status_changed(account.PurpleAccount *c_account, \ status.PurpleStatus *c_status): @@ -99,9 +99,9 @@ cdef void status_changed(account.PurpleAccount *c_account, \ status_id = status.purple_status_get_id(c_status) status_name = status.purple_status_get_name(c_status) - if account_cbs.has_key("status-changed"): + if "status-changed" in account_cbs: ( account_cbs["status-changed"])( \ - (username, protocol_id), status_id, status_name) + (username, protocol_id), status_id, status_name) cdef void request_add(account.PurpleAccount *c_account, \ const_char *remote_user, const_char *id, const_char *alias, \ @@ -133,10 +133,10 @@ cdef void request_add(account.PurpleAccount *c_account, \ else: message = None - if account_cbs.has_key("request-add"): + if "request-add" in account_cbs: ( account_cbs["request-add"])( \ - ( remote_user, remote_alias), \ - (username, protocol_id), message) + ( remote_user, remote_alias), \ + (username, protocol_id), message) cdef void *request_authorize(account.PurpleAccount *c_account, \ const_char *remote_user, const_char *id, const_char *alias, \ @@ -182,12 +182,12 @@ cdef void *request_authorize(account.PurpleAccount *c_account, \ else: message = None - if account_cbs.has_key("request-authorize"): + if "request-authorize" in account_cbs: ( account_cbs["request-authorize"])( \ - ( remote_user, remote_alias), \ - (username, protocol_id), \ - message, on_list, \ - call_authorize_cb, call_deny_cb) + ( remote_user, remote_alias), \ + (username, protocol_id), \ + message, on_list, \ + call_authorize_cb, call_deny_cb) cdef void close_account_request (void *ui_handle): """ @@ -198,5 +198,5 @@ cdef void close_account_request (void *ui_handle): request.purple_request_close(request.PURPLE_REQUEST_ACTION, ui_handle) - if account_cbs.has_key("close-account-request"): + if "close-account-request" in account_cbs: ( account_cbs["close-account-request"])() diff --git a/blist_cbs.pxd b/blist_cbs.pxd index 8fba121..fc587e5 100644 --- a/blist_cbs.pxd +++ b/blist_cbs.pxd @@ -92,7 +92,7 @@ cdef void new_list(blist.PurpleBuddyList *list): Sets UI-specific data on a buddy list. """ debug.purple_debug_info("blist", "%s", "new-list\n") - if blist_cbs.has_key("new-list"): + if "new-list" in blist_cbs: ( blist_cbs["new-list"])("new-list: TODO") cdef void new_node(blist.PurpleBlistNode *node): @@ -100,7 +100,7 @@ cdef void new_node(blist.PurpleBlistNode *node): Sets UI-specific data on a node. """ debug.purple_debug_info("blist", "%s", "new-node\n") - if blist_cbs.has_key("new-node"): + if "new-node" in blist_cbs: if node.type == blist.PURPLE_BLIST_GROUP_NODE: __group_node_cb(node, blist_cbs["new-node"]) elif node.type == blist.PURPLE_BLIST_CONTACT_NODE: @@ -117,7 +117,7 @@ cdef void show(blist.PurpleBuddyList *list): The core will call this when it's finished doing its core stuff. """ debug.purple_debug_info("blist", "%s", "show\n") - if blist_cbs.has_key("show"): + if "show" in blist_cbs: ( blist_cbs["show"])("show: TODO") cdef void update(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node): @@ -125,7 +125,7 @@ cdef void update(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node): This will update a node in the buddy list. """ debug.purple_debug_info("blist", "%s", "update\n") - if blist_cbs.has_key("update"): + if "update" in blist_cbs: if node.type == blist.PURPLE_BLIST_GROUP_NODE: __group_node_cb(node, blist_cbs["update"]) elif node.type == blist.PURPLE_BLIST_CONTACT_NODE: @@ -142,7 +142,7 @@ cdef void remove(blist.PurpleBuddyList *list, blist.PurpleBlistNode *node): This removes a node from the list. """ debug.purple_debug_info("blist", "%s", "remove\n") - if blist_cbs.has_key("remove"): + if "remove" in blist_cbs: if node.type == blist.PURPLE_BLIST_GROUP_NODE: __group_node_cb(node, blist_cbs["remove"]) elif node.type == blist.PURPLE_BLIST_CONTACT_NODE: @@ -159,7 +159,7 @@ cdef void destroy(blist.PurpleBuddyList *list): When the list gets destroyed, this gets called to destroy the UI. """ debug.purple_debug_info("blist", "%s", "destroy\n") - if blist_cbs.has_key("destroy"): + if "destroy" in blist_cbs: ( blist_cbs["destroy"])("destroy: TODO") cdef void set_visible(blist.PurpleBuddyList *list, glib.gboolean show): @@ -167,7 +167,7 @@ cdef void set_visible(blist.PurpleBuddyList *list, glib.gboolean show): Hides or unhides the buddy list. """ debug.purple_debug_info("blist", "%s", "set-visible\n") - if blist_cbs.has_key("set-visible"): + if "set-visible" in blist_cbs: ( blist_cbs["set-visible"])("set-visible: TODO") cdef void request_add_buddy(account.PurpleAccount *c_account, \ @@ -197,10 +197,9 @@ cdef void request_add_buddy(account.PurpleAccount *c_account, \ else: buddy_alias = None - if blist_cbs.has_key("request-add-buddy"): + if "request-add-buddy" in blist_cbs: ( blist_cbs["request-add-buddy"])( \ - (username, protocol_id), \ - buddy_username, buddy_group, buddy_alias) + (username, protocol_id), buddy_username, buddy_group, buddy_alias) cdef void request_add_chat(account.PurpleAccount *acc, \ blist.PurpleGroup *group, const_char *alias, const_char *name): @@ -208,7 +207,7 @@ cdef void request_add_chat(account.PurpleAccount *acc, \ TODO """ debug.purple_debug_info("blist", "%s", "request-add-chat\n") - if blist_cbs.has_key("request-add-chat"): + if "request-add-chat" in blist_cbs: ( blist_cbs["request-add-chat"])("request-add-chat: TODO") cdef void request_add_group(): @@ -216,5 +215,5 @@ cdef void request_add_group(): TODO """ debug.purple_debug_info("blist", "%s", "request-add-group\n") - if blist_cbs.has_key("request-add-chat"): - (blist_cbs["request-add-chat"])("request-add-group: TODO") + if "request-add-group" in blist_cbs: + (blist_cbs["request-add-group"])("request-add-group: TODO") diff --git a/connection_cbs.pxd b/connection_cbs.pxd index 1fc35d6..501f39e 100644 --- a/connection_cbs.pxd +++ b/connection_cbs.pxd @@ -35,15 +35,16 @@ cdef void connect_progress(connection.PurpleConnection *gc, const_char *text, \ reached (which might be displayed as a progress bar). """ debug.purple_debug_info("connection", "%s", "connect-progress\n") - if connection_cbs.has_key("connect-progress"): - ( connection_cbs["connect-progress"])( text, step, step_count) + if "connect-progress" in connection_cbs: + ( connection_cbs["connect-progress"]) \ + ( text, step, step_count) cdef void connected(connection.PurpleConnection *gc): """ Called when a connection is established (just before the signed-on signal). """ debug.purple_debug_info("connection", "%s", "connected\n") - if connection_cbs.has_key("connected"): + if "connected" in connection_cbs: ( connection_cbs["connected"])("connected: TODO") cdef void disconnected(connection.PurpleConnection *gc): @@ -52,7 +53,7 @@ cdef void disconnected(connection.PurpleConnection *gc): signal). """ debug.purple_debug_info("connection", "%s", "disconnected\n") - if connection_cbs.has_key("disconnected"): + if "disconnected" in connection_cbs: ( connection_cbs["disconnected"])("disconnected: TODO") cdef void notice(connection.PurpleConnection *gc, const_char *text): @@ -62,7 +63,7 @@ cdef void notice(connection.PurpleConnection *gc, const_char *text): operation, is not used by any of the protocols shipped with libpurple.) """ debug.purple_debug_info("connection", "%s", "notice\n") - if connection_cbs.has_key("notice"): + if "notice" in connection_cbs: ( connection_cbs["notice"])("notice: TODO") cdef void report_disconnect(connection.PurpleConnection *gc, const_char *text): @@ -75,7 +76,7 @@ cdef void report_disconnect(connection.PurpleConnection *gc, const_char *text): PurpleConnectionUiOps.report_disconnect_reason. """ debug.purple_debug_info("connection", "%s", "report-disconnect\n") - if connection_cbs.has_key("report-disconnect"): + if "report-disconnect" in connection_cbs: ( connection_cbs["report-disconnect"])( text) cdef void network_connected(): @@ -85,7 +86,7 @@ cdef void network_connected(): it uses Win32's network change notification infrastructure. """ debug.purple_debug_info("connection", "%s", "network-connected\n") - if connection_cbs.has_key("network-connected"): + if "network-connected" in connection_cbs: ( connection_cbs["network-connected"])() cdef void network_disconnected(): @@ -94,7 +95,7 @@ cdef void network_disconnected(): has gone away. """ debug.purple_debug_info("connection", "%s", "network-disconnected\n") - if connection_cbs.has_key("network-disconnected"): + if "network-disconnected" in connection_cbs: ( connection_cbs["network-disconnected"])() cdef void report_disconnect_reason(connection.PurpleConnection *gc, \ @@ -137,5 +138,6 @@ cdef void report_disconnect_reason(connection.PurpleConnection *gc, \ else: text = None - if connection_cbs.has_key("report-disconnect-reason"): - ( connection_cbs["report-disconnect-reason"])(reason_string, text) + if "report-disconnect-reason" in connection_cbs: + ( connection_cbs["report-disconnect-reason"]) \ + (reason_string, text) diff --git a/conversation_cbs.pxd b/conversation_cbs.pxd index f3a6bd7..573ef15 100644 --- a/conversation_cbs.pxd +++ b/conversation_cbs.pxd @@ -42,7 +42,7 @@ cdef void create_conversation(conversation.PurpleConversation *conv): type = conversation.purple_conversation_get_type(conv) - if conversation_cbs.has_key("create-conversation"): + if "create-conversation" in conversation_cbs: ( conversation_cbs["create-conversation"])(name, type) cdef void destroy_conversation(conversation.PurpleConversation *conv): @@ -50,8 +50,9 @@ cdef void destroy_conversation(conversation.PurpleConversation *conv): Called just before a conv is freed. """ debug.purple_debug_info("conversation", "%s", "destroy-conversation\n") - if conversation_cbs.has_key("destroy-conversation"): - ( conversation_cbs["destroy-conversation"])("destroy-conversation: TODO") + if "destroy-conversation" in conversation_cbs: + ( conversation_cbs["destroy-conversation"]) \ + ("destroy-conversation: TODO") cdef void write_chat(conversation.PurpleConversation *conv, const_char *who, \ const_char *message, conversation.PurpleMessageFlags flags, \ @@ -62,7 +63,7 @@ cdef void write_chat(conversation.PurpleConversation *conv, const_char *who, \ @see purple_conv_chat_write() """ debug.purple_debug_info("conversation", "%s", "write-chat\n") - if conversation_cbs.has_key("write-chat"): + if "write-chat" in conversation_cbs: ( conversation_cbs["write-chat"])("write-chat: TODO") cdef void write_im(conversation.PurpleConversation *conv, const_char *who, \ @@ -74,7 +75,8 @@ cdef void write_im(conversation.PurpleConversation *conv, const_char *who, \ @see purple_conv_im_write() """ debug.purple_debug_info("conversation", "%s", "write-im\n") - cdef account.PurpleAccount *acc = conversation.purple_conversation_get_account(conv) + cdef account.PurpleAccount *acc = \ + conversation.purple_conversation_get_account(conv) cdef blist.PurpleBuddy *buddy = NULL cdef char *c_username = NULL cdef char *c_sender_alias = NULL @@ -109,9 +111,9 @@ cdef void write_im(conversation.PurpleConversation *conv, const_char *who, \ else: flag = "RECV" - if conversation_cbs.has_key("write-im"): + if "write-im" in conversation_cbs: ( conversation_cbs["write-im"])(username, sender, \ - sender_alias, message, flag) + sender_alias, message, flag) cdef void write_conv(conversation.PurpleConversation *conv, const_char *name, \ const_char *alias, const_char *message, \ @@ -125,7 +127,7 @@ cdef void write_conv(conversation.PurpleConversation *conv, const_char *name, \ @see purple_conversation_write() """ debug.purple_debug_info("conversation", "%s", "write-conv\n") - if conversation_cbs.has_key("write-conv"): + if "write-conv" in conversation_cbs: ( conversation_cbs["write-conv"])("write-conv: TODO") cdef void chat_add_users(conversation.PurpleConversation *conv, \ @@ -139,7 +141,7 @@ cdef void chat_add_users(conversation.PurpleConversation *conv, \ @see purple_conv_chat_add_users() """ debug.purple_debug_info("conversation", "%s", "chat-add-users\n") - if conversation_cbs.has_key("chat-add-users"): + if "chat-add-users" in conversation_cbs: ( conversation_cbs["chat-add-users"])("chat-add-users: TODO") cdef void chat_rename_user(conversation.PurpleConversation *conv, \ @@ -152,8 +154,9 @@ cdef void chat_rename_user(conversation.PurpleConversation *conv, \ @see purple_conv_chat_rename_user() """ debug.purple_debug_info("conversation", "%s", "chat-rename-user\n") - if conversation_cbs.has_key("chat-rename-user"): - ( conversation_cbs["chat-rename-user"])("chat-rename-user: TODO") + if "chat-rename-user" in conversation_cbs: + ( conversation_cbs["chat-rename-user"]) \ + ("chat-rename-user: TODO") cdef void chat_remove_users(conversation.PurpleConversation *conv, \ glib.GList *users): @@ -162,8 +165,9 @@ cdef void chat_remove_users(conversation.PurpleConversation *conv, \ @param users A GList of const char *s. """ debug.purple_debug_info("conversation", "%s", "chat-remove-users\n") - if conversation_cbs.has_key("chat-remove-users"): - ( conversation_cbs["chat-remove-users"])("chat-remove-users: TODO") + if "chat-remove-users" in conversation_cbs: + ( conversation_cbs["chat-remove-users"]) \ + ("chat-remove-users: TODO") cdef void chat_update_user(conversation.PurpleConversation *conv, \ const_char *user): @@ -172,8 +176,9 @@ cdef void chat_update_user(conversation.PurpleConversation *conv, \ @see purple_conv_chat_user_set_flags() """ debug.purple_debug_info("conversation", "%s", "chat-update-user\n") - if conversation_cbs.has_key("chat-update-user"): - ( conversation_cbs["chat-update-user"])("chat-update-user: TODO") + if "chat-update-user" in conversation_cbs: + ( conversation_cbs["chat-update-user"]) \ + ("chat-update-user: TODO") cdef void present(conversation.PurpleConversation *conv): """ @@ -181,7 +186,7 @@ cdef void present(conversation.PurpleConversation *conv): dialog. """ debug.purple_debug_info("conversation", "%s", "present\n") - if conversation_cbs.has_key("present"): + if "present" in conversation_cbs: ( conversation_cbs["present"])("present: TODO") cdef glib.gboolean has_focus(conversation.PurpleConversation *conv): @@ -190,7 +195,7 @@ cdef glib.gboolean has_focus(conversation.PurpleConversation *conv): conversation has the focus, return TRUE; otherwise, return FALSE. """ debug.purple_debug_info("conversation", "%s", "has-focus\n") - if conversation_cbs.has_key("has-focus"): + if "has-focus" in conversation_cbs: ( conversation_cbs["has-focus"])("has-focus: TODO") return False @@ -200,8 +205,9 @@ cdef glib.gboolean custom_smiley_add(conversation.PurpleConversation *conv, \ Custom smileys (add). """ debug.purple_debug_info("conversation", "%s", "custom-smiley-add\n") - if conversation_cbs.has_key("custom-smiley-add"): - ( conversation_cbs["custom-smiley-add"])("custom-smiley-add: TODO") + if "custom-smiley-add" in conversation_cbs: + ( conversation_cbs["custom-smiley-add"]) \ + ("custom-smiley-add: TODO") return False cdef void custom_smiley_write(conversation.PurpleConversation *conv, \ @@ -210,8 +216,9 @@ cdef void custom_smiley_write(conversation.PurpleConversation *conv, \ Custom smileys (write). """ debug.purple_debug_info("conversation", "%s", "custom-smiley-write\n") - if conversation_cbs.has_key("custom-smiley-write"): - ( conversation_cbs["custom-smiley-write"])("custom-smiley-write: TODO") + if "custom-smiley-write" in conversation_cbs: + ( conversation_cbs["custom-smiley-write"]) \ + ("custom-smiley-write: TODO") cdef void custom_smiley_close(conversation.PurpleConversation *conv, \ const_char *smile): @@ -219,8 +226,9 @@ cdef void custom_smiley_close(conversation.PurpleConversation *conv, \ Custom smileys (close). """ debug.purple_debug_info("conversation", "%s", "custom-smiley-close\n") - if conversation_cbs.has_key("custom-smiley-close"): - ( conversation_cbs["custom-smiley-close"])("custom-smiley-close: TODO") + if "custom-smiley-close" in conversation_cbs: + ( conversation_cbs["custom-smiley-close"]) \ + ("custom-smiley-close: TODO") cdef void send_confirm(conversation.PurpleConversation *conv, \ const_char *message): @@ -230,5 +238,5 @@ cdef void send_confirm(conversation.PurpleConversation *conv, \ is NULL, libpurple will fall back to using purple_request_action(). """ debug.purple_debug_info("conversation", "%s", "send-confirm\n") - if conversation_cbs.has_key("send-confirm"): + if "send-confirm" in conversation_cbs: ( conversation_cbs["send-confirm"])("send-confirm: TODO") diff --git a/notify_cbs.pxd b/notify_cbs.pxd index f23bb0e..bdb8da7 100644 --- a/notify_cbs.pxd +++ b/notify_cbs.pxd @@ -31,7 +31,7 @@ cdef void *notify_message(notify.PurpleNotifyMsgType type, \ TODO """ debug.purple_debug_info("notify", "%s", "notify-message\n") - if notify_cbs.has_key("notif-message"): + if "notify-message" in notify_cbs: ( notify_cbs["notify-message"])("notify-message: TODO") cdef void *notify_email(connection.PurpleConnection *gc, \ @@ -41,7 +41,7 @@ cdef void *notify_email(connection.PurpleConnection *gc, \ TODO """ debug.purple_debug_info("notify", "%s", "notify-email\n") - if notify_cbs.has_key("notify-email"): + if "notify-email" in notify_cbs: ( notify_cbs["notify-email"])("notify-email: TODO") cdef void *notify_emails(connection.PurpleConnection *gc, size_t count, \ @@ -51,7 +51,7 @@ cdef void *notify_emails(connection.PurpleConnection *gc, size_t count, \ TODO """ debug.purple_debug_info("notify", "%s", "notify-emails\n") - if notify_cbs.has_key("notify-emails"): + if "notify-emails" in notify_cbs: ( notify_cbs["notify-emails"])("notify-emails: TODO") cdef void *notify_formatted(const_char *title, const_char *primary, \ @@ -60,7 +60,7 @@ cdef void *notify_formatted(const_char *title, const_char *primary, \ TODO """ debug.purple_debug_info("notify", "%s", "notify-formatted\n") - if notify_cbs.has_key("notify-formatted"): + if "notify-formatted" in notify_cbs: ( notify_cbs["notify-formatted"])("notify-formatted: TODO") cdef void *notify_searchresults(connection.PurpleConnection *gc, \ @@ -70,8 +70,9 @@ cdef void *notify_searchresults(connection.PurpleConnection *gc, \ TODO """ debug.purple_debug_info("notify", "%s", "notify-searchresults\n") - if notify_cbs.has_key("notify-searchresults"): - ( notify_cbs["notify-searchresults"])("notify-searchresults: TODO") + if "notify-searchresults" in notify_cbs: + ( notify_cbs["notify-searchresults"]) \ + ("notify-searchresults: TODO") cdef void notify_searchresults_new_rows(connection.PurpleConnection *gc, \ notify.PurpleNotifySearchResults *results, void *data): @@ -79,8 +80,9 @@ cdef void notify_searchresults_new_rows(connection.PurpleConnection *gc, \ TODO """ debug.purple_debug_info("notify", "%s", "notify-searchresults-new-rows\n") - if notify_cbs.has_key("notify-searchresults-new-rows"): - ( notify_cbs["notify-searchresults-new-rows"])("notify-searchresults-new-rows: TODO") + if "notify-searchresults-new-rows" in notify_cbs: + ( notify_cbs["notify-searchresults-new-rows"]) \ + ("notify-searchresults-new-rows: TODO") cdef void *notify_userinfo(connection.PurpleConnection *gc, const_char *who, \ notify.PurpleNotifyUserInfo *user_info): @@ -88,7 +90,7 @@ cdef void *notify_userinfo(connection.PurpleConnection *gc, const_char *who, \ TODO """ debug.purple_debug_info("notify", "%s", "notify-userinfo\n") - if notify_cbs.has_key("notify-userinfo"): + if "notify-userinfo" in notify_cbs: ( notify_cbs["notify-userinfo"])("notify-userinfo: TODO") cdef void *notify_uri(const_char *uri): @@ -96,7 +98,7 @@ cdef void *notify_uri(const_char *uri): TODO """ debug.purple_debug_info("notify", "%s", "notify-uri\n") - if notify_cbs.has_key("notify-uri"): + if "notify-uri" in notify_cbs: ( notify_cbs["notify-uri"])("notify-uri: TODO") cdef void close_notify(notify.PurpleNotifyType type, void *ui_handle): @@ -104,5 +106,5 @@ cdef void close_notify(notify.PurpleNotifyType type, void *ui_handle): TODO """ debug.purple_debug_info("notify", "%s", "close-notify\n") - if notify_cbs.has_key("close-notify"): + if "close-notify" in notify_cbs: ( notify_cbs["close-notify"])("close-notify: TODO") diff --git a/nullclient-ecore.py b/nullclient-ecore.py index 1f7d844..fff3d59 100644 --- a/nullclient-ecore.py +++ b/nullclient-ecore.py @@ -318,7 +318,7 @@ class NullClient(object): def __update_blist_cb(self, type, name=None, alias=None): if self.account and name and type == 2: - if not self.buddies.has_key(name): + if name not in self.buddies: self.buddies[name] = purple.Buddy(name, self.account) if self.buddies[name].online: self.window.add_buddy(name) @@ -361,7 +361,7 @@ class NullClient(object): self.window.show() def __buddy_signed_off_cb(self, name, alias): - if self.buddies.has_key(name): + if name in self.buddies: del self.buddies[name] if self.window: @@ -386,7 +386,7 @@ class NullClient(object): def send_message(self, name, message): print name, message - if not self.conversations.has_key(name): + if name not in self.conversations: self.conversations[name] = purple.Conversation('IM', self.account, name) self.conversations[name].new() diff --git a/plugin.pyx b/plugin.pyx index c5b5f93..57c7e9d 100644 --- a/plugin.pyx +++ b/plugin.pyx @@ -169,7 +169,7 @@ cdef class Plugin: iter = iter.next - if not po.has_key(sett) or not po[sett]: + if sett not in po or po[sett] == None: continue if type == prefs.PURPLE_PREF_STRING: diff --git a/proxy.pyx b/proxy.pyx index 7deb3ac..13a1bdd 100644 --- a/proxy.pyx +++ b/proxy.pyx @@ -110,25 +110,25 @@ cdef class ProxyInfo: c_proxyinfo = proxy.c_purple_proxy_info_new() account.purple_account_set_proxy_info(c_account, c_proxyinfo) - if info.has_key('type') and info['type']: + if 'type' in info and info['type']: type = info['type'] - if not type in self.types.keys(): + if not type in self.types: type = 'HTTP' proxy.c_purple_proxy_info_set_type(c_proxyinfo, self.types[type]) - if info.has_key('host') and info['host']: + if 'host' in info and info['host']: host = info['host'] proxy.c_purple_proxy_info_set_host(c_proxyinfo, host) - if info.has_key('port') and info['port']: + if 'port' in info and info['port']: port = int(info['port']) proxy.c_purple_proxy_info_set_port(c_proxyinfo, port) - if info.has_key('username') and info['username']: + if 'username' in info and info['username']: username = info['username'] proxy.c_purple_proxy_info_set_username(c_proxyinfo, username) - if info.has_key('password') and info['password']: + if 'password' in info and info['password']: password = info['password'] proxy.c_purple_proxy_info_set_password(c_proxyinfo, password) diff --git a/request_cbs.pxd b/request_cbs.pxd index fd98e02..e45bc24 100644 --- a/request_cbs.pxd +++ b/request_cbs.pxd @@ -44,7 +44,7 @@ cdef void *request_input(const_char *title, const_char *primary, \ @see purple_request_input(). """ debug.purple_debug_info("request", "%s", "request-input\n") - if request_cbs.has_key("request-input"): + if "request-input" in request_cbs: ( request_cbs["request-input"])("request-input: TODO") cdef void *request_choice(const_char *title, const_char *primary, \ @@ -57,7 +57,7 @@ cdef void *request_choice(const_char *title, const_char *primary, \ @see purple_request_choice_varg(). """ debug.purple_debug_info("request", "%s", "request-choice\n") - if request_cbs.has_key("request-choice"): + if "request-choice" in request_cbs: ( request_cbs["request-choice"])("request-choice: TODO") cdef void __call_action(int i): @@ -99,10 +99,10 @@ cdef void *request_action(const_char *title, const_char *primary, \ i = i + 1 debug.purple_debug_info("request", "%s", "request-action\n") - if request_cbs.has_key("request-action"): - ( request_cbs["request-action"])( title, - primary, secondary, - default_action, req_actions_list) + if "request-action" in request_cbs: + ( request_cbs["request-action"]) \ + ( title, primary, secondary, \ + default_action, req_actions_list) cdef void *request_fields(const_char *title, const_char *primary, \ const_char *secondary, request.PurpleRequestFields *fields, \ @@ -114,7 +114,7 @@ cdef void *request_fields(const_char *title, const_char *primary, \ @see purple_request_fields(). """ debug.purple_debug_info("request", "%s", "request-fields\n") - if request_cbs.has_key("request-fields"): + if "request-fields" in request_cbs: ( request_cbs["request-fields"])("request-fields: TODO") cdef void *request_file(const_char *title, const_char *filename, \ @@ -126,7 +126,7 @@ cdef void *request_file(const_char *title, const_char *filename, \ @see purple_request_file(). """ debug.purple_debug_info("request", "%s", "request-file\n") - if request_cbs.has_key("request-file"): + if "request-file" in request_cbs: ( request_cbs["request-file"])("request-file: TODO") cdef void close_request(request.PurpleRequestType type, void *ui_handle): @@ -134,7 +134,7 @@ cdef void close_request(request.PurpleRequestType type, void *ui_handle): TODO """ debug.purple_debug_info("request", "%s", "close-request\n") - if request_cbs.has_key("close-request"): + if "close-request" in request_cbs: ( request_cbs["close-request"])("close-request: TODO") cdef void *request_folder(const_char *title, const_char *dirname, \ @@ -145,5 +145,5 @@ cdef void *request_folder(const_char *title, const_char *dirname, \ @see purple_request_folder(). """ debug.purple_debug_info("request", "%s", "request-folder\n") - if request_cbs.has_key("request-folder"): + if "request-folder" in request_cbs: ( request_cbs["request-folder"])("request-folder: TODO") diff --git a/signal_cbs.pxd b/signal_cbs.pxd index ed1ab71..81a064d 100644 --- a/signal_cbs.pxd +++ b/signal_cbs.pxd @@ -46,7 +46,7 @@ cdef void signal_signed_on_cb(connection.PurpleConnection *gc, \ else: protocol_id = c_protocol_id - if signal_cbs.has_key("signed-on"): + if "signed-on" in signal_cbs: ( signal_cbs["signed-on"])(username, protocol_id) cdef void signal_signed_off_cb(connection.PurpleConnection *gc, \ @@ -71,7 +71,7 @@ cdef void signal_signed_off_cb(connection.PurpleConnection *gc, \ else: protocol_id = c_protocol_id - if signal_cbs.has_key("signed-off"): + if "signed-off" in signal_cbs: ( signal_cbs["signed-off"])(username, protocol_id) cdef void signal_connection_error_cb(connection.PurpleConnection *gc, \ @@ -122,7 +122,7 @@ cdef void signal_connection_error_cb(connection.PurpleConnection *gc, \ else: desc = None - if signal_cbs.has_key("connection-error"): + if "connection-error" in signal_cbs: ( signal_cbs["connection-error"])(username, protocol_id, \ short_desc, desc) @@ -146,7 +146,7 @@ cdef void signal_buddy_signed_on_cb(blist.PurpleBuddy *buddy): else: alias = c_alias - if signal_cbs.has_key("buddy-signed-on"): + if "buddy-signed-on" in signal_cbs: ( signal_cbs["buddy-signed-on"])(name, alias) cdef void signal_buddy_signed_off_cb(blist.PurpleBuddy *buddy): @@ -169,7 +169,7 @@ cdef void signal_buddy_signed_off_cb(blist.PurpleBuddy *buddy): else: alias = c_alias - if signal_cbs.has_key("buddy-signed-off"): + if "buddy-signed-off" in signal_cbs: ( signal_cbs["buddy-signed-off"])(name, alias) cdef glib.gboolean signal_receiving_im_msg_cb(account.PurpleAccount *account, \ @@ -198,7 +198,7 @@ cdef glib.gboolean signal_receiving_im_msg_cb(account.PurpleAccount *account, \ stripped = util.purple_markup_strip_html(message[0]) - if signal_cbs.has_key("receiving-im-msg"): + if "receiving-im-msg" in signal_cbs: return ( signal_cbs["receiving-im-msg"])(sender[0], alias, stripped) cdef void jabber_receiving_xmlnode_cb(connection.PurpleConnection *gc, \ @@ -208,5 +208,5 @@ cdef void jabber_receiving_xmlnode_cb(connection.PurpleConnection *gc, \ """ message = xmlnode.xmlnode_to_str(packet[0], NULL) - if signal_cbs.has_key("jabber-receiving-xmlnode"): + if "jabber-receiving-xmlnode" in signal_cbs: ( signal_cbs["jabber-receiving-xmlnode"])(message)