cq: Format with black and isort
This commit is contained in:
@@ -18,13 +18,14 @@ import logging
|
||||
|
||||
from openpgp.modules.util import Trust
|
||||
|
||||
log = logging.getLogger('gajim.p.openpgp.store')
|
||||
log = logging.getLogger("gajim.p.openpgp.store")
|
||||
|
||||
|
||||
class KeyData:
|
||||
'''
|
||||
"""
|
||||
Holds all data related to a certain key
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self, contact_data):
|
||||
self._contact_data = contact_data
|
||||
self.fingerprint = None
|
||||
@@ -40,11 +41,8 @@ class KeyData:
|
||||
|
||||
@trust.setter
|
||||
def trust(self, value):
|
||||
if value not in (Trust.NOT_TRUSTED,
|
||||
Trust.UNKNOWN,
|
||||
Trust.BLIND,
|
||||
Trust.VERIFIED):
|
||||
raise ValueError('Trust value not allowed: %s' % value)
|
||||
if value not in (Trust.NOT_TRUSTED, Trust.UNKNOWN, Trust.BLIND, Trust.VERIFIED):
|
||||
raise ValueError("Trust value not allowed: %s" % value)
|
||||
self._trust = value
|
||||
self._contact_data.set_trust(self.fingerprint, self._trust)
|
||||
|
||||
@@ -72,9 +70,10 @@ class KeyData:
|
||||
|
||||
|
||||
class ContactData:
|
||||
'''
|
||||
"""
|
||||
Holds all data related to a contact
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self, jid, storage, pgp):
|
||||
self.jid = jid
|
||||
self._key_store = {}
|
||||
@@ -84,8 +83,8 @@ class ContactData:
|
||||
@property
|
||||
def userid(self):
|
||||
if self.jid is None:
|
||||
raise ValueError('JID not set')
|
||||
return 'xmpp:%s' % self.jid
|
||||
raise ValueError("JID not set")
|
||||
return "xmpp:%s" % self.jid
|
||||
|
||||
@property
|
||||
def default_trust(self):
|
||||
@@ -96,12 +95,14 @@ class ContactData:
|
||||
|
||||
def db_values(self):
|
||||
for key in self._key_store.values():
|
||||
yield (self.jid,
|
||||
key.fingerprint,
|
||||
key.active,
|
||||
key.trust,
|
||||
key.timestamp,
|
||||
key.comment)
|
||||
yield (
|
||||
self.jid,
|
||||
key.fingerprint,
|
||||
key.active,
|
||||
key.trust,
|
||||
key.timestamp,
|
||||
key.comment,
|
||||
)
|
||||
|
||||
def add_from_key(self, key):
|
||||
try:
|
||||
@@ -109,7 +110,7 @@ class ContactData:
|
||||
except KeyError:
|
||||
keydata = KeyData.from_key(self, key, self.default_trust)
|
||||
self._key_store[key.fingerprint] = keydata
|
||||
log.info('Add from key: %s %s', self.jid, keydata.fingerprint)
|
||||
log.info("Add from key: %s %s", self.jid, keydata.fingerprint)
|
||||
return keydata
|
||||
|
||||
def add_from_db(self, row):
|
||||
@@ -118,11 +119,11 @@ class ContactData:
|
||||
except KeyError:
|
||||
keydata = KeyData.from_row(self, row)
|
||||
self._key_store[row.fingerprint] = keydata
|
||||
log.info('Add from row: %s %s', self.jid, row.fingerprint)
|
||||
log.info("Add from row: %s %s", self.jid, row.fingerprint)
|
||||
return keydata
|
||||
|
||||
def process_keylist(self, keylist):
|
||||
log.info('Process keylist: %s %s', self.jid, keylist)
|
||||
log.info("Process keylist: %s %s", self.jid, keylist)
|
||||
|
||||
if keylist is None:
|
||||
for keydata in self._key_store.values():
|
||||
@@ -133,7 +134,7 @@ class ContactData:
|
||||
missing_pub_keys = []
|
||||
fingerprints = set([key.fingerprint for key in keylist])
|
||||
if fingerprints == self._key_store.keys():
|
||||
log.info('No updates found')
|
||||
log.info("No updates found")
|
||||
for key in self._key_store.values():
|
||||
if not key.has_pubkey:
|
||||
missing_pub_keys.append(key.fingerprint)
|
||||
@@ -159,18 +160,20 @@ class ContactData:
|
||||
try:
|
||||
keydata = self._key_store[fingerprint]
|
||||
except KeyError:
|
||||
log.warning('Set public key on unknown fingerprint: %s %s',
|
||||
self.jid, fingerprint)
|
||||
log.warning(
|
||||
"Set public key on unknown fingerprint: %s %s", self.jid, fingerprint
|
||||
)
|
||||
else:
|
||||
keydata.has_pubkey = True
|
||||
log.info('Set public key: %s %s', self.jid, fingerprint)
|
||||
log.info("Set public key: %s %s", self.jid, fingerprint)
|
||||
|
||||
def get_keys(self, only_trusted=True):
|
||||
keys = list(self._key_store.values())
|
||||
if not only_trusted:
|
||||
return keys
|
||||
return [k for k in keys if k.active and k.trust in (Trust.VERIFIED,
|
||||
Trust.BLIND)]
|
||||
return [
|
||||
k for k in keys if k.active and k.trust in (Trust.VERIFIED, Trust.BLIND)
|
||||
]
|
||||
|
||||
def get_key(self, fingerprint):
|
||||
return self._key_store.get(fingerprint, None)
|
||||
@@ -185,9 +188,10 @@ class ContactData:
|
||||
|
||||
|
||||
class PGPContacts:
|
||||
'''
|
||||
"""
|
||||
Holds all contacts available for PGP encryption
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self, pgp, storage):
|
||||
self._contacts = {}
|
||||
self._storage = storage
|
||||
@@ -196,20 +200,20 @@ class PGPContacts:
|
||||
self._load_from_keyring()
|
||||
|
||||
def _load_from_keyring(self):
|
||||
log.info('Load keys from keyring')
|
||||
log.info("Load keys from keyring")
|
||||
keyring = self._pgp.get_keys()
|
||||
for key in keyring:
|
||||
log.info('Found: %s %s', key.jid, key.fingerprint)
|
||||
log.info("Found: %s %s", key.jid, key.fingerprint)
|
||||
self.set_public_key(key.jid, key.fingerprint)
|
||||
|
||||
def _load_from_storage(self):
|
||||
log.info('Load contacts from storage')
|
||||
log.info("Load contacts from storage")
|
||||
rows = self._storage.load_contacts()
|
||||
if rows is None:
|
||||
return
|
||||
|
||||
for row in rows:
|
||||
log.info('Found: %s %s', row.jid, row.fingerprint)
|
||||
log.info("Found: %s %s", row.jid, row.fingerprint)
|
||||
try:
|
||||
contact_data = self._contacts[row.jid]
|
||||
except KeyError:
|
||||
@@ -235,7 +239,7 @@ class PGPContacts:
|
||||
try:
|
||||
contact_data = self._contacts[jid]
|
||||
except KeyError:
|
||||
log.warning('ContactData not found: %s %s', jid, fingerprint)
|
||||
log.warning("ContactData not found: %s %s", jid, fingerprint)
|
||||
else:
|
||||
contact_data.set_public_key(fingerprint)
|
||||
|
||||
|
||||
@@ -14,24 +14,24 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OpenPGP Gajim Plugin. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from nbxmpp.namespaces import Namespace
|
||||
from nbxmpp import Node
|
||||
from nbxmpp import StanzaMalformed
|
||||
from nbxmpp.errors import MalformedStanzaError
|
||||
from nbxmpp.errors import StanzaError
|
||||
from nbxmpp.exceptions import StanzaDecrypted
|
||||
from nbxmpp.modules.openpgp import create_message_stanza
|
||||
from nbxmpp.modules.openpgp import create_signcrypt_node
|
||||
from nbxmpp.modules.openpgp import parse_signcrypt
|
||||
from nbxmpp.modules.openpgp import PGPKeyMetadata
|
||||
from nbxmpp.namespaces import Namespace
|
||||
from nbxmpp.structs import EncryptionData
|
||||
from nbxmpp.structs import MessageProperties
|
||||
from nbxmpp.structs import StanzaHandler
|
||||
from nbxmpp.errors import StanzaError
|
||||
from nbxmpp.errors import MalformedStanzaError
|
||||
from nbxmpp.modules.openpgp import PGPKeyMetadata
|
||||
from nbxmpp.modules.openpgp import parse_signcrypt
|
||||
from nbxmpp.modules.openpgp import create_signcrypt_node
|
||||
from nbxmpp.modules.openpgp import create_message_stanza
|
||||
|
||||
from gajim.common import app
|
||||
from gajim.common import configpaths
|
||||
@@ -40,22 +40,22 @@ from gajim.common.modules.base import BaseModule
|
||||
from gajim.common.modules.util import event_node
|
||||
from gajim.common.structs import OutgoingMessage
|
||||
|
||||
from openpgp.modules.util import ENCRYPTION_NAME
|
||||
from openpgp.modules.util import NOT_ENCRYPTED_TAGS
|
||||
from openpgp.modules.util import Key
|
||||
from openpgp.modules.util import Trust
|
||||
from openpgp.modules.util import DecryptionFailed
|
||||
from openpgp.modules.util import prepare_stanza
|
||||
from openpgp.modules.key_store import PGPContacts
|
||||
from openpgp.backend.sql import Storage
|
||||
from openpgp.modules.key_store import PGPContacts
|
||||
from openpgp.modules.util import DecryptionFailed
|
||||
from openpgp.modules.util import ENCRYPTION_NAME
|
||||
from openpgp.modules.util import Key
|
||||
from openpgp.modules.util import NOT_ENCRYPTED_TAGS
|
||||
from openpgp.modules.util import prepare_stanza
|
||||
from openpgp.modules.util import Trust
|
||||
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
from openpgp.backend.pygpg import PythonGnuPG as PGPBackend
|
||||
else:
|
||||
from openpgp.backend.gpgme import GPGME as PGPBackend
|
||||
|
||||
|
||||
log = logging.getLogger('gajim.p.openpgp')
|
||||
log = logging.getLogger("gajim.p.openpgp")
|
||||
|
||||
|
||||
# Module name
|
||||
@@ -65,24 +65,26 @@ zeroconf = False
|
||||
|
||||
class OpenPGP(BaseModule):
|
||||
|
||||
_nbxmpp_extends = 'OpenPGP'
|
||||
_nbxmpp_extends = "OpenPGP"
|
||||
_nbxmpp_methods = [
|
||||
'set_keylist',
|
||||
'request_keylist',
|
||||
'set_public_key',
|
||||
'request_public_key',
|
||||
'set_secret_key',
|
||||
'request_secret_key',
|
||||
"set_keylist",
|
||||
"request_keylist",
|
||||
"set_public_key",
|
||||
"request_public_key",
|
||||
"set_secret_key",
|
||||
"request_secret_key",
|
||||
]
|
||||
|
||||
def __init__(self, client):
|
||||
BaseModule.__init__(self, client)
|
||||
|
||||
self.handlers = [
|
||||
StanzaHandler(name='message',
|
||||
callback=self.decrypt_message,
|
||||
ns=Namespace.OPENPGP,
|
||||
priority=9),
|
||||
StanzaHandler(
|
||||
name="message",
|
||||
callback=self.decrypt_message,
|
||||
ns=Namespace.OPENPGP,
|
||||
priority=9,
|
||||
),
|
||||
]
|
||||
|
||||
self._register_pubsub_handler(self._keylist_notification_received)
|
||||
@@ -90,7 +92,7 @@ class OpenPGP(BaseModule):
|
||||
self.own_jid = self._client.get_own_jid()
|
||||
|
||||
own_bare_jid = self.own_jid.bare
|
||||
path = Path(configpaths.get('MY_DATA')) / 'openpgp' / own_bare_jid
|
||||
path = Path(configpaths.get("MY_DATA")) / "openpgp" / own_bare_jid
|
||||
if not path.exists():
|
||||
path.mkdir(mode=0o700, parents=True)
|
||||
|
||||
@@ -98,7 +100,7 @@ class OpenPGP(BaseModule):
|
||||
self._storage = Storage(path)
|
||||
self._contacts = PGPContacts(self._pgp, self._storage)
|
||||
self._fingerprint, self._date = self.get_own_key_details()
|
||||
log.info('Own Fingerprint at start: %s', self._fingerprint)
|
||||
log.info("Own Fingerprint at start: %s", self._fingerprint)
|
||||
|
||||
@property
|
||||
def secret_key_available(self):
|
||||
@@ -112,27 +114,22 @@ class OpenPGP(BaseModule):
|
||||
self._pgp.generate_key()
|
||||
|
||||
def set_public_key(self):
|
||||
log.info('%s => Publish public key', self._account)
|
||||
log.info("%s => Publish public key", self._account)
|
||||
key = self._pgp.export_key(self._fingerprint)
|
||||
self._nbxmpp('OpenPGP').set_public_key(
|
||||
key, self._fingerprint, self._date)
|
||||
self._nbxmpp("OpenPGP").set_public_key(key, self._fingerprint, self._date)
|
||||
|
||||
def request_public_key(self, jid, fingerprint):
|
||||
log.info('%s => Request public key %s - %s',
|
||||
self._account, fingerprint, jid)
|
||||
self._nbxmpp('OpenPGP').request_public_key(
|
||||
jid,
|
||||
fingerprint,
|
||||
callback=self._public_key_received,
|
||||
user_data=fingerprint)
|
||||
log.info("%s => Request public key %s - %s", self._account, fingerprint, jid)
|
||||
self._nbxmpp("OpenPGP").request_public_key(
|
||||
jid, fingerprint, callback=self._public_key_received, user_data=fingerprint
|
||||
)
|
||||
|
||||
def _public_key_received(self, task):
|
||||
fingerprint = task.get_user_data()
|
||||
try:
|
||||
result = task.finish()
|
||||
except (StanzaError, MalformedStanzaError) as error:
|
||||
log.error('%s => Public Key not found: %s',
|
||||
self._account, error)
|
||||
log.error("%s => Public Key not found: %s", self._account, error)
|
||||
return
|
||||
|
||||
imported_key = self._pgp.import_key(result.key, result.jid)
|
||||
@@ -142,8 +139,8 @@ class OpenPGP(BaseModule):
|
||||
def set_keylist(self, keylist=None):
|
||||
if keylist is None:
|
||||
keylist = [PGPKeyMetadata(None, self._fingerprint, self._date)]
|
||||
log.info('%s => Publish keylist', self._account)
|
||||
self._nbxmpp('OpenPGP').set_keylist(keylist)
|
||||
log.info("%s => Publish keylist", self._account)
|
||||
self._nbxmpp("OpenPGP").set_keylist(keylist)
|
||||
|
||||
@event_node(Namespace.OPENPGP_PK)
|
||||
def _keylist_notification_received(self, _con, _stanza, properties):
|
||||
@@ -157,46 +154,43 @@ class OpenPGP(BaseModule):
|
||||
def request_keylist(self, jid=None):
|
||||
if jid is None:
|
||||
jid = self.own_jid
|
||||
log.info('%s => Fetch keylist %s', self._account, jid)
|
||||
log.info("%s => Fetch keylist %s", self._account, jid)
|
||||
|
||||
self._nbxmpp('OpenPGP').request_keylist(
|
||||
jid,
|
||||
callback=self._keylist_received,
|
||||
user_data=jid)
|
||||
self._nbxmpp("OpenPGP").request_keylist(
|
||||
jid, callback=self._keylist_received, user_data=jid
|
||||
)
|
||||
|
||||
def _keylist_received(self, task):
|
||||
jid = task.get_user_data()
|
||||
try:
|
||||
keylist = task.finish()
|
||||
except (StanzaError, MalformedStanzaError) as error:
|
||||
log.error('%s => Keylist query failed: %s',
|
||||
self._account, error)
|
||||
log.error("%s => Keylist query failed: %s", self._account, error)
|
||||
if self.own_jid.bare_match(jid) and self._fingerprint is not None:
|
||||
self.set_keylist()
|
||||
return
|
||||
|
||||
log.info('Keylist received from %s', jid)
|
||||
log.info("Keylist received from %s", jid)
|
||||
self._process_keylist(keylist, jid)
|
||||
|
||||
def _process_keylist(self, keylist, from_jid):
|
||||
if not keylist:
|
||||
log.warning('%s => Empty keylist received from %s',
|
||||
self._account, from_jid)
|
||||
log.warning("%s => Empty keylist received from %s", self._account, from_jid)
|
||||
self._contacts.process_keylist(self.own_jid, keylist)
|
||||
if self.own_jid.bare_match(from_jid) and self._fingerprint is not None:
|
||||
self.set_keylist()
|
||||
return
|
||||
|
||||
if self.own_jid.bare_match(from_jid):
|
||||
log.info('Received own keylist')
|
||||
log.info("Received own keylist")
|
||||
for key in keylist:
|
||||
log.info(key.fingerprint)
|
||||
for key in keylist:
|
||||
# Check if own fingerprint is published
|
||||
if key.fingerprint == self._fingerprint:
|
||||
log.info('Own key found in keys list')
|
||||
log.info("Own key found in keys list")
|
||||
return
|
||||
log.info('Own key not published')
|
||||
log.info("Own key not published")
|
||||
if self._fingerprint is not None:
|
||||
keylist.append(Key(self._fingerprint, self._date))
|
||||
self.set_keylist(keylist)
|
||||
@@ -228,31 +222,29 @@ class OpenPGP(BaseModule):
|
||||
try:
|
||||
payload, recipients, _timestamp = parse_signcrypt(signcrypt)
|
||||
except StanzaMalformed as error:
|
||||
log.warning('Decryption failed: %s', error)
|
||||
log.warning("Decryption failed: %s", error)
|
||||
log.warning(payload)
|
||||
return
|
||||
|
||||
if not any(map(self.own_jid.bare_match, recipients)):
|
||||
log.warning('to attr not valid')
|
||||
log.warning("to attr not valid")
|
||||
log.warning(signcrypt)
|
||||
return
|
||||
|
||||
keys = self._contacts.get_keys(remote_jid)
|
||||
fingerprints = [key.fingerprint for key in keys]
|
||||
if fingerprint not in fingerprints:
|
||||
log.warning('Invalid fingerprint on message: %s', fingerprint)
|
||||
log.warning('Expected: %s', fingerprints)
|
||||
log.warning("Invalid fingerprint on message: %s", fingerprint)
|
||||
log.warning("Expected: %s", fingerprints)
|
||||
return
|
||||
|
||||
log.info('Received OpenPGP message from: %s', properties.jid)
|
||||
log.info("Received OpenPGP message from: %s", properties.jid)
|
||||
prepare_stanza(stanza, payload)
|
||||
|
||||
trust = self._contacts.get_trust(remote_jid, fingerprint)
|
||||
|
||||
properties.encrypted = EncryptionData(
|
||||
protocol=ENCRYPTION_NAME,
|
||||
key=fingerprint,
|
||||
trust=trust
|
||||
protocol=ENCRYPTION_NAME, key=fingerprint, trust=trust
|
||||
)
|
||||
|
||||
raise StanzaDecrypted
|
||||
@@ -262,39 +254,38 @@ class OpenPGP(BaseModule):
|
||||
|
||||
keys = self._contacts.get_keys(remote_jid)
|
||||
if not keys:
|
||||
log.error('Droping stanza to %s, because we have no key', remote_jid)
|
||||
log.error("Droping stanza to %s, because we have no key", remote_jid)
|
||||
return
|
||||
|
||||
keys += self._contacts.get_keys(self.own_jid)
|
||||
keys += [Key(self._fingerprint, None)]
|
||||
|
||||
payload = create_signcrypt_node(message.get_stanza(),
|
||||
[remote_jid],
|
||||
NOT_ENCRYPTED_TAGS)
|
||||
payload = create_signcrypt_node(
|
||||
message.get_stanza(), [remote_jid], NOT_ENCRYPTED_TAGS
|
||||
)
|
||||
|
||||
encrypted_payload, error = self._pgp.encrypt(payload, keys)
|
||||
if error:
|
||||
log.error('Error: %s', error)
|
||||
text = message.get_text(with_fallback=False) or ''
|
||||
log.error("Error: %s", error)
|
||||
text = message.get_text(with_fallback=False) or ""
|
||||
app.ged.raise_event(
|
||||
MessageNotSent(client=self._client,
|
||||
jid=str(remote_jid),
|
||||
message=text,
|
||||
error=error,
|
||||
time=time.time()))
|
||||
MessageNotSent(
|
||||
client=self._client,
|
||||
jid=str(remote_jid),
|
||||
message=text,
|
||||
error=error,
|
||||
time=time.time(),
|
||||
)
|
||||
)
|
||||
return
|
||||
|
||||
create_message_stanza(
|
||||
message.get_stanza(),
|
||||
encrypted_payload,
|
||||
bool(message.get_text())
|
||||
message.get_stanza(), encrypted_payload, bool(message.get_text())
|
||||
)
|
||||
|
||||
message.set_encryption(
|
||||
EncryptionData(
|
||||
protocol=ENCRYPTION_NAME,
|
||||
key='Unknown',
|
||||
trust=Trust.VERIFIED
|
||||
protocol=ENCRYPTION_NAME, key="Unknown", trust=Trust.VERIFIED
|
||||
)
|
||||
)
|
||||
|
||||
@@ -302,12 +293,12 @@ class OpenPGP(BaseModule):
|
||||
|
||||
@staticmethod
|
||||
def print_msg_to_log(stanza):
|
||||
""" Prints a stanza in a fancy way to the log """
|
||||
log.debug('-'*15)
|
||||
stanzastr = '\n' + stanza.__str__(fancy=True)
|
||||
"""Prints a stanza in a fancy way to the log"""
|
||||
log.debug("-" * 15)
|
||||
stanzastr = "\n" + stanza.__str__(fancy=True)
|
||||
stanzastr = stanzastr[0:-1]
|
||||
log.debug(stanzastr)
|
||||
log.debug('-'*15)
|
||||
log.debug("-" * 15)
|
||||
|
||||
def get_keys(self, jid=None, only_trusted=True):
|
||||
if jid is None:
|
||||
@@ -324,4 +315,4 @@ class OpenPGP(BaseModule):
|
||||
|
||||
|
||||
def get_instance(*args, **kwargs):
|
||||
return OpenPGP(*args, **kwargs), 'OpenPGP'
|
||||
return OpenPGP(*args, **kwargs), "OpenPGP"
|
||||
|
||||
@@ -14,24 +14,23 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with OpenPGP Gajim Plugin. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from enum import IntEnum
|
||||
from collections import namedtuple
|
||||
from enum import IntEnum
|
||||
|
||||
from nbxmpp.namespaces import Namespace
|
||||
|
||||
|
||||
ENCRYPTION_NAME = 'OpenPGP'
|
||||
ENCRYPTION_NAME = "OpenPGP"
|
||||
|
||||
NOT_ENCRYPTED_TAGS = [
|
||||
('no-store', Namespace.HINTS),
|
||||
('store', Namespace.HINTS),
|
||||
('no-copy', Namespace.HINTS),
|
||||
('no-permanent-store', Namespace.HINTS),
|
||||
('origin-id', Namespace.SID),
|
||||
('thread', None)
|
||||
("no-store", Namespace.HINTS),
|
||||
("store", Namespace.HINTS),
|
||||
("no-copy", Namespace.HINTS),
|
||||
("no-permanent-store", Namespace.HINTS),
|
||||
("origin-id", Namespace.SID),
|
||||
("thread", None),
|
||||
]
|
||||
|
||||
Key = namedtuple('Key', 'fingerprint date')
|
||||
Key = namedtuple("Key", "fingerprint date")
|
||||
|
||||
|
||||
class Trust(IntEnum):
|
||||
@@ -42,8 +41,8 @@ class Trust(IntEnum):
|
||||
|
||||
|
||||
def prepare_stanza(stanza, payload):
|
||||
delete_nodes(stanza, 'openpgp', Namespace.OPENPGP)
|
||||
delete_nodes(stanza, 'body')
|
||||
delete_nodes(stanza, "openpgp", Namespace.OPENPGP)
|
||||
delete_nodes(stanza, "body")
|
||||
|
||||
nodes = [(node.getName(), node.getNamespace()) for node in payload]
|
||||
for name, namespace in nodes:
|
||||
@@ -56,7 +55,7 @@ def prepare_stanza(stanza, payload):
|
||||
def delete_nodes(stanza, name, namespace=None):
|
||||
attrs = None
|
||||
if namespace is not None:
|
||||
attrs = {'xmlns': Namespace.OPENPGP}
|
||||
attrs = {"xmlns": Namespace.OPENPGP}
|
||||
nodes = stanza.getTags(name, attrs)
|
||||
for node in nodes:
|
||||
stanza.delChild(node)
|
||||
|
||||
Reference in New Issue
Block a user