changeset 1767:8c7450bd9335

tmp (wokkel): removed delay as it is nearly identical to original one, and the additional exception should be catched elsewhere
author Goffi <goffi@goffi.org>
date Sun, 03 Jan 2016 18:36:39 +0100
parents d17772b0fe22
children 7debf3a4bf14
files src/plugins/__init__.py src/tmp/wokkel/delay.py
diffstat 2 files changed, 1 insertions(+), 168 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/__init__.py	Sun Jan 03 16:28:30 2016 +0100
+++ b/src/plugins/__init__.py	Sun Jan 03 18:36:39 2016 +0100
@@ -1,8 +1,7 @@
 # FIXME: remove this when RSM and MAM are in wokkel
 # XXX: the Monkey Patch is here and not in src/__init__ to avoir issues with pyjamas compilation
 import wokkel
-from sat.tmp.wokkel import delay as tmp_delay, pubsub as tmp_pubsub, rsm as tmp_rsm, mam as tmp_mam
-wokkel.delay = tmp_delay
+from sat.tmp.wokkel import pubsub as tmp_pubsub, rsm as tmp_rsm, mam as tmp_mam
 wokkel.pubsub = tmp_pubsub
 wokkel.rsm = tmp_rsm
 wokkel.mam = tmp_mam
--- a/src/tmp/wokkel/delay.py	Sun Jan 03 16:28:30 2016 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-# -*- coding: utf-8 -*-
-# -*- test-case-name: wokkel.test.test_delay -*-
-#
-# SàT adaptation for wokkel.delay
-# Copyright (C) 2015 Adien Cossa (souliane@mailoo.org)
-# Copyright (c) 2003-2012 Ralph Meijer.
-
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-
-# You should have received a copy of the GNU Affero General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-# --
-
-# This program is based on wokkel (https://wokkel.ik.nu/),
-# originaly written by Ralph Meijer
-# It is sublicensed under AGPL v3 (or any later version) as allowed by the original
-# license.
-
-# --
-
-# Here is a copy of the original license:
-
-# Copyright (c) 2003-2012 Ralph Meijer.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Copyright (c) Ralph Meijer.
-# See LICENSE for details.
-
-"""
-Delayed Delivery.
-
-Support for comunicating Delayed Delivery information as specified by
-U{XEP-0203<http://xmpp.org/extensions/xep-0203.html>} and its predecessor
-U{XEP-0091<http://xmpp.org/extensions/xep-0091.html>}.
-"""
-
-from dateutil.parser import parse
-from dateutil.tz import tzutc
-
-from twisted.words.protocols.jabber.jid import InvalidFormat, JID
-from twisted.words.xish import domish
-
-NS_DELAY = 'urn:xmpp:delay'
-NS_JABBER_DELAY = 'jabber:x:delay'
-
-class Delay(object):
-    """
-    Delayed Delivery information.
-
-    Instances of this class represent delayed delivery information that can be
-    parsed from and rendered into both XEP-0203 and legacy XEP-0091 formats.
-
-    @ivar stamp: The timestamp the stanza was originally sent.
-    @type stamp: L{datetime.datetime}
-    @ivar sender: The optional entity that originally sent the stanza or
-        delayed its delivery.
-    @type sender: L{JID}
-    """
-
-    def __init__(self, stamp, sender=None):
-        self.stamp = stamp
-        self.sender = sender
-
-
-    def toElement(self, legacy=False):
-        """
-        Render this instance into a domish Element.
-
-        @param legacy: If C{True}, use the legacy XEP-0091 format.
-        @type legacy: C{bool}
-        """
-        if not self.stamp:
-            raise ValueError("stamp is required")
-        if self.stamp.tzinfo is None:
-            raise ValueError("stamp is not offset-aware")
-
-        if legacy:
-            element = domish.Element((NS_JABBER_DELAY, 'x'))
-            stampFormat = '%Y%m%dT%H:%M:%S'
-        else:
-            element = domish.Element((NS_DELAY, 'delay'))
-            stampFormat = '%Y-%m-%dT%H:%M:%SZ'
-
-        stamp = self.stamp.astimezone(tzutc())
-        element['stamp'] = stamp.strftime(stampFormat)
-
-        if self.sender:
-            element['from'] = self.sender.full()
-
-        return element
-
-
-    @staticmethod
-    def fromElement(element):
-        """
-        Create an instance from a domish Element.
-        """
-        try:
-            stamp = parse(element[u'stamp'])
-
-            # Assume UTC if no timezone was given
-            if stamp.tzinfo is None:
-                stamp = stamp.replace(tzinfo=tzutc())
-        except (KeyError, ValueError, TypeError):
-            stamp = None
-
-        try:
-            sender = JID(element[u'from'])
-        except (KeyError, InvalidFormat):
-            sender = None
-
-        delay = Delay(stamp, sender)
-        return delay
-
-
-
-class DelayMixin(object):
-    """
-    Mixin for parsing delayed delivery information from stanzas.
-
-    This can be used as a mixin for subclasses of L{wokkel.generic.Stanza}
-    for parsing delayed delivery information. If both XEP-0203 and XEP-0091
-    formats are present, the former takes precedence.
-    """
-
-    delay = None
-
-    childParsers = {
-            (NS_DELAY, 'delay'): '_childParser_delay',
-            (NS_JABBER_DELAY, 'x'): '_childParser_legacyDelay',
-            }
-
-
-    def _childParser_delay(self, element):
-        self.delay = Delay.fromElement(element)
-
-
-    def _childParser_legacyDelay(self, element):
-        if not self.delay:
-            self.delay = Delay.fromElement(element)