<commit_before>import sys


class BaseRunner(object):
    def __init__(self, importer, persistance=None, **credentials):
        from contacts_import.settings import DEFAULT_PERSISTANCE
        if persistance is None:
            persistance = DEFAULT_PERSISTANCE
        self.importer = importer
        self.persistance = persistance
        self.credentials = credentials
    
    def import_contacts(self):
        raise NotImplementedError("Implement this in a subclass")


class SynchronousResult(object):
    """
    Very simple result to mimic what is needed of Celery's result
    """
    
    def __init__(self, importer, *args):
        self.importer = importer
        self.args = args
        self.status = "DONE"
    
    def run(self):
        self.result = self.importer().run(*self.args)
    
    def ready(self):
        return True


class SynchronousRunner(BaseRunner):
    def import_contacts(self):
        result = SynchronousResult(self.importer, self.credentials, self.persistance())
        result.run()
        return result


class AsyncRunner(BaseRunner):
    def import_contacts(self):
        return self.importer.delay(self.credentials, self.persistance())<commit_msg>SynchronousResult should only care about the result not running behavior<commit_after>import sys


class BaseRunner(object):
    def __init__(self, importer, persistance=None, **credentials):
        from contacts_import.settings import DEFAULT_PERSISTANCE
        if persistance is None:
            persistance = DEFAULT_PERSISTANCE
        self.importer = importer
        self.persistance = persistance
        self.credentials = credentials
    
    def import_contacts(self):
        raise NotImplementedError("Implement this in a subclass")


class SynchronousResult(object):
    """
    Very simple result to mimic what is needed of Celery's result
    """
    
    def __init__(self, result):
        self.result = result
        self.status = "DONE"
    
    def ready(self):
        return True


class SynchronousRunner(BaseRunner):
    def import_contacts(self):
        return SynchronousResult(
            self.importer().run(self.credentials, self.persistance())
        )


class AsyncRunner(BaseRunner):
    def import_contacts(self):
        return self.importer.delay(self.credentials, self.persistance())
{'fraction_non_alphanumeric': 0.08297506448839209, 'fraction_numerical': 0.0, 'mean_word_length': 2.9175084175084174, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5610553', 'n_tokens_mistral': 644, 'n_tokens_neox': 631, 'n_words': 162}