Coverage for slidge/slixfix/xep_0317/stanza.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-07 05:11 +0000

1from slixmpp import Presence 

2from slixmpp.xmlstream import ElementBase, register_stanza_plugin 

3 

4NS = "urn:xmpp:hats:0" 

5 

6 

7class Hats(ElementBase): 

8 name = plugin_attrib = "hats" 

9 namespace = NS 

10 

11 def add_hats(self, data: list[tuple[str, str]]): 

12 for uri, title in data: 

13 hat = Hat() 

14 hat["uri"] = uri 

15 hat["title"] = title 

16 self.append(hat) 

17 

18 

19class Hat(ElementBase): 

20 name = plugin_attrib = "hat" 

21 namespace = NS 

22 interfaces = {"uri", "title"} 

23 plugin_multi_attrib = "hats" 

24 

25 

26def register(): 

27 register_stanza_plugin(Hats, Hat, iterable=True) 

28 register_stanza_plugin(Presence, Hats)