<commit_before>"""
Command that will allow for a user to inject triples into a database.
"""
from rhobot.components.commands.base_command import BaseCommand
from rdflib.namespace import FOAF
from rhobot.namespace import RHO
import logging

logger = logging.getLogger(__name__)

class FindOwner(BaseCommand):

    def initialize_command(self):
        super(FindOwner, self).initialize_command()

        logger.info('Initialize Command')
        self._initialize_command(identifier='find_owner', name='Find Owner',
                                 additional_dependencies={'rho_bot_storage_client'})

    def command_start(self, request, initial_session):
        """
        Provide the configuration details back to the requester and end the command.
        :param request:
        :param initial_session:
        :return:
        """

        storage = self.xmpp['rho_bot_storage_client'].create_payload()
        storage.add_type(FOAF.Person, RHO.Owner)

        results = self.xmpp['rho_bot_storage_client'].find_nodes(storage)

        initial_session['payload'] = results.populate_payload()
        initial_session['next'] = None
        initial_session['has_next'] = False

        return initial_session

find_owner = FindOwner<commit_msg>Refactor find owner command<commit_after>"""
Command that will allow for a user to inject triples into a database.
"""
from rhobot.components.commands.base_command import BaseCommand
from rdflib.namespace import FOAF
from rhobot.namespace import RHO
import logging

logger = logging.getLogger(__name__)

class FindOwner(BaseCommand):

    def initialize_command(self):
        super(FindOwner, self).initialize_command()

        logger.info('Initialize Command')
        self._initialize_command(identifier='find_owner', name='Find Owner',
                                 additional_dependencies={'rho_bot_storage_client', 'rho_bot_scheduler', })

    def command_start(self, request, initial_session):
        """
        Provide the configuration details back to the requester and end the command.
        :param request:
        :param initial_session:
        :return:
        """

        storage = self.xmpp['rho_bot_storage_client'].create_payload()
        storage.add_type(FOAF.Person, RHO.Owner)

        results = self.xmpp['rho_bot_storage_client'].find_nodes(storage)

        initial_session['payload'] = results.populate_payload()
        initial_session['next'] = None
        initial_session['has_next'] = False

        promise = self.xmpp['rho_bot_scheduler'].promise()

        promise.resolved(initial_session)

        return promise

find_owner = FindOwner
{'fraction_non_alphanumeric': 0.09201520912547528, 'fraction_numerical': 0.0, 'mean_word_length': 3.36318407960199, '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': '4926778', 'n_tokens_mistral': 713, 'n_tokens_neox': 696, 'n_words': 164}