Exemplo n.º 1
0
 def import_models():
     """Performs collision resolving and imports all models.
     When collisions are resolved we can perform imports and print information's, because it is last phase.
     This function updates imported_objects dictionary.
     """
     modules_to_models = CollisionResolvingRunner().run_collision_resolver(
         get_dict_from_names_to_possible_models())
     for full_module_path, models in modules_to_models.items():
         model_labels = []
         for (model_name, alias) in sorted(models):
             try:
                 imported_objects[alias] = import_string(
                     "%s.%s" % (full_module_path, model_name))
                 if model_name == alias:
                     model_labels.append(model_name)
                 else:
                     model_labels.append("%s (as %s)" % (model_name, alias))
             except ImportError as e:
                 if options.get("traceback"):
                     traceback.print_exc()
                 if not options.get('quiet_load'):
                     print(
                         style.ERROR(
                             "Failed to import '%s' from '%s' reason: %s" %
                             (model_name, full_module_path, str(e))))
         if not options.get('quiet_load'):
             print(
                 style.SQL_COLTYPE(
                     "from %s import %s" %
                     (full_module_path, ", ".join(model_labels))))
Exemplo n.º 2
0
 def import_models():
     """
     Perform collision resolving and imports all models.
     When collisions are resolved we can perform imports and print information's, because it is last phase.
     This function updates imported_objects dictionary.
     """
     modules_to_models = CollisionResolvingRunner().run_collision_resolver(get_dict_from_names_to_possible_models())
     perform_automatic_imports(modules_to_models)
Exemplo n.º 3
0
 def import_models():
     """Performs collision resolving and imports all models.
     When collisions are resolved we can perform imports and print information's, because it is last phase.
     This function updates imported_objects dictionary.
     """
     modules_to_models = CollisionResolvingRunner().run_collision_resolver(get_dict_from_names_to_possible_models())
     for full_module_path, models in modules_to_models.items():
         model_labels = []
         for (model_name, alias) in sorted(models):
             try:
                 imported_objects[alias] = import_string("%s.%s" % (full_module_path, model_name))
                 if model_name == alias:
                     model_labels.append(model_name)
                 else:
                     model_labels.append("%s (as %s)" % (model_name, alias))
             except ImportError as e:
                 if options.get("traceback"):
                     traceback.print_exc()
                 if not options.get('quiet_load'):
                     print(style.ERROR(
                         "Failed to import '%s' from '%s' reason: %s" % (model_name, full_module_path, str(e))))
         if not options.get('quiet_load'):
             print(style.SQL_COLTYPE("from %s import %s" % (full_module_path, ", ".join(model_labels))))