<commit_before>import importlib

from django.db.models.loading import get_apps
from sqjobs.utils import get_jobs_from_module

import logging
logger = logging.getLogger('sqjobs.contrib.django.utils')


def register_all_jobs(worker):
    """
    Register all the jobs in a worker
    """
    jobs = get_all_jobs()

    for job in jobs:
        worker.register_job(job)

    return jobs


def get_all_jobs():
    """
    Get all the jobs of the django INSTALLED_APPS
    """
    jobs = []

    for app in get_apps():
        try:
            module = importlib.import_module(app.__name__[:-6] + 'jobs')
            jobs.extend(get_jobs_from_module(module))
        except ImportError:
            pass

    return jobs
<commit_msg>Fixed support for Django 1.9 with @lonamiaec<commit_after>import importlib

from sqjobs.utils import get_jobs_from_module

import logging
logger = logging.getLogger('sqjobs.contrib.django.utils')


def get_apps():
    """
    copied from django-extensions compatibility sheam
    """
    try:
        # django >= 1.7, to support AppConfig
        from django.apps import apps
        return [app.models_module for app in apps.get_app_configs() if app.models_module]
    except ImportError:
        from django.db import models
        return models.get_apps()


def register_all_jobs(worker):
    """
    Register all the jobs in a worker
    """
    jobs = get_all_jobs()

    for job in jobs:
        worker.register_job(job)

    return jobs


def get_all_jobs():
    """
    Get all the jobs of the django INSTALLED_APPS
    """
    jobs = []

    for app in get_apps():
        try:
            module = importlib.import_module(app.__name__[:-6] + 'jobs')
            jobs.extend(get_jobs_from_module(module))
        except ImportError:
            pass

    return jobs

{'fraction_non_alphanumeric': 0.0886426592797784, 'fraction_numerical': 0.0033240997229916896, 'mean_word_length': 2.5833333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3091921', 'n_tokens_mistral': 569, 'n_tokens_neox': 537, 'n_words': 149}