<commit_before>from twisted.python import log
from twisted.python.log import logging
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet import reactor
from twisted.words.protocols.jabber.jid import JID
from twisted.words.xish import domish
from twisted.words.xish.domish import Element as DomishElement
from twisted.application.service import MultiService
from getpass import getpass

from wokkel import client
from wokkel.xmppim import RosterClientProtocol, MessageProtocol, PresenceClientProtocol, PresenceProtocol

from datetime import datetime

from vumi.service import Worker, Publisher
from vumi.message import Message

class TransportRosterClientProtocol(RosterClientProtocol):
    
    def connectionMade(self):
        reactor.callLater(2, self.getRoster)
    
class TransportPresenceClientProtocol(PresenceClientProtocol):
    """
    A custom presence protocol to automatically accept any subscription
    attempt.
    """
    
    def subscribeReceived(self, entity):
        self.subscribe(entity)
        self.subscribed(entity)
    
    def unsubscribeReceived(self, entity):
        self.unsubscribe(entity)
        self.unsubscribed(entity)
    
class XMPPTransportProtocol(MessageProtocol):
    def __init__(self, jid, publisher):
        super(MessageProtocol, self).__init__()
        self.jid = jid
        self.publisher = publisher
        self.routing_key = "%s.%s" % (self.publisher.routing_key, 
                                        self.jid.userhost())<commit_msg>only fetch roster after proper init<commit_after>from twisted.python import log
from twisted.python.log import logging
from twisted.internet.defer import inlineCallbacks, returnValue
from twisted.internet import reactor
from twisted.words.protocols.jabber.jid import JID
from twisted.words.xish import domish
from twisted.words.xish.domish import Element as DomishElement
from twisted.application.service import MultiService
from getpass import getpass

from wokkel import client
from wokkel.xmppim import RosterClientProtocol, MessageProtocol, PresenceClientProtocol, PresenceProtocol

from datetime import datetime

from vumi.service import Worker, Publisher
from vumi.message import Message

class TransportRosterClientProtocol(RosterClientProtocol):
    
    def connectionInitialized(self):
        self.getRoster()
    
class TransportPresenceClientProtocol(PresenceClientProtocol):
    """
    A custom presence protocol to automatically accept any subscription
    attempt.
    """
    
    def subscribeReceived(self, entity):
        self.subscribe(entity)
        self.subscribed(entity)
    
    def unsubscribeReceived(self, entity):
        self.unsubscribe(entity)
        self.unsubscribed(entity)
    
class XMPPTransportProtocol(MessageProtocol):
    def __init__(self, jid, publisher):
        super(MessageProtocol, self).__init__()
        self.jid = jid
        self.publisher = publisher
        self.routing_key = "%s.%s" % (self.publisher.routing_key, 
                                        self.jid.userhost())
{'fraction_non_alphanumeric': 0.06716661232474731, 'fraction_numerical': 0.00032605151613955004, 'mean_word_length': 3.734567901234568, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3493448', 'n_tokens_mistral': 803, 'n_tokens_neox': 794, 'n_words': 217}