Merge branch 'revert-types' into 'master'

Revert "Bookmarks: type bookmark method (local/remote)"

See merge request poezio/poezio!140
This commit is contained in:
Maxime Buquet 2020-05-31 03:57:12 +02:00
commit fe9992e3e8
2 changed files with 6 additions and 8 deletions

View file

@ -30,7 +30,7 @@ Adding a remote bookmark:
import functools import functools
import logging import logging
from typing import Optional, List, Literal, Union from typing import Optional, List, Union
from slixmpp import InvalidJID, JID from slixmpp import InvalidJID, JID
from slixmpp.plugins.xep_0048 import Bookmarks, Conference, URL from slixmpp.plugins.xep_0048 import Bookmarks, Conference, URL
@ -39,8 +39,6 @@ from poezio.config import config
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
Method = Union[Literal['local'], Literal['remote']]
class Bookmark: class Bookmark:
def __init__(self, def __init__(self,
jid: Union[JID, str], jid: Union[JID, str],
@ -48,7 +46,7 @@ class Bookmark:
autojoin=False, autojoin=False,
nick: Optional[str] = None, nick: Optional[str] = None,
password: Optional[str] = None, password: Optional[str] = None,
method: Method = 'local') -> None: method='local') -> None:
try: try:
if isinstance(jid, JID): if isinstance(jid, JID):
self._jid = jid self._jid = jid
@ -84,7 +82,7 @@ class Bookmark:
return self._method return self._method
@method.setter @method.setter
def method(self, value: Method): def method(self, value: str):
if value not in ('local', 'remote'): if value not in ('local', 'remote'):
log.debug('Could not set bookmark storing method: %s', value) log.debug('Could not set bookmark storing method: %s', value)
return return

View file

@ -18,7 +18,7 @@ from poezio import common
from poezio import pep from poezio import pep
from poezio import tabs from poezio import tabs
from poezio import multiuserchat as muc from poezio import multiuserchat as muc
from poezio.bookmarks import Bookmark, Method as BookmarkMethod from poezio.bookmarks import Bookmark
from poezio.common import safeJID from poezio.common import safeJID
from poezio.config import config, DEFAULT_CONFIG, options as config_opts from poezio.config import config, DEFAULT_CONFIG, options as config_opts
from poezio.contact import Contact, Resource from poezio.contact import Contact, Resource
@ -444,7 +444,7 @@ class CommandCore:
self._add_bookmark(jid, autojoin, password, 'remote') self._add_bookmark(jid, autojoin, password, 'remote')
def _add_bookmark(self, jid: str, autojoin: bool, password: str, method: BookmarkMethod) -> None: def _add_bookmark(self, jid, autojoin, password, method):
nick = None nick = None
if not jid: if not jid:
tab = self.core.tabs.current_tab tab = self.core.tabs.current_tab
@ -478,7 +478,7 @@ class CommandCore:
self.core.bookmarks.save_remote(self.core.xmpp, self.core.bookmarks.save_remote(self.core.xmpp,
self.core.handler.on_bookmark_result) self.core.handler.on_bookmark_result)
def _add_wildcard_bookmarks(self, method: BookmarkMethod): def _add_wildcard_bookmarks(self, method):
new_bookmarks = [] new_bookmarks = []
for tab in self.core.get_tabs(tabs.MucTab): for tab in self.core.get_tabs(tabs.MucTab):
bookmark = self.core.bookmarks[tab.jid.bare] bookmark = self.core.bookmarks[tab.jid.bare]