Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
b3a88167 by Daniel Brötzmann at 2021-10-12T16:15:22+00:00
Windows Build Instructions: Add Windows 7 compatibility hint
- - - - -
1 changed file:
- win/README.md
Changes:
=====================================
win/README.md
=====================================
@@ -3,6 +3,7 @@ # Windows Installer
We use [msys2](https://www.msys2.org/) for creating the Windows installer
and development on Windows.
+Please note that Windows 7 support has been dropped.
## Development
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/b3a88167ffbccaa8fecb1be9689180fc…
--
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/b3a88167ffbccaa8fecb1be9689180fc…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
01b4b9c8 by lovetox at 2021-10-10T15:48:57+02:00
Remove superfluous import
- - - - -
1 changed file:
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/structs.py
=====================================
@@ -35,7 +35,6 @@ from gi.repository import Gio
from nbxmpp.simplexml import Node
from nbxmpp.namespaces import Namespace
from nbxmpp.protocol import Protocol
-from nbxmpp.protocol import Node
from nbxmpp.protocol import JID
from nbxmpp.const import MessageType
from nbxmpp.const import AvatarState
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/01b4b9c8a30624e20b92c479…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/01b4b9c8a30624e20b92c479…
You're receiving this email because of your account on dev.gajim.org.
Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
8a8086e6 by lovetox at 2021-10-10T15:39:39+02:00
Remove "one" keyword argument from getTags()
If one wants to get only the first tag getTag() should be used
This change also helps for typing hints
- - - - -
5fd7e953 by lovetox at 2021-10-10T15:41:50+02:00
structs: Add more typing hints
- - - - -
2 changed files:
- nbxmpp/simplexml.py
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/simplexml.py
=====================================
@@ -351,9 +351,10 @@ class Node:
Filter all child nodes using specified arguments as filter. Return the
first found or None if not found
"""
- tag = self.getTags(name, attrs, namespace, one=True)
- assert not isinstance(tag, list)
- return tag
+ tags = self.getTags(name, attrs, namespace)
+ if not tags:
+ return None
+ return tags[0]
def getTagAttr(self,
tag: str,
@@ -380,13 +381,12 @@ class Node:
def getTags(self,
name: str,
attrs: Optional[Attrs] = None,
- namespace: Optional[str] = None,
- one: bool = False) -> Union[List[Node], Node, None]:
+ namespace: Optional[str] = None) -> List[Node]:
"""
Filter all child nodes using specified arguments as filter. Returns the
list of nodes found
"""
- nodes = []
+ nodes: List[Node] = []
for node in self.kids:
if namespace and namespace != node.getNamespace():
continue
@@ -398,11 +398,7 @@ class Node:
break
else:
nodes.append(node)
- if one and nodes:
- return nodes[0]
- if not one:
- return nodes
- return None
+ return nodes
def iterTags(self,
name: str,
@@ -479,9 +475,9 @@ class Node:
Same as getTag but if the node with specified namespace/attributes not
found, creates such node and returns it
"""
- node = self.getTags(name, attrs, namespace=namespace, one=True)
- if node:
- return node
+ nodes = self.getTags(name, attrs, namespace=namespace)
+ if nodes:
+ return nodes[0]
return self.addChild(name, attrs, namespace=namespace)
def setTagAttr(self,
=====================================
nbxmpp/structs.py
=====================================
@@ -15,17 +15,24 @@
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.
+from __future__ import annotations
+
+from typing import Any
+from typing import Optional
from typing import Set
+from typing import NamedTuple
import time
import random
from collections import namedtuple
+import dataclasses
from dataclasses import dataclass
from dataclasses import field
from gi.repository import Soup
from gi.repository import Gio
+from nbxmpp.simplexml import Node
from nbxmpp.namespaces import Namespace
from nbxmpp.protocol import Protocol
from nbxmpp.protocol import Node
@@ -37,9 +44,15 @@ from nbxmpp.const import PresenceType
from nbxmpp.const import LOCATION_DATA
from nbxmpp.const import AdHocStatus
-StanzaHandler = namedtuple('StanzaHandler',
- 'name callback typ ns xmlns priority')
-StanzaHandler.__new__.__defaults__ = ('', '', None, 50)
+
+class StanzaHandler(NamedTuple):
+ name: str
+ callback: Any
+ typ: str = ''
+ ns: str = ''
+ xmlns: Optional[str] = None
+ priority: int = 50
+
CommonResult = namedtuple('CommonResult', 'jid')
CommonResult.__new__.__defaults__ = (None,)
@@ -140,32 +153,29 @@ RosterPush = namedtuple('RosterPush', 'item version')
@dataclass
class RosterItem:
jid: JID
- name: str = None
- ask: str = None
- subscription: str = None
+ name: Optional[str] = None
+ ask: Optional[str] = None
+ subscription: Optional[str] = None
groups: Set[str] = field(default_factory=set)
@classmethod
- def from_node(cls, node):
+ def from_node(cls, node: Node) -> RosterItem:
attrs = node.getAttrs(copy=True)
jid = attrs.get('jid')
if jid is None:
raise Exception('jid attribute missing')
jid = JID.from_string(jid)
- attrs['jid'] = jid
-
groups = {group.getData() for group in node.getTags('group')}
- attrs['groups'] = groups
- return cls(**attrs)
+ return cls(jid=jid,
+ name=attrs.get('name'),
+ ask=attrs.get('ask'),
+ subscription=attrs.get('subscription'),
+ groups=groups)
def asdict(self):
- return {'jid': self.jid,
- 'name': self.name,
- 'ask': self.ask,
- 'subscription': self.subscription,
- 'groups': self.groups}
+ return dataclasses.asdict(self)
class DiscoInfo(namedtuple('DiscoInfo', 'stanza identities features dataforms timestamp')):
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/compare/46b1d670f30822a1070d43f…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/compare/46b1d670f30822a1070d43f…
You're receiving this email because of your account on dev.gajim.org.