当前位置: 首页>>代码示例>>Python>>正文


Python Migrations.calculate_dependencies方法代码示例

本文整理汇总了Python中south.migration.Migrations.calculate_dependencies方法的典型用法代码示例。如果您正苦于以下问题:Python Migrations.calculate_dependencies方法的具体用法?Python Migrations.calculate_dependencies怎么用?Python Migrations.calculate_dependencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在south.migration.Migrations的用法示例。


在下文中一共展示了Migrations.calculate_dependencies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from south.migration import Migrations [as 别名]
# 或者: from south.migration.Migrations import calculate_dependencies [as 别名]
    def handle(self, **options):
        
        # Resolve dependencies
        Migrations.calculate_dependencies()

        colors = [ 'crimson', 'darkgreen', 'darkgoldenrod', 'navy',
                'brown', 'darkorange', 'aquamarine' , 'blueviolet' ]
        color_index = 0
        wrapper = textwrap.TextWrapper(width=40)
        
        print("digraph G {")
        
        # Group each app in a subgraph
        for migrations in all_migrations():
            print("  subgraph %s {" % migrations.app_label())
            print("    node [color=%s];" % colors[color_index])
            for migration in migrations:
                # Munge the label - text wrap and change _ to spaces
                label = "%s - %s" % (
                        migration.app_label(), migration.name())
                label = re.sub(r"_+", " ", label)
                label=  "\\n".join(wrapper.wrap(label))
                print('    "%s.%s" [label="%s"];' % (
                        migration.app_label(), migration.name(), label))
            print("  }")
            color_index = (color_index + 1) % len(colors)

        # For every migration, print its links.
        for migrations in all_migrations():
            for migration in migrations:
                for other in migration.dependencies:
                    # Added weight tends to keep migrations from the same app
                    # in vertical alignment
                    attrs = "[weight=2.0]"
                    # But the more interesting edges are those between apps
                    if other.app_label() != migration.app_label():
                        attrs = "[style=bold]"
                    print('  "%s.%s" -> "%s.%s" %s;' % (
                        other.app_label(), other.name(),
                        migration.app_label(), migration.name(),
                        attrs
                    ))
            
        print("}");
开发者ID:takeiteasyguy,项目名称:django-project,代码行数:46,代码来源:graphmigrations.py

示例2: handle

# 需要导入模块: from south.migration import Migrations [as 别名]
# 或者: from south.migration.Migrations import calculate_dependencies [as 别名]
 def handle(self, **options):
     
     # Resolve dependencies
     Migrations.calculate_dependencies()
     
     print "digraph G {"
     
     # Print each app in a cluster
     #for migrations in all_migrations():
     #    print "  subgraph %s {" % migrations.app_label()
     #    # Nodes inside here are linked
     #    print (" -> ".join(['"%s.%s"' % (migration.app_label(), migration.name()) for migration in migrations])) + ";"
     #    print "  }"
 
     # For every migration, print its links.
     for migrations in all_migrations():
         for migration in migrations:
             for other in migration.dependencies:
                 print '"%s.%s" -> "%s.%s"' % (
                     other.app_label(), other.name(),
                     migration.app_label(), migration.name(),
                 )
         
     print "}";
开发者ID:jhelbert,项目名称:coshare,代码行数:26,代码来源:graphmigrations.py


注:本文中的south.migration.Migrations.calculate_dependencies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。