reorder: group exception handling

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2020-04-01 01:33:09 +02:00
parent 496752d0db
commit da695768b0
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -167,25 +167,22 @@ class Plugin(BasePlugin):
cls, jid = tabs_spec[pos] cls, jid = tabs_spec[pos]
try: try:
jid = JID(jid) jid = JID(jid)
except InvalidJID: tab = self.core.tabs.by_name_and_class(str(jid), cls=cls)
self.api.information('Reorder: Invalid JID \'%s\'.' % jid, 'Warning') if tab and tab in old_tabs:
continue new_tabs.append(tab)
tab = self.core.tabs.by_name_and_class(str(jid), cls=cls) old_tabs.remove(tab)
if tab and tab in old_tabs: else:
new_tabs.append(tab) self.api.information('Tab %s not found. Creating it' % jid, 'Warning')
old_tabs.remove(tab) # TODO: Add support for MucTab. Requires nickname.
else: if cls in (tabs.DynamicConversationTab, tabs.StaticConversationTab):
self.api.information('Tab %s not found. Creating it' % jid, 'Warning')
# TODO: Add support for MucTab. Requires nickname.
if cls in (tabs.DynamicConversationTab, tabs.StaticConversationTab):
try:
new_tab = cls(self.core, jid) new_tab = cls(self.core, jid)
new_tabs.append(new_tab) new_tabs.append(new_tab)
except: except:
self.api.information('Failed to create tab \'%s\'.' % jid, 'Error') self.api.information('Failed to create tab \'%s\'.' % jid, 'Error')
if create_gaps: if create_gaps:
new_tabs.append(tabs.GapTab(self.core)) new_tabs.append(tabs.GapTab(self.core))
last = pos finally:
last = pos
for tab in old_tabs: for tab in old_tabs:
if tab: if tab: