diff options
author | mathieui <mathieui@mathieui.net> | 2014-04-30 21:34:09 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-04-30 21:34:09 +0200 |
commit | bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677 (patch) | |
tree | 190e961ea1c516ad0127e1c82cddb5fee263e565 /src/core | |
parent | d859ec2ea19654603075b556094c6b59aad8e73a (diff) | |
download | poezio-bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677.tar.gz poezio-bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677.tar.bz2 poezio-bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677.tar.xz poezio-bbdc14aaa5a47e77ad46d1ad7b4465ac065d6677.zip |
Remove Tab.get_name() and use Tab.name instead
(keep a get_name() fallback just in case for now)
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/commands.py | 48 | ||||
-rw-r--r-- | src/core/completions.py | 18 | ||||
-rw-r--r-- | src/core/core.py | 18 | ||||
-rw-r--r-- | src/core/handlers.py | 6 |
4 files changed, 45 insertions, 45 deletions
diff --git a/src/core/commands.py b/src/core/commands.py index 1c728283..d4df1099 100644 --- a/src/core/commands.py +++ b/src/core/commands.py @@ -147,7 +147,7 @@ def command_presence(self, arg): else: return if jid == '.' and isinstance(self.current_tab(), tabs.ChatTab): - jid = self.current_tab().get_name() + jid = self.current_tab().name if type == 'available': type = None try: @@ -238,7 +238,7 @@ def command_move_tab(self, arg): except ValueError: old_tab = None for tab in self.tabs: - if not old_tab and value == tab.get_name(): + if not old_tab and value == tab.name: old_tab = tab if not old_tab: self.information("Tab %s does not exist" % args[0], "Error") @@ -269,7 +269,7 @@ def command_list(self, arg): else: if not isinstance(self.current_tab(), tabs.MucTab): return self.information('Please provide a server', 'Error') - server = safeJID(self.current_tab().get_name()).server + server = safeJID(self.current_tab().name).server list_tab = tabs.MucListTab(server) self.add_tab(list_tab, True) cb = list_tab.on_muc_list_item_received @@ -316,7 +316,7 @@ def command_join(self, arg, histo_length=None): tab = self.current_tab() if not isinstance(tab, (tabs.MucTab, tabs.PrivateTab)): return - room = safeJID(tab.get_name()).bare + room = safeJID(tab.name).bare nick = tab.own_nick else: if args[0].startswith('@'): # we try to join a server directly @@ -335,7 +335,7 @@ def command_join(self, arg, histo_length=None): tab = self.current_tab() if not isinstance(tab, tabs.MucTab): return - room = tab.get_name() + room = tab.name if nick == '': nick = tab.own_nick else: @@ -345,8 +345,8 @@ def command_join(self, arg, histo_length=None): # check if the current room's name has a server if room.find('@') == -1 and not server_root: if isinstance(self.current_tab(), tabs.MucTab) and\ - self.current_tab().get_name().find('@') != -1: - domain = safeJID(self.current_tab().get_name()).domain + self.current_tab().name.find('@') != -1: + domain = safeJID(self.current_tab().name).domain room += '@%s' % domain else: room = args[0] @@ -421,15 +421,15 @@ def command_bookmark_local(self, arg=''): return if not args: tab = self.current_tab() - roomname = tab.get_name() + roomname = tab.name if tab.joined and tab.own_nick != self.own_nick: nick = tab.own_nick elif args[0] == '*': new_bookmarks = [] for tab in self.get_tabs(tabs.MucTab): - b = bookmark.get_by_jid(tab.get_name()) + b = bookmark.get_by_jid(tab.name) if not b: - b = bookmark.Bookmark(tab.get_name(), + b = bookmark.Bookmark(tab.name, autojoin=True, method="local") new_bookmarks.append(b) @@ -451,7 +451,7 @@ def command_bookmark_local(self, arg=''): if not roomname: if not isinstance(self.current_tab(), tabs.MucTab): return - roomname = self.current_tab().get_name() + roomname = self.current_tab().name if len(args) > 1: password = args[1] @@ -485,7 +485,7 @@ def command_bookmark(self, arg=''): return if not args: tab = self.current_tab() - roomname = tab.get_name() + roomname = tab.name if tab.joined: nick = tab.own_nick autojoin = True @@ -497,9 +497,9 @@ def command_bookmark(self, arg=''): autojoin = True new_bookmarks = [] for tab in self.get_tabs(tabs.MucTab): - b = bookmark.get_by_jid(tab.get_name()) + b = bookmark.get_by_jid(tab.name) if not b: - b = bookmark.Bookmark(tab.get_name(), autojoin=autojoin, + b = bookmark.Bookmark(tab.name, autojoin=autojoin, method=bookmark.preferred) new_bookmarks.append(b) else: @@ -523,7 +523,7 @@ def command_bookmark(self, arg=''): if roomname == '': if not isinstance(self.current_tab(), tabs.MucTab): return - roomname = self.current_tab().get_name() + roomname = self.current_tab().name if len(args) > 1: autojoin = False if args[1].lower() != 'true' else True else: @@ -571,8 +571,8 @@ def command_remove_bookmark(self, arg=''): args = common.shell_split(arg) if not args: tab = self.current_tab() - if isinstance(tab, tabs.MucTab) and bookmark.get_by_jid(tab.get_name()): - bookmark.remove(tab.get_name()) + if isinstance(tab, tabs.MucTab) and bookmark.get_by_jid(tab.name): + bookmark.remove(tab.name) bookmark.save(self.xmpp) if bookmark.save(self.xmpp): self.information('Bookmark deleted', 'Info') @@ -643,22 +643,22 @@ def command_server_cycle(self, arg=''): message = args[1] else: if isinstance(tab, tabs.MucTab): - domain = safeJID(tab.get_name()).domain + domain = safeJID(tab.name).domain else: self.information(_("No server specified"), "Error") return for tab in self.get_tabs(tabs.MucTab): - if tab.get_name().endswith(domain): + if tab.name.endswith(domain): if tab.joined: muc.leave_groupchat(tab.core.xmpp, - tab.get_name(), + tab.name, tab.own_nick, message) tab.joined = False - if tab.get_name() == domain: - self.command_join('"@%s/%s"' %(tab.get_name(), tab.own_nick)) + if tab.name == domain: + self.command_join('"@%s/%s"' %(tab.name, tab.own_nick)) else: - self.command_join('"%s/%s"' %(tab.get_name(), tab.own_nick)) + self.command_join('"%s/%s"' %(tab.name, tab.own_nick)) def command_last_activity(self, arg): """ @@ -928,7 +928,7 @@ def command_message(self, arg): if not tab: tab = self.open_conversation_window(jid.full, focus=True) else: - self.focus_tab_named(tab.get_name()) + self.focus_tab_named(tab.name) if len(args) > 1: tab.command_say(args[1]) diff --git a/src/core/completions.py b/src/core/completions.py index 5387eefd..f8fb7fc8 100644 --- a/src/core/completions.py +++ b/src/core/completions.py @@ -98,7 +98,7 @@ def completion_join(self, the_input): relevant_rooms.extend(sorted(self.pending_invites.keys())) bookmarks = {str(elem.jid): False for elem in bookmark.bookmarks} for tab in self.get_tabs(tabs.MucTab): - name = tab.get_name() + name = tab.name if name in bookmarks and not tab.joined: bookmarks[name] = True relevant_rooms.extend(sorted(room[0] for room in bookmarks.items() if room[1])) @@ -126,7 +126,7 @@ def completion_join(self, the_input): serv_list = [] for tab in self.get_tabs(tabs.MucTab): if tab.joined: - serv_list.append('%s@%s'% (jid.user, safeJID(tab.get_name()).host)) + serv_list.append('%s@%s'% (jid.user, safeJID(tab.name).host)) serv_list.extend(relevant_rooms) return the_input.new_completion(serv_list, 1, quotify=True) elif args[1].startswith('/'): @@ -147,8 +147,8 @@ def completion_list(self, the_input): """Completion for /list""" muc_serv_list = [] for tab in self.get_tabs(tabs.MucTab): # TODO, also from an history - if tab.get_name() not in muc_serv_list: - muc_serv_list.append(safeJID(tab.get_name()).server) + if tab.name not in muc_serv_list: + muc_serv_list.append(safeJID(tab.name).server) if muc_serv_list: return the_input.new_completion(muc_serv_list, 1, quotify=False) @@ -157,7 +157,7 @@ def completion_move_tab(self, the_input): """Completion for /move_tab""" n = the_input.get_argument_position(quoted=True) if n == 1: - nodes = [tab.get_name() for tab in self.tabs if tab] + nodes = [tab.name for tab in self.tabs if tab] nodes.remove('Roster') return the_input.new_completion(nodes, 1, ' ', quotify=True) @@ -199,7 +199,7 @@ def completion_bookmark(self, the_input): nicks.append(nick) jids_list = ['%s/%s' % (jid.bare, nick) for nick in nicks] return the_input.new_completion(jids_list, 1, quotify=True) - muc_list = [tab.get_name() for tab in self.get_tabs(tabs.MucTab)] + muc_list = [tab.name for tab in self.get_tabs(tabs.MucTab)] muc_list.sort() muc_list.append('*') return the_input.new_completion(muc_list, 1, quotify=True) @@ -259,7 +259,7 @@ def completion_invite(self, the_input): rooms = [] for tab in self.get_tabs(tabs.MucTab): if tab.joined: - rooms.append(tab.get_name()) + rooms.append(tab.name) rooms.sort() return the_input.new_completion(rooms, n, '', quotify=True) @@ -300,7 +300,7 @@ def completion_server_cycle(self, the_input): """Completion for /server_cycle""" serv_list = set() for tab in self.get_tabs(tabs.MucTab): - serv = safeJID(tab.get_name()).server + serv = safeJID(tab.name).server serv_list.add(serv) return the_input.new_completion(sorted(serv_list), 1, ' ') @@ -380,7 +380,7 @@ def completion_bookmark_local(self, the_input): nicks.append(nick) jids_list = ['%s/%s' % (jid.bare, nick) for nick in nicks] return the_input.new_completion(jids_list, 1, quotify=True) - muc_list = [tab.get_name() for tab in self.get_tabs(tabs.MucTab)] + muc_list = [tab.name for tab in self.get_tabs(tabs.MucTab)] muc_list.append('*') return the_input.new_completion(muc_list, 1, quotify=True) diff --git a/src/core/core.py b/src/core/core.py index 4ffb0213..805cd838 100644 --- a/src/core/core.py +++ b/src/core/core.py @@ -902,7 +902,7 @@ class Core(object): If typ is provided, return a tab of this type only """ for tab in self.tabs: - if tab.get_name() == name: + if tab.name == name: if (typ and isinstance(tab, typ)) or\ not typ: return tab @@ -1081,7 +1081,7 @@ class Core(object): def focus_tab_named(self, tab_name, type_=None): """Returns True if it found a tab to focus on""" for tab in self.tabs: - if tab.get_name() == tab_name: + if tab.name == tab_name: if (type_ and (isinstance(tab, type_))) or not type_: self.command_win('%s' % (tab.nb,)) return True @@ -1133,7 +1133,7 @@ class Core(object): complete_jid = room_name+'/'+user_nick # if the room exists, focus it and return for tab in self.get_tabs(tabs.PrivateTab): - if tab.get_name() == complete_jid: + if tab.name == complete_jid: self.command_win('%s' % tab.nb) return tab # create the new tab @@ -1206,7 +1206,7 @@ class Core(object): if reason is None: reason = _('\x195}You left the chatroom\x193}') for tab in self.get_tabs(tabs.PrivateTab): - if tab.get_name().startswith(room_name): + if tab.name.startswith(room_name): tab.deactivate(reason=reason) def enable_private_tabs(self, room_name, reason=None): @@ -1216,7 +1216,7 @@ class Core(object): if reason is None: reason = _('\x195}You joined the chatroom\x193}') for tab in self.get_tabs(tabs.PrivateTab): - if tab.get_name().startswith(room_name): + if tab.name.startswith(room_name): tab.activate(reason=reason) def on_user_changed_status_in_private(self, jid, msg): @@ -1246,10 +1246,10 @@ class Core(object): self.tabs[nb] = tabs.GapTab() else: self.tabs.remove(tab) - if tab and tab.get_name() in logger.fds: - logger.fds[tab.get_name()].close() - log.debug("Log file for %s closed.", tab.get_name()) - del logger.fds[tab.get_name()] + if tab and tab.name in logger.fds: + logger.fds[tab.name].close() + log.debug("Log file for %s closed.", tab.name) + del logger.fds[tab.name] if self.current_tab_nb >= len(self.tabs): self.current_tab_nb = len(self.tabs) - 1 while not self.tabs[self.current_tab_nb]: diff --git a/src/core/handlers.py b/src/core/handlers.py index ad696eb1..45a4ff2a 100644 --- a/src/core/handlers.py +++ b/src/core/handlers.py @@ -161,7 +161,7 @@ def on_message(self, message): # Differentiate both type of messages, and call the appropriate handler. jid_from = message['from'] for tab in self.get_tabs(tabs.MucTab): - if tab.get_name() == jid_from.bare: + if tab.name == jid_from.bare: if message['type'] == 'error': return self.room_error(message, jid_from) else: @@ -1003,12 +1003,12 @@ def on_attention(self, message): jid_from = message['from'] self.information('%s requests your attention!' % jid_from, 'Info') for tab in self.tabs: - if tab.get_name() == jid_from: + if tab.name == jid_from: tab.state = 'attention' self.refresh_tab_win() return for tab in self.tabs: - if tab.get_name() == jid_from.bare: + if tab.name == jid_from.bare: tab.state = 'attention' self.refresh_tab_win() return |