# Path: shrubbery/utils/text.py
# def camel_case(s, initial_cap=None):
#     s = _camel_case_re.sub(lambda m: m.group(1).upper(), s)
#     if initial_cap is not None:
#         if initial_cap:
#             s = s[0].upper() + s[1:]
#         else:
#             s = s[0].lower() + s[1:]
#     return s


import re
from django.db import models
from shrubbery.utils.text import camel_case
        from django.db.models.loading import get_model
        from django.db.models.loading import get_models
        pattern = re.compile(pattern)
    fields = []
    for field in model._meta.fields:
        if isinstance(field, (models.TextField, models.CharField)):
            fields.append(field.name)
    for obj in get_query_set(model):
        for field in fields:
            val = getattr(obj, field)
            if val and pattern.search(val):
                val = pattern.sub(replacement, val)
                setattr(obj, field, val)
                obj.save()


def unordered_pairs(qs):
    objects = list(qs.order_by())
    for a in objects:
        for b in objects:
            if b.pk > a.pk:
                yield a, b


def create_intermediate_model(cls, rel_name, attrs, bases=None, meta=None):
    if not meta:
        meta = {}
    if not bases:
        bases = (models.Model,)
    meta.setdefault('app_label', cls._meta.app_label)    
    attrs['Meta'] = type('Meta', (object,), meta)
    attrs.setdefault('__module__', cls.__module__)

# Path: shrubbery/utils/text.py
# def camel_case(s, initial_cap=None):
#     s = _camel_case_re.sub(lambda m: m.group(1).upper(), s)
#     if initial_cap is not None:
#         if initial_cap:
#             s = s[0].upper() + s[1:]
#         else:
#             s = s[0].lower() + s[1:]
#     return s


# Path: shrubbery/db/utils.py
import re
from django.db import models
from shrubbery.utils.text import camel_case
        from django.db.models.loading import get_model
        from django.db.models.loading import get_models

        pattern = re.compile(pattern)
    fields = []
    for field in model._meta.fields:
        if isinstance(field, (models.TextField, models.CharField)):
            fields.append(field.name)
    for obj in get_query_set(model):
        for field in fields:
            val = getattr(obj, field)
            if val and pattern.search(val):
                val = pattern.sub(replacement, val)
                setattr(obj, field, val)
                obj.save()


def unordered_pairs(qs):
    objects = list(qs.order_by())
    for a in objects:
        for b in objects:
            if b.pk > a.pk:
                yield a, b


def create_intermediate_model(cls, rel_name, attrs, bases=None, meta=None):
    if not meta:
        meta = {}
    if not bases:
        bases = (models.Model,)
    meta.setdefault('app_label', cls._meta.app_label)    
    attrs['Meta'] = type('Meta', (object,), meta)
    attrs.setdefault('__module__', cls.__module__)

    return type("%s%s" % (cls.__name__, camel_case(rel_name, True)), bases, attrs)