source:
ralphm-patches/py3-muc.patch
Last change on this file was 78:361e2111a663, checked in by Ralph Meijer <ralphm@…>, 6 years ago | |
---|---|
File size: 15.9 KB |
-
wokkel/compat.py
# HG changeset patch # Parent 67c8865969f4350bfc019ddd852ee6f2ed707cdf diff --git a/wokkel/compat.py b/wokkel/compat.py
a b 9 9 10 10 from __future__ import division, absolute_import 11 11 12 from twisted.python.deprecate import deprecatedModuleAttribute13 from twisted.python.versions import Version14 12 from twisted.words.protocols.jabber import xmlstream 15 13 16 14 class IQ(xmlstream.IQ): -
wokkel/muc.py
diff --git a/wokkel/muc.py b/wokkel/muc.py
a b 14 14 from zope.interface import implementer 15 15 16 16 from twisted.internet import defer 17 from twisted.python.compat import unicode 17 18 from twisted.python.constants import Values, ValueConstant 18 19 from twisted.words.protocols.jabber import jid, error, xmlstream 19 20 from twisted.words.xish import domish … … 72 73 This is currently implemented as a set of constant values from 73 74 L{STATUS_CODE}. Instances of this class provide L{IMUCStatuses}, that 74 75 defines the supported operations. Even though this class currently derives 75 from C{set}, future versions might not. This provides an upgrade path to76 from L{set}, future versions might not. This provides an upgrade path to 76 77 cater for extensible status conditions, as defined in 77 78 U{XEP-0306<http://xmpp.org/extensions/xep-0306.html>}. 78 79 """ … … 224 225 Room destruction request. 225 226 226 227 @param reason: Optional reason for the destruction of this room. 227 @type reason: C{unicode}.228 @type reason: L{unicode}. 228 229 229 230 @param alternate: Optional room JID of an alternate venue. 230 231 @type alternate: L{JID<twisted.words.protocols.jabber.jid.JID>} 231 232 232 233 @param password: Optional password for entering the alternate venue. 233 @type password: C{unicode}234 @type password: L{unicode} 234 235 """ 235 236 236 237 stanzaType = 'set' … … 273 274 """ 274 275 Render into a domish Element. 275 276 276 @param legacyDelay: If C{True} send the delayed delivery information277 @param legacyDelay: If L{True} send the delayed delivery information 277 278 in legacy format. 278 279 """ 279 280 element = xmppim.Message.toElement(self) … … 323 324 @ivar maxchars: Limit the total number of characters in the history to "X" 324 325 (where the character count is the characters of the complete XML 325 326 stanzas, not only their XML character data). 326 @type maxchars: C{int}327 @type maxchars: L{int} 327 328 328 329 @ivar maxstanzas: Limit the total number of messages in the history to "X". 329 @type mazstanzas: C{int}330 @type mazstanzas: L{int} 330 331 331 332 @ivar seconds: Send only the messages received in the last "X" seconds. 332 @type seconds: C{int}333 @type seconds: L{int} 333 334 334 335 @ivar since: Send only the messages received since the datetime specified. 335 336 Note that this must be an offset-aware instance. … … 391 392 Availability presence sent from MUC service to client. 392 393 393 394 @ivar affiliation: Affiliation of the entity to the room. 394 @type affiliation: C{unicode}395 @type affiliation: L{unicode} 395 396 396 397 @ivar role: Role of the entity in the room. 397 @type role: C{unicode}398 @type role: L{unicode} 398 399 399 400 @ivar entity: The real JID of the entity this presence is from. 400 401 @type entity: L{JID<twisted.words.protocols.jabber.jid.JID>} … … 404 405 @type mucStatuses: L{Statuses} 405 406 406 407 @ivar nick: The nick name of the entity in the room. 407 @type nick: C{unicode}408 @type nick: L{unicode} 408 409 """ 409 410 410 411 affiliation = None … … 545 546 546 547 @param timeout: The number of seconds to wait before the deferred is 547 548 timed out. 548 @type timeout: C{int}549 @type timeout: L{int} 549 550 550 551 The deferred object L{defer.Deferred} is returned. 551 552 """ … … 591 592 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 592 593 593 594 @param nick: The nick name for the entitity joining the room. 594 @type nick: C{unicode}595 @type nick: L{unicode} 595 596 596 597 @param historyOptions: Options for conversation history sent by the 597 598 room upon joining. 598 599 @type historyOptions: L{HistoryOptions} 599 600 600 601 @param password: Optional password for the room. 601 @type password: C{unicode}602 @type password: L{unicode} 602 603 603 604 @return: A deferred that fires when the entity is in the room or an 604 605 error has occurred. … … 624 625 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 625 626 626 627 @param nick: The new nick name within the room. 627 @type nick: C{unicode}628 @type nick: L{unicode} 628 629 """ 629 630 occupantJID = jid.JID(tuple=(roomJID.user, roomJID.host, nick)) 630 631 presence = BasicPresence(recipient=occupantJID) … … 642 643 643 644 @param show: The availability of the entity. Common values are xa, 644 645 available, etc 645 @type show: C{unicode}646 @type show: L{unicode} 646 647 647 648 @param status: The current status of the entity. 648 @type status: C{unicode}649 @type status: L{unicode} 649 650 """ 650 651 occupantJID = self._roomOccupantMap[roomJID] 651 652 presence = BasicPresence(recipient=occupantJID, show=show, … … 700 701 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 701 702 702 703 @param subject: The subject you want to set. 703 @type subject: C{unicode}704 @type subject: L{unicode} 704 705 """ 705 706 message = GroupChat(roomJID.userhostJID(), subject=subject) 706 707 self.send(message.toElement()) … … 719 720 @type invitee: L{JID<twisted.words.protocols.jabber.jid.JID>} 720 721 721 722 @param reason: The reason for the invite. 722 @type reason: C{unicode}723 @type reason: L{unicode} 723 724 """ 724 725 message = InviteMessage(recipient=roomJID, invitee=invitee, 725 726 reason=reason) … … 751 752 @param roomJID: The bare JID of the room. 752 753 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 753 754 754 @param options: A mapping of field names to values, or C{None} to755 @param options: A mapping of field names to values, or L{None} to 755 756 cancel. 756 @type options: C{dict}757 @type options: L{dict} 757 758 """ 758 759 if options is None: 759 760 options = False … … 783 784 784 785 @param messages: The history to send to the room as an ordered list of 785 786 message, represented by a dictionary with the keys 786 C{'stanza'}, holding the original stanza a787 L{domish.Element}, and C{'timestamp'} with the787 L{'stanza'}, holding the original stanza a 788 L{domish.Element}, and L{'timestamp'} with the 788 789 timestamp. 789 @type messages: C{list} of L{domish.Element}790 @type messages: L{list} of L{domish.Element} 790 791 """ 791 792 792 793 for message in messages: … … 818 819 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 819 820 820 821 @return: A deferred that fires with the room's configuration form as 821 a L{data_form.Form} or C{None} if there are no configuration822 a L{data_form.Form} or L{None} if there are no configuration 822 823 options available. 823 824 """ 824 825 def cb(response): … … 838 839 @param roomJID: The room to configure. 839 840 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 840 841 841 @param options: A mapping of field names to values, or C{None} to842 @param options: A mapping of field names to values, or L{None} to 842 843 cancel. 843 @type options: C{dict}844 @type options: L{dict} 844 845 """ 845 846 if options is None: 846 847 options = False … … 962 963 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 963 964 964 965 @param entities: The list of entities to change for a room. 965 @type entities: C{list} of966 @type entities: L{list} of 966 967 L{JID<twisted.words.protocols.jabber.jid.JID>} 967 968 968 969 @param affiliation: The affilation to the entities will acquire. 969 @type affiliation: C{unicode}970 @type affiliation: L{unicode} 970 971 971 972 @param sender: The entity sending the request. 972 973 @type sender: L{JID<twisted.words.protocols.jabber.jid.JID>} … … 988 989 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 989 990 990 991 @param nick: The nick name for the user in this room. 991 @type nick: C{unicode}992 @type nick: L{unicode} 992 993 993 994 @param reason: The reason for granting voice to the entity. 994 @type reason: C{unicode}995 @type reason: L{unicode} 995 996 996 997 @param sender: The entity sending the request. 997 998 @type sender: L{JID<twisted.words.protocols.jabber.jid.JID>} … … 1011 1012 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 1012 1013 1013 1014 @param nick: The nick name for the user in this room. 1014 @type nick: C{unicode}1015 @type nick: L{unicode} 1015 1016 1016 1017 @param reason: The reason for revoking voice from the entity. 1017 @type reason: C{unicode}1018 @type reason: L{unicode} 1018 1019 1019 1020 @param sender: The entity sending the request. 1020 1021 @type sender: L{JID<twisted.words.protocols.jabber.jid.JID>} … … 1031 1032 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 1032 1033 1033 1034 @param nick: The nick name for the user in this room. 1034 @type nick: C{unicode}1035 @type nick: L{unicode} 1035 1036 1036 1037 @param reason: The reason for granting moderation to the entity. 1037 @type reason: C{unicode}1038 @type reason: L{unicode} 1038 1039 1039 1040 @param sender: The entity sending the request. 1040 1041 @type sender: L{JID<twisted.words.protocols.jabber.jid.JID>} … … 1054 1055 @type entity: L{JID<twisted.words.protocols.jabber.jid.JID>} 1055 1056 1056 1057 @param reason: The reason for banning the entity. 1057 @type reason: C{unicode}1058 @type reason: L{unicode} 1058 1059 1059 1060 @param sender: The entity sending the request. 1060 1061 @type sender: L{JID<twisted.words.protocols.jabber.jid.JID>} … … 1071 1072 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 1072 1073 1073 1074 @param nick: The occupant to be banned. 1074 @type nick: C{unicode}1075 @type nick: L{unicode} 1075 1076 1076 1077 @param reason: The reason given for the kick. 1077 @type reason: C{unicode}1078 @type reason: L{unicode} 1078 1079 1079 1080 @param sender: The entity sending the request. 1080 1081 @type sender: L{JID<twisted.words.protocols.jabber.jid.JID>} … … 1091 1092 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 1092 1093 1093 1094 @param reason: The reason for the destruction of the room. 1094 @type reason: C{unicode}1095 @type reason: L{unicode} 1095 1096 1096 1097 @param alternate: The JID of the room suggested as an alternate venue. 1097 1098 @type alternate: L{JID<twisted.words.protocols.jabber.jid.JID>} … … 1131 1132 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 1132 1133 1133 1134 @ivar nick: The nick name for the client in this room. 1134 @type nick: C{unicode}1135 @type nick: L{unicode} 1135 1136 1136 1137 @ivar occupantJID: The JID of the occupant in the room. Generated from 1137 1138 roomJID and nick. … … 1141 1142 to be configured before it can be used. See 1142 1143 L{MUCClientProtocol.getConfiguration} and 1143 1144 L{MUCClientProtocol.configure}. 1144 @type locked: C{bool}1145 @type locked: L{bool} 1145 1146 """ 1146 1147 1147 1148 locked = False … … 1186 1187 Get a user from the room's roster. 1187 1188 1188 1189 @param nick: The nick for the user in the MUC room. 1189 @type nick: C{unicode}1190 @type nick: L{unicode} 1190 1191 """ 1191 1192 return self.roster.get(nick) 1192 1193 … … 1213 1214 @ivar _rooms: Collection of occupied rooms, keyed by the bare JID of the 1214 1215 room. Note that a particular entity can only join a room once 1215 1216 at a time. 1216 @type _rooms: C{dict}1217 @type _rooms: L{dict} 1217 1218 """ 1218 1219 1219 1220 def __init__(self, reactor=None): … … 1398 1399 @param room: The room the message was received from. 1399 1400 @type room: L{Room} 1400 1401 1401 @param user: The user that sent the message, or C{None} if it was a1402 @param user: The user that sent the message, or L{None} if it was a 1402 1403 message from the room itself. 1403 1404 @type user: L{User} 1404 1405 … … 1419 1420 @param room: The room the message was received from. 1420 1421 @type room: L{Room} 1421 1422 1422 @param user: The user that sent the message, or C{None} if it was a1423 @param user: The user that sent the message, or L{None} if it was a 1423 1424 message from the room itself. 1424 1425 @type user: L{User} 1425 1426 … … 1438 1439 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 1439 1440 1440 1441 @param nick: The nick name for the entitity joining the room. 1441 @type nick: C{unicode}1442 @type nick: L{unicode} 1442 1443 1443 1444 @param historyOptions: Options for conversation history sent by the 1444 1445 room upon joining. 1445 1446 @type historyOptions: L{HistoryOptions} 1446 1447 1447 1448 @param password: Optional password for the room. 1448 @type password: C{unicode}1449 @type password: L{unicode} 1449 1450 1450 1451 @return: A deferred that fires with the room when the entity is in the 1451 1452 room, or with a failure if an error has occurred. … … 1482 1483 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 1483 1484 1484 1485 @param nick: The new nick name within the room. 1485 @type nick: C{unicode}1486 @type nick: L{unicode} 1486 1487 """ 1487 1488 def cb(presence): 1488 1489 # Presence confirmation, change the nickname. … … 1524 1525 1525 1526 @param show: The availability of the entity. Common values are xa, 1526 1527 available, etc 1527 @type show: C{unicode}1528 @type show: L{unicode} 1528 1529 1529 1530 @param status: The current status of the entity. 1530 @type status: C{unicode}1531 @type status: L{unicode} 1531 1532 """ 1532 1533 room = self._getRoom(roomJID) 1533 1534 d = MUCClientProtocol.status(self, roomJID, show, status) … … 1543 1544 @type roomJID: L{JID<twisted.words.protocols.jabber.jid.JID>} 1544 1545 1545 1546 @param reason: The reason for the destruction of the room. 1546 @type reason: C{unicode}1547 @type reason: L{unicode} 1547 1548 1548 1549 @param alternate: The JID of the room suggested as an alternate venue. 1549 1550 @type alternate: L{JID<twisted.words.protocols.jabber.jid.JID>} -
wokkel/test/test_muc.py
diff --git a/wokkel/test/test_muc.py b/wokkel/test/test_muc.py
a b 12 12 13 13 from twisted.trial import unittest 14 14 from twisted.internet import defer, task 15 from twisted.python.compat import iteritems, unicode 15 16 from twisted.words.xish import domish, xpath 16 17 from twisted.words.protocols.jabber.jid import JID 17 18 from twisted.words.protocols.jabber.error import StanzaError … … 78 79 332: 'removed-shutdown', 79 80 } 80 81 81 for code, condition in codes.iteritems():82 for code, condition in iteritems(codes): 82 83 constantName = condition.replace('-', '_').upper() 83 84 self.assertEqual(getattr(muc.STATUS_CODE, constantName), 84 85 muc.STATUS_CODE.lookupByValue(code)) … … 823 824 nodes = xpath.queryForNodes(query, iq) 824 825 self.assertNotIdentical(None, nodes, 'Missing query element') 825 826 826 self.assertRaises(StopIteration, n odes[0].elements().next)827 self.assertRaises(StopIteration, next, nodes[0].elements()) 827 828 828 829 xml = u""" 829 830 <iq from='%s' id='%s' to='%s' type='result'> … … 969 970 nodes = xpath.queryForNodes(query, iq) 970 971 self.assertNotIdentical(None, nodes, 'Missing query element') 971 972 972 self.assertRaises(StopIteration, n odes[0].elements().next)973 self.assertRaises(StopIteration, next, nodes[0].elements()) 973 974 974 975 xml = u""" 975 976 <iq from='%s' id='%s' to='%s' type='result'>
Note: See TracBrowser
for help on using the repository browser.