File: util.py

package info (click to toggle)
gajim-openpgp 1.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 160 kB
  • sloc: python: 1,487; sh: 29; xml: 11; makefile: 2
file content (12 lines) | stat: -rw-r--r-- 369 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
from __future__ import annotations


def parse_uid(uid: str, compat: bool = False) -> str:
    if uid.startswith("xmpp:"):
        return uid[5:]

    # Compat with uids of form "Name <xmpp:my@jid.com>"
    if compat and "<xmpp:" in uid and uid.endswith(">"):
        return uid[:-1].split("<xmpp:", maxsplit=1)[1]

    raise ValueError("Unknown UID format: %s" % uid)