From c61bd6560785c037d13ec671196a93152984463d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Tue, 20 Nov 2018 10:04:54 +0100 Subject: [PATCH] Simplify PEP module inits --- gajim/common/modules/atom.py | 5 ----- gajim/common/modules/pep.py | 8 ++++---- gajim/common/modules/user_activity.py | 8 -------- gajim/common/modules/user_avatar.py | 8 -------- gajim/common/modules/user_location.py | 10 ---------- gajim/common/modules/user_mood.py | 8 -------- gajim/common/modules/user_nickname.py | 8 -------- gajim/common/modules/user_tune.py | 8 -------- 8 files changed, 4 insertions(+), 59 deletions(-) diff --git a/gajim/common/modules/atom.py b/gajim/common/modules/atom.py index d22bd5dc1..b987a6dbc 100644 --- a/gajim/common/modules/atom.py +++ b/gajim/common/modules/atom.py @@ -58,11 +58,6 @@ class Atom(AbstractPEPModule): store_publish = False _log = log - def __init__(self, con): - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] - def _extract_info(self, item): entry = item.getTag('entry', namespace=nbxmpp.NS_ATOM) if entry is None: diff --git a/gajim/common/modules/pep.py b/gajim/common/modules/pep.py index 9f9d1a333..c56b63128 100644 --- a/gajim/common/modules/pep.py +++ b/gajim/common/modules/pep.py @@ -153,11 +153,11 @@ class AbstractPEPModule: store_publish = True _log = log - def __init__(self, - con: ConnectionT, - account: str) -> None: - self._account = account + def __init__(self, con: ConnectionT) -> None: self._con = con + self._account = con.name + + self.handlers = [] # type: List[Tuple[Any, ...]] self._stored_publish = None diff --git a/gajim/common/modules/user_activity.py b/gajim/common/modules/user_activity.py index f7c53ab83..079607e59 100644 --- a/gajim/common/modules/user_activity.py +++ b/gajim/common/modules/user_activity.py @@ -30,9 +30,6 @@ class UserActivityData(AbstractPEPData): type_ = PEPEventType.ACTIVITY - def __init__(self, activity): - self.data = activity - def as_markup_text(self): pep = self.data activity = pep['activity'] @@ -62,11 +59,6 @@ class UserActivity(AbstractPEPModule): store_publish = True _log = log - def __init__(self, con): - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] - def _extract_info(self, item): activity_dict = {} activity_tag = item.getTag('activity', namespace=self.namespace) diff --git a/gajim/common/modules/user_avatar.py b/gajim/common/modules/user_avatar.py index 82d3ba1e4..e29283780 100644 --- a/gajim/common/modules/user_avatar.py +++ b/gajim/common/modules/user_avatar.py @@ -32,9 +32,6 @@ class UserAvatarData(AbstractPEPData): type_ = PEPEventType.AVATAR - def __init__(self, avatar): - self.data = avatar - class UserAvatar(AbstractPEPModule): @@ -44,11 +41,6 @@ class UserAvatar(AbstractPEPModule): store_publish = False _log = log - def __init__(self, con): - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] - def get_pubsub_avatar(self, jid, item_id): log.info('Request: %s %s', jid, item_id) self._con.get_module('PubSub').send_pb_retrieve( diff --git a/gajim/common/modules/user_location.py b/gajim/common/modules/user_location.py index b55d1ac15..e73d610b1 100644 --- a/gajim/common/modules/user_location.py +++ b/gajim/common/modules/user_location.py @@ -30,11 +30,6 @@ class UserLocationData(AbstractPEPData): type_ = PEPEventType.LOCATION - def __init__(self, location): - # set_location plugin uses self._pep_specific_data - self._pep_specific_data = location - self.data = location - def as_markup_text(self): location = self.data location_string = '' @@ -58,11 +53,6 @@ class UserLocation(AbstractPEPModule): store_publish = True _log = log - def __init__(self, con): - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] - def _extract_info(self, item): location_dict = {} location_tag = item.getTag('geoloc', namespace=nbxmpp.NS_LOCATION) diff --git a/gajim/common/modules/user_mood.py b/gajim/common/modules/user_mood.py index e36ea5a41..e237dd306 100644 --- a/gajim/common/modules/user_mood.py +++ b/gajim/common/modules/user_mood.py @@ -37,9 +37,6 @@ class UserMoodData(AbstractPEPData): type_ = PEPEventType.MOOD - def __init__(self, mood: Optional[Dict[str, str]]) -> None: - self.data = mood - def as_markup_text(self) -> str: if self.data is None: return '' @@ -65,11 +62,6 @@ class UserMood(AbstractPEPModule): store_publish = True _log = log - def __init__(self, con: ConnectionT) -> None: - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] # type: List[Tuple[Any, ...]] - def _extract_info(self, item: nbxmpp.Node) -> Optional[Dict[str, str]]: mood_dict = {} mood_tag = item.getTag('mood', namespace=nbxmpp.NS_MOOD) diff --git a/gajim/common/modules/user_nickname.py b/gajim/common/modules/user_nickname.py index f130b2222..b5ed70756 100644 --- a/gajim/common/modules/user_nickname.py +++ b/gajim/common/modules/user_nickname.py @@ -36,9 +36,6 @@ class UserNicknameData(AbstractPEPData): type_ = PEPEventType.NICKNAME - def __init__(self, nickname: Optional[str]) -> None: - self.data = nickname - def get_nick(self) -> str: return self.data or '' @@ -51,11 +48,6 @@ class UserNickname(AbstractPEPModule): store_publish = True _log = log - def __init__(self, con: ConnectionT) -> None: - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] # type: List[Tuple[Any, ...]] - def _extract_info(self, item: nbxmpp.Node) -> Optional[str]: nick = '' child = item.getTag('nick', namespace=nbxmpp.NS_NICK) diff --git a/gajim/common/modules/user_tune.py b/gajim/common/modules/user_tune.py index 55160c7f9..9359924e6 100644 --- a/gajim/common/modules/user_tune.py +++ b/gajim/common/modules/user_tune.py @@ -39,9 +39,6 @@ class UserTuneData(AbstractPEPData): type_ = PEPEventType.TUNE - def __init__(self, tune: Optional[Dict[str, str]]) -> None: - self.data = tune - def as_markup_text(self) -> str: if self.data is None: return '' @@ -72,11 +69,6 @@ class UserTune(AbstractPEPModule): store_publish = True _log = log - def __init__(self, con: ConnectionT) -> None: - AbstractPEPModule.__init__(self, con, con.name) - - self.handlers = [] # type: List[Tuple[Any, ...]] - def _extract_info(self, item: nbxmpp.Node) -> Optional[Dict[str, str]]: tune_dict = {} tune_tag = item.getTag('tune', namespace=self.namespace)