# 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

def get_app_label(module):
    return get_app_path(module).rsplit('.', 1)[-1]


_pending_reference_lookups = {}

def get_by_ref(s, callback, module=None, app_label=None, field=None):
    if '@' in s:
        model, module_name = s.split('@')
        if module_name:
            app_label = None
            module = module_name
        if '.' in name:
            model, field = name.split('.')
    else:
        bits = s.rsplit('.', 3)
        if len(bits) == 1:
            model = bits[0]
        elif len(bits) == 2:
            app_label, model = bits
        else:
            app_label, model, field = bits
    
    if module and not app_label:
        app_label = get_app_label(module)        
    
    if app_label:
        model = get_model(app_label, model)
    else:

# 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


def get_app_label(module):
    return get_app_path(module).rsplit('.', 1)[-1]


_pending_reference_lookups = {}

def get_by_ref(s, callback, module=None, app_label=None, field=None):
    if '@' in s:
        model, module_name = s.split('@')
        if module_name:
            app_label = None
            module = module_name
        if '.' in name:
            model, field = name.split('.')
    else:
        bits = s.rsplit('.', 3)
        if len(bits) == 1:
            model = bits[0]
        elif len(bits) == 2:
            app_label, model = bits
        else:
            app_label, model, field = bits
    
    if module and not app_label:
        app_label = get_app_label(module)        
    
    if app_label:
        model = get_model(app_label, model)
    else:

        for m in get_model():