def post_syncdb_run(sender, **kwargs):
    """Look for permissions.run in each app and call it.
    
    This function will wait till the last installed app, and then
    search for all permissions modules, and try to call a C{run} function
    in them if found.
    """
    post_syncdb_run.queued = getattr(post_syncdb_run, "processed", [])
    post_syncdb_run.perms_installed = getattr(
        post_syncdb_run, "perms_installed", False)

    app = sender.__name__.split(".models")[0]

    # installed!
    if app == "expedient.common.permissions":
        post_syncdb_run.perms_installed = True
        
    post_syncdb_run.queued.append(app)

    # need to wait until we syncdb the permissions app
    if post_syncdb_run.perms_installed:
        for app in post_syncdb_run.queued:
            logger.debug("Checking app %s for permissions" % app)
            try:
                mod = import_module("%s.permissions" % app)
            except ImportError as exc:
                msg = exc.args[0]
                if not msg.startswith('No module named') or\
                msg not in "permissions":
                    raise
                else:
                    continue
            try:
                mod.run()
                logger.debug("Ran permissions.run() for %s" % app)
            except AttributeError as exc:
                msg = "%s" % exc
                if msg == "'module' object has no attribute 'run'":
                    logger.warn(
                        "Function called 'run' missing from %s.permissions."\
                        " Skipping." % app
                    )
                else:
                    raise
        post_syncdb_run.queued = []
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/common/permissions/management.py/post_syncdb_run/swapped operands of `not in`