code style reformatting using black
This commit is contained in:
parent
4127bcffd0
commit
744cb0c503
1 changed files with 21394 additions and 10488 deletions
|
|
@ -57,8 +57,12 @@ class FakeMUCClient(object):
|
|||
if other_profile == profile:
|
||||
continue
|
||||
try:
|
||||
other_room = self.plugin_parent.clients[other_profile].joined_rooms[room_jid]
|
||||
roster.setdefault(other_room.nick, User(other_room.nick, C.PROFILE_DICT[other_profile]))
|
||||
other_room = self.plugin_parent.clients[other_profile].joined_rooms[
|
||||
room_jid
|
||||
]
|
||||
roster.setdefault(
|
||||
other_room.nick, User(other_room.nick, C.PROFILE_DICT[other_profile])
|
||||
)
|
||||
for other_nick in other_room.roster:
|
||||
roster.setdefault(other_nick, other_room.roster[other_nick])
|
||||
except (AttributeError, KeyError):
|
||||
|
|
@ -80,8 +84,12 @@ class FakeMUCClient(object):
|
|||
if other_profile == profile:
|
||||
continue
|
||||
try:
|
||||
other_room = self.plugin_parent.clients[other_profile].joined_rooms[room_jid]
|
||||
other_room.roster.setdefault(room.nick, User(room.nick, C.PROFILE_DICT[profile]))
|
||||
other_room = self.plugin_parent.clients[other_profile].joined_rooms[
|
||||
room_jid
|
||||
]
|
||||
other_room.roster.setdefault(
|
||||
room.nick, User(room.nick, C.PROFILE_DICT[profile])
|
||||
)
|
||||
except (AttributeError, KeyError):
|
||||
pass
|
||||
|
||||
|
|
@ -101,7 +109,9 @@ class FakeMUCClient(object):
|
|||
if other_profile == profile:
|
||||
continue
|
||||
try:
|
||||
other_room = self.plugin_parent.clients[other_profile].joined_rooms[roomJID]
|
||||
other_room = self.plugin_parent.clients[other_profile].joined_rooms[
|
||||
roomJID
|
||||
]
|
||||
del other_room.roster[room.nick]
|
||||
except (AttributeError, KeyError):
|
||||
pass
|
||||
|
|
@ -110,14 +120,13 @@ class FakeMUCClient(object):
|
|||
|
||||
|
||||
class FakeXEP_0045(plugin_xep_0045.XEP_0045):
|
||||
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
self.clients = {}
|
||||
for profile in C.PROFILE:
|
||||
self.clients[profile] = FakeMUCClient(self)
|
||||
|
||||
def join(self, room_jid, nick, options={}, profile_key='@DEFAULT@'):
|
||||
def join(self, room_jid, nick, options={}, profile_key="@DEFAULT@"):
|
||||
"""
|
||||
@param roomJID: the room JID
|
||||
@param nick: nick to be used in the room
|
||||
|
|
@ -140,7 +149,7 @@ class FakeXEP_0045(plugin_xep_0045.XEP_0045):
|
|||
self.join(muc_jid, nick, profile_key=profile)
|
||||
return self.getNick(muc_index, user_index)
|
||||
|
||||
def leave(self, room_jid, profile_key='@DEFAULT@'):
|
||||
def leave(self, room_jid, profile_key="@DEFAULT@"):
|
||||
"""
|
||||
@param roomJID: the room JID
|
||||
@param profile_key: the profile of the user leaving the room
|
||||
|
|
@ -174,7 +183,7 @@ class FakeXEP_0045(plugin_xep_0045.XEP_0045):
|
|||
try:
|
||||
return self.getRoomNick(C.MUC[muc_index], C.PROFILE[user_index])
|
||||
except (KeyError, AttributeError):
|
||||
return ''
|
||||
return ""
|
||||
|
||||
def getNickOfUser(self, muc_index, user_index, profile_index, secure=True):
|
||||
try:
|
||||
|
|
@ -185,11 +194,10 @@ class FakeXEP_0045(plugin_xep_0045.XEP_0045):
|
|||
|
||||
|
||||
class FakeXEP_0249(object):
|
||||
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
|
||||
def invite(self, target, room, options={}, profile_key='@DEFAULT@'):
|
||||
def invite(self, target, room, options={}, profile_key="@DEFAULT@"):
|
||||
"""
|
||||
Invite a user to a room. To accept the invitation from a test,
|
||||
just call FakeXEP_0045.joinRoom (no need to have a dedicated method).
|
||||
|
|
@ -202,15 +210,13 @@ class FakeXEP_0249(object):
|
|||
|
||||
|
||||
class FakeSatPubSubClient(object):
|
||||
|
||||
def __init__(self, host, parent_plugin):
|
||||
self.host = host
|
||||
self.parent_plugin = parent_plugin
|
||||
self.__items = OrderedDict()
|
||||
self.__rsm_responses = {}
|
||||
|
||||
def createNode(self, service, nodeIdentifier=None, options=None,
|
||||
sender=None):
|
||||
def createNode(self, service, nodeIdentifier=None, options=None, sender=None):
|
||||
return defer.succeed(None)
|
||||
|
||||
def deleteNode(self, service, nodeIdentifier, sender=None):
|
||||
|
|
@ -220,12 +226,17 @@ class FakeSatPubSubClient(object):
|
|||
pass
|
||||
return defer.succeed(None)
|
||||
|
||||
def subscribe(self, service, nodeIdentifier, subscriber,
|
||||
options=None, sender=None):
|
||||
def subscribe(self, service, nodeIdentifier, subscriber, options=None, sender=None):
|
||||
return defer.succeed(None)
|
||||
|
||||
def unsubscribe(self, service, nodeIdentifier, subscriber,
|
||||
subscriptionIdentifier=None, sender=None):
|
||||
def unsubscribe(
|
||||
self,
|
||||
service,
|
||||
nodeIdentifier,
|
||||
subscriber,
|
||||
subscriptionIdentifier=None,
|
||||
sender=None,
|
||||
):
|
||||
return defer.succeed(None)
|
||||
|
||||
def publish(self, service, nodeIdentifier, items=None, sender=None):
|
||||
|
|
@ -234,7 +245,7 @@ class FakeSatPubSubClient(object):
|
|||
def replace(item_obj):
|
||||
index = 0
|
||||
for current in node:
|
||||
if current['id'] == item_obj['id']:
|
||||
if current["id"] == item_obj["id"]:
|
||||
node[index] = item_obj
|
||||
return True
|
||||
index += 1
|
||||
|
|
@ -246,22 +257,30 @@ class FakeSatPubSubClient(object):
|
|||
node.append(item_obj)
|
||||
return defer.succeed(None)
|
||||
|
||||
def items(self, service, nodeIdentifier, maxItems=None, itemIdentifiers=None,
|
||||
subscriptionIdentifier=None, sender=None, ext_data=None):
|
||||
def items(
|
||||
self,
|
||||
service,
|
||||
nodeIdentifier,
|
||||
maxItems=None,
|
||||
itemIdentifiers=None,
|
||||
subscriptionIdentifier=None,
|
||||
sender=None,
|
||||
ext_data=None,
|
||||
):
|
||||
try:
|
||||
items = self.__items[nodeIdentifier]
|
||||
except KeyError:
|
||||
items = []
|
||||
if ext_data:
|
||||
assert('id' in ext_data)
|
||||
if 'rsm' in ext_data:
|
||||
args = (0, items[0]['id'], items[-1]['id']) if items else ()
|
||||
self.__rsm_responses[ext_data['id']] = RSMResponse(len(items), *args)
|
||||
assert "id" in ext_data
|
||||
if "rsm" in ext_data:
|
||||
args = (0, items[0]["id"], items[-1]["id"]) if items else ()
|
||||
self.__rsm_responses[ext_data["id"]] = RSMResponse(len(items), *args)
|
||||
return defer.succeed(items)
|
||||
|
||||
def retractItems(self, service, nodeIdentifier, itemIdentifiers, sender=None):
|
||||
node = self.__items[nodeIdentifier]
|
||||
for item in [item for item in node if item['id'] in itemIdentifiers]:
|
||||
for item in [item for item in node if item["id"] in itemIdentifiers]:
|
||||
node.remove(item)
|
||||
return defer.succeed(None)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue