Did I find the right examples for you? yes no

All Samples(40)  |  Call(29)  |  Derive(0)  |  Import(11)

        def import_objects(options, style):
    # XXX: (Temporary) workaround for ticket #1796: force early loading of all
    # models from installed apps. (this is fixed by now, but leaving it here
    # for people using 0.96 or older trunk (pre [5919]) versions.
    from django.db.models.loading import get_models, get_apps
    mongoengine = False
    try:
        from mongoengine.base import _document_registry
        mongoengine = True
    except:
        pass

    loaded_models = get_models()  # NOQA

    from django.conf import settings
    imported_objects = {}

    dont_load_cli = options.get('dont_load')  # optparse will set this to [] if it doensnt exists
    dont_load_conf = getattr(settings, 'SHELL_PLUS_DONT_LOAD', [])
    dont_load = dont_load_cli + dont_load_conf
    quiet_load = options.get('quiet_load')

    model_aliases = getattr(settings, 'SHELL_PLUS_MODEL_ALIASES', {})

    # Perform pre-imports before any other imports
    imports = import_items(getattr(settings, 'SHELL_PLUS_PRE_IMPORTS', {}))
    for k, v in six.iteritems(imports):
        imported_objects[k] = v

    load_models = {}

    if getattr(settings, 'SHELL_PLUS_DJANGO_IMPORTS', True):
        load_models.update({
            'django.core.cache': ['cache'],
            'django.core.urlresolvers': ['reverse'],
            'django.conf': ['settings'],
            'django.db': ['transaction'],
            'django.db.models': ['Avg', 'Count', 'F', 'Max', 'Min', 'Sum', 'Q'],
            'django.utils': ['timezone'],
        })

    if mongoengine:
        for name, mod in six.iteritems(_document_registry):
            name = name.split('.')[-1]
            app_name = mod.__module__.split('.')[-2]
            if app_name in dont_load or ("%s.%s" % (app_name, name)) in dont_load:
                continue

            load_models.setdefault(mod.__module__, [])
            load_models[mod.__module__].append(name)

    for app_mod in get_apps():
        app_models = get_models(app_mod)
        if not app_models:
            continue

        app_name = app_mod.__name__.split('.')[-2]
        if app_name in dont_load:
            continue

        app_aliases = model_aliases.get(app_name, {})
        for mod in app_models:
            if "%s.%s" % (app_name, mod.__name__) in dont_load:
                continue

            load_models.setdefault(mod.__module__, [])
            load_models[mod.__module__].append(mod.__name__)

    for app_mod, models in sorted(six.iteritems(load_models)):
        app_name = app_mod.split('.')[-2]
        app_aliases = model_aliases.get(app_name, {})
        model_labels = []

        for model_name in sorted(models):
            try:
                imported_object = getattr(__import__(app_mod, {}, {}, model_name), model_name)

                if "%s.%s" % (app_name, model_name) in dont_load:
                    continue

                alias = app_aliases.get(model_name, model_name)
                imported_objects[alias] = imported_object
                if model_name == alias:
                    model_labels.append(model_name)
                else:
                    model_labels.append("%s (as %s)" % (model_name, alias))

            except AttributeError as e:
                if options.get("traceback"):
                    traceback.print_exc()
                if not quiet_load:
                    print(style.ERROR("Failed to import '%s' from '%s' reason: %s" % (model_name, app_mod, str(e))))
                continue

        if not quiet_load:
            print(style.SQL_COLTYPE("from %s import %s" % (app_mod, ", ".join(model_labels))))

    # Perform post-imports after any other imports
    imports = import_items(getattr(settings, 'SHELL_PLUS_POST_IMPORTS', {}))
    for k, v in six.iteritems(imports):
        imported_objects[k] = v

    return imported_objects
        


src/r/o/rolf-HEAD/ve/lib/python2.7/site-packages/django_extensions/management/notebook_extension.py   rolf(Download)
def load_ipython_extension(ipython):
    from django.core.management.color import no_style
    from django_extensions.management.shells import import_objects
    imported_objects = import_objects(options={'dont_load': []},
                                      style=no_style())

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/django_extensions/management/notebook_extension.py   antisocial(Download)
def load_ipython_extension(ipython):
    from django.core.management.color import no_style
    from django_extensions.management.shells import import_objects
    imported_objects = import_objects(options={'dont_load': []},
                                      style=no_style())

src/k/a/ka-lite-HEAD/python-packages/django_extensions/management/notebook_extension.py   ka-lite(Download)
def load_ipython_extension(ipython):
    from django.core.management.color import no_style
    from django_extensions.management.shells import import_objects
    imported_objects = import_objects(options={'dont_load': []},
                                      style=no_style())

src/d/j/django-extensions-1.3.3/django_extensions/management/notebook_extension.py   django-extensions(Download)
def load_ipython_extension(ipython):
    from django.core.management.color import no_style
    from django_extensions.management.shells import import_objects
    imported_objects = import_objects(options={'dont_load': []},
                                      style=no_style())

src/d/j/django-extensions-HEAD/django_extensions/management/notebook_extension.py   django-extensions(Download)
def load_ipython_extension(ipython):
    from django.core.management.color import no_style
    from django_extensions.management.shells import import_objects
    imported_objects = import_objects(options={'dont_load': []},
                                      style=no_style())

src/k/a/ka-lite-HEAD/python-packages/django_extensions/management/commands/shell_plus.py   ka-lite(Download)
import os
from django.core.management.base import NoArgsCommand
from django_extensions.management.shells import import_objects
from optparse import make_option
import time
                    raise ImportError
                from bpython import embed
                imported_objects = import_objects(options, self.style)
                embed(imported_objects)
            except ImportError:
                    else:
                        from IPython import embed
                        imported_objects = import_objects(options, self.style)
                        embed(user_ns=imported_objects)
                except ImportError:
                    try:
                        from IPython.Shell import IPShell
                        imported_objects = import_objects(options, self.style)
                        shell = IPShell(argv=[], user_ns=imported_objects)
                        shell.mainloop()
            # Using normal Python shell
            import code
            imported_objects = import_objects(options, self.style)
            try:
                # Try activating rlcompleter, because it's handy.

src/r/o/rolf-HEAD/ve/lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.py   rolf(Download)
from django.conf import settings
 
from django_extensions.management.shells import import_objects
 
 
        def run_plain():
            # Using normal Python shell
            import code
            imported_objects = import_objects(options, self.style)
            try:
        def run_bpython():
            from bpython import embed
            imported_objects = import_objects(options, self.style)
            embed(imported_objects)
 
        def run_ipython():
            try:
                from IPython import embed
                imported_objects = import_objects(options, self.style)
                # Notebook not supported for IPython < 0.11.
                from IPython.Shell import IPShell
                imported_objects = import_objects(options, self.style)
                shell = IPShell(argv=[], user_ns=imported_objects)
                shell.mainloop()

src/a/n/antisocial-HEAD/ve/lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.py   antisocial(Download)
from django.conf import settings
 
from django_extensions.management.shells import import_objects
 
 
        def run_plain():
            # Using normal Python shell
            import code
            imported_objects = import_objects(options, self.style)
            try:
        def run_bpython():
            from bpython import embed
            imported_objects = import_objects(options, self.style)
            embed(imported_objects)
 
        def run_ipython():
            try:
                from IPython import embed
                imported_objects = import_objects(options, self.style)
                # Notebook not supported for IPython < 0.11.
                from IPython.Shell import IPShell
                imported_objects = import_objects(options, self.style)
                shell = IPShell(argv=[], user_ns=imported_objects)
                shell.mainloop()

src/d/j/django-extensions-1.3.3/django_extensions/management/commands/shell_plus.py   django-extensions(Download)
from django.conf import settings
 
from django_extensions.management.shells import import_objects
 
 
        def run_plain():
            # Using normal Python shell
            import code
            imported_objects = import_objects(options, self.style)
            try:
        def run_bpython():
            from bpython import embed
            imported_objects = import_objects(options, self.style)
            embed(imported_objects)
 
        def run_ipython():
            try:
                from IPython import embed
                imported_objects = import_objects(options, self.style)
                # Notebook not supported for IPython < 0.11.
                from IPython.Shell import IPShell
                imported_objects = import_objects(options, self.style)
                shell = IPShell(argv=[], user_ns=imported_objects)
                shell.mainloop()

src/o/i/oioioi-HEAD/oioioi/base/management/commands/shell.py   oioioi(Download)
from django.core.management.base import NoArgsCommand
 
from django_extensions.management.shells import import_objects
 
 
        def run_plain():
            # Using normal Python shell
            import code
            imported_objects = import_objects(options, self.style)
            try:
        def run_bpython():
            from bpython import embed
            imported_objects = import_objects(options, self.style)
            embed(imported_objects)
 
        def run_ipython():
            try:
                from IPython import embed
                imported_objects = import_objects(options, self.style)
                # Notebook not supported for IPython < 0.11.
                from IPython.Shell import IPShell
                imported_objects = import_objects(options, self.style)
                shell = IPShell(argv=[], user_ns=imported_objects)
                shell.mainloop()

  1 | 2  Next