<commit_before>"""
    SleekXMPP: The Sleek XMPP Library
    Copyright (C) 2010 <NAME>
    This file is part of SleekXMPP.

    See the file LICENSE for copying permission.
"""

import logging

import sleekxmpp
from sleekxmpp import Iq
from sleekxmpp.xmlstream import register_stanza_plugin
from sleekxmpp.xmlstream.handler import Callback
from sleekxmpp.xmlstream.matcher import StanzaPath
from sleekxmpp.plugins.base import base_plugin
from sleekxmpp.plugins.xep_0092 import Version


log = logging.getLogger(__name__)


class xep_0092(base_plugin):

    """
    XEP-0092: Software Version
    """

    def plugin_init(self):
        """
        Start the XEP-0092 plugin.
        """
        self.xep = "0092"
        self.description = "Software Version"
        self.stanza = sleekxmpp.plugins.xep_0092.stanza

        self.name = self.config.get('name', 'SleekXMPP')
        self.version = self.config.get('version', '0.1-dev')
        self.os = self.config.get('os', '')

        self.getVersion = self.get_version

        self.xmpp.register_handler(
                Callback('Software Version',
                         StanzaPath('iq/software_version'),
                         self._handle_version))

        register_stanza_plugin(Iq, Version)

    def post_init(self):
        """
        Handle cross-plugin dependencies.
        """
        base_plugin.post_init(self)
        self.xmpp.plugin['xep_0030'].add_feature('jabber:iq:version')

    def _handle_version(self, iq):
        """
        Respond to a software version query.

        Arguments:
            iq -- The Iq stanza containing the software version query.
        """
        iq.reply()
        iq['software_version']['name'] = self.name
        iq['software_version']['version'] = self.version
        iq['software_version']['os'] = self.os
        iq.send()

    def get_version(self, jid, ifrom=None):
        """
        Retrieve the software version of a remote agent.

        Arguments:
            jid -- The JID of the entity to query.
        """
        iq = self.xmpp.Iq()
        iq['to'] = jid
        if ifrom:
            iq['from'] = ifrom
        iq['type'] = 'get'
        iq['query'] = Version.namespace

        result = iq.send()

        if result and result['type'] != 'error':
            return result['software_version'].values
        return False
<commit_msg>Avoid infinite loop on version result<commit_after>"""
    SleekXMPP: The Sleek XMPP Library
    Copyright (C) 2010 <NAME>
    This file is part of SleekXMPP.

    See the file LICENSE for copying permission.
"""

import logging

import sleekxmpp
from sleekxmpp import Iq
from sleekxmpp.xmlstream import register_stanza_plugin
from sleekxmpp.xmlstream.handler import Callback
from sleekxmpp.xmlstream.matcher import StanzaPath
from sleekxmpp.plugins.base import base_plugin
from sleekxmpp.plugins.xep_0092 import Version


log = logging.getLogger(__name__)


class xep_0092(base_plugin):

    """
    XEP-0092: Software Version
    """

    def plugin_init(self):
        """
        Start the XEP-0092 plugin.
        """
        self.xep = "0092"
        self.description = "Software Version"
        self.stanza = sleekxmpp.plugins.xep_0092.stanza

        self.name = self.config.get('name', 'SleekXMPP')
        self.version = self.config.get('version', '0.1-dev')
        self.os = self.config.get('os', '')

        self.getVersion = self.get_version

        self.xmpp.register_handler(
                Callback('Software Version',
                         StanzaPath('iq@=get/software_version'),
                         self._handle_version))

        register_stanza_plugin(Iq, Version)

    def post_init(self):
        """
        Handle cross-plugin dependencies.
        """
        base_plugin.post_init(self)
        self.xmpp.plugin['xep_0030'].add_feature('jabber:iq:version')

    def _handle_version(self, iq):
        """
        Respond to a software version query.

        Arguments:
            iq -- The Iq stanza containing the software version query.
        """
        iq.reply()
        iq['software_version']['name'] = self.name
        iq['software_version']['version'] = self.version
        iq['software_version']['os'] = self.os
        iq.send()

    def get_version(self, jid, ifrom=None):
        """
        Retrieve the software version of a remote agent.

        Arguments:
            jid -- The JID of the entity to query.
        """
        iq = self.xmpp.Iq()
        iq['to'] = jid
        if ifrom:
            iq['from'] = ifrom
        iq['type'] = 'get'
        iq['query'] = Version.namespace

        result = iq.send()

        if result and result['type'] != 'error':
            return result['software_version'].values
        return False

{'fraction_non_alphanumeric': 0.11066862293020331, 'fraction_numerical': 0.014252777195556487, 'mean_word_length': 2.2026845637583894, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '351162', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1407, 'n_words': 337}