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


Python color.no_style方法代码示例

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


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

示例1: drop_models_tables

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def drop_models_tables(
    database_name: str,
    style: Optional[Style] = None,
) -> None:
    """Drop all installed Django's models tables."""
    style = style or no_style()
    connection = connections[database_name]
    tables = connection.introspection.django_table_names(
        only_existing=True,
        include_views=False,
    )
    sql_drop_tables = [
        connection.SchemaEditorClass.sql_delete_table % {
            'table': style.SQL_FIELD(connection.ops.quote_name(table)),
        }
        for table in tables
    ]
    if sql_drop_tables:
        get_execute_sql_flush_for(connection)(database_name, sql_drop_tables) 
开发者ID:wemake-services,项目名称:django-test-migrations,代码行数:21,代码来源:sql.py

示例2: apply_initial_migration

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def apply_initial_migration(self, targets: MigrationSpec) -> ProjectState:
        """Reverse back to the original migration."""
        targets = normalize(targets)

        style = no_style()
        # start from clean database state
        sql.drop_models_tables(self._database, style)
        sql.flush_django_migrations_table(self._database, style)

        # prepare as broad plan as possible based on full plan
        self._executor.loader.build_graph()  # reload
        full_plan = self._executor.migration_plan(
            self._executor.loader.graph.leaf_nodes(),
            clean_start=True,
        )
        plan = truncate_plan(targets, full_plan)

        # apply all migrations from generated plan on clean database
        # (only forward, so any unexpected migration won't be applied)
        # to restore database state before tested migration
        return self._migrate(targets, plan=plan) 
开发者ID:wemake-services,项目名称:django-test-migrations,代码行数:23,代码来源:migrator.py

示例3: test_sequence_name_length_limits_flush

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def test_sequence_name_length_limits_flush(self):
        """
        Sequence resetting as part of a flush with model with long name and
        long pk name doesn't error (#8901).
        """
        # A full flush is expensive to the full test, so we dig into the
        # internals to generate the likely offending SQL and run it manually

        # Some convenience aliases
        VLM = VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
        VLM_m2m = VLM.m2m_also_quite_long_zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.through
        tables = [
            VLM._meta.db_table,
            VLM_m2m._meta.db_table,
        ]
        sequences = [
            {
                'column': VLM._meta.pk.column,
                'table': VLM._meta.db_table
            },
        ]
        cursor = connection.cursor()
        for statement in connection.ops.sql_flush(no_style(), tables, sequences):
            cursor.execute(statement) 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:26,代码来源:tests.py

示例4: test_generic_relation

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def test_generic_relation(self):
        "Sequence names are correct when resetting generic relations (Ref #13941)"
        # Create an object with a manually specified PK
        Post.objects.create(id=10, name='1st post', text='hello world')

        # Reset the sequences for the database
        cursor = connection.cursor()
        commands = connections[DEFAULT_DB_ALIAS].ops.sequence_reset_sql(no_style(), [Post])
        for sql in commands:
            cursor.execute(sql)

        # If we create a new object now, it should have a PK greater
        # than the PK we specified manually.
        obj = Post.objects.create(name='New post', text='goodbye world')
        self.assertGreater(obj.pk, 10)


# This test needs to run outside of a transaction, otherwise closing the
# connection would implicitly rollback and cause problems during teardown. 
开发者ID:denisenkom,项目名称:django-sqlserver,代码行数:21,代码来源:tests.py

示例5: test_sequence_name_length_limits_flush

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def test_sequence_name_length_limits_flush(self):
        """
        Sequence resetting as part of a flush with model with long name and
        long pk name doesn't error (#8901).
        """
        # A full flush is expensive to the full test, so we dig into the
        # internals to generate the likely offending SQL and run it manually

        # Some convenience aliases
        VLM = VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
        VLM_m2m = VLM.m2m_also_quite_long_zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.through
        tables = [
            VLM._meta.db_table,
            VLM_m2m._meta.db_table,
        ]
        sequences = [
            {
                'column': VLM._meta.pk.column,
                'table': VLM._meta.db_table
            },
        ]
        sql_list = connection.ops.sql_flush(no_style(), tables, sequences)
        with connection.cursor() as cursor:
            for statement in sql_list:
                cursor.execute(statement) 
开发者ID:nesdis,项目名称:djongo,代码行数:27,代码来源:tests.py

示例6: test_generic_relation

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def test_generic_relation(self):
        "Sequence names are correct when resetting generic relations (Ref #13941)"
        # Create an object with a manually specified PK
        Post.objects.create(id=10, name='1st post', text='hello world')

        # Reset the sequences for the database
        commands = connections[DEFAULT_DB_ALIAS].ops.sequence_reset_sql(no_style(), [Post])
        with connection.cursor() as cursor:
            for sql in commands:
                cursor.execute(sql)

        # If we create a new object now, it should have a PK greater
        # than the PK we specified manually.
        obj = Post.objects.create(name='New post', text='goodbye world')
        self.assertGreater(obj.pk, 10)


# This test needs to run outside of a transaction, otherwise closing the
# connection would implicitly rollback and cause problems during teardown. 
开发者ID:nesdis,项目名称:djongo,代码行数:21,代码来源:tests.py

示例7: reset_sequences

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def reset_sequences(*models):
    """
    After loading data the sequences must be reset in the database if
    the primary keys are manually specified. This is handled
    automatically by django for fixtures.

    Much of this is modeled after django.core.management.commands.loaddata.
    """
    # connection = connections[DEFAULT_DB_ALIAS]
    # cursor = connection.cursor()
    # sequence_sql = connection.ops.sequence_reset_sql(no_style(), models)
    # if sequence_sql:
    #     for line in sequence_sql:
    #         cursor.execute(line)
    # # transaction.commit_unless_managed()
    # cursor.close()
    pass 
开发者ID:wise-team,项目名称:steemprojects.com,代码行数:19,代码来源:datautil.py

示例8: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def __init__(self, *args, **kwargs):
        super(Command, self).__init__(*args, **kwargs)
        self.copied_files = []
        self.symlinked_files = []
        self.unmodified_files = []
        self.post_processed_files = []
        self.storage = staticfiles_storage
        self.style = no_style()
        try:
            self.storage.path('')
        except NotImplementedError:
            self.local = False
        else:
            self.local = True 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:16,代码来源:collectstatic.py

示例9: create_default_site

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def create_default_site(app_config, verbosity=2, interactive=True, using=DEFAULT_DB_ALIAS, **kwargs):
    try:
        Site = apps.get_model('sites', 'Site')
    except LookupError:
        return

    if not router.allow_migrate_model(using, Site):
        return

    if not Site.objects.using(using).exists():
        # The default settings set SITE_ID = 1, and some tests in Django's test
        # suite rely on this value. However, if database sequences are reused
        # (e.g. in the test suite after flush/syncdb), it isn't guaranteed that
        # the next id will be 1, so we coerce it. See #15573 and #16353. This
        # can also crop up outside of tests - see #15346.
        if verbosity >= 2:
            print("Creating example.com Site object")
        Site(pk=getattr(settings, 'SITE_ID', 1), domain="example.com", name="example.com").save(using=using)

        # We set an explicit pk instead of relying on auto-incrementation,
        # so we need to reset the database sequence. See #17415.
        sequence_sql = connections[using].ops.sequence_reset_sql(no_style(), [Site])
        if sequence_sql:
            if verbosity >= 2:
                print("Resetting sequence")
            with connections[using].cursor() as cursor:
                for command in sequence_sql:
                    cursor.execute(command) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:30,代码来源:management.py

示例10: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def __init__(self, stdout=None, stderr=None, no_color=False):
        self.stdout = OutputWrapper(stdout or sys.stdout)
        self.stderr = OutputWrapper(stderr or sys.stderr)
        if no_color:
            self.style = no_style()
        else:
            self.style = color_style()
            self.stderr.style_func = self.style.ERROR

        # `requires_model_validation` is deprecated in favor of
        # `requires_system_checks`. If both options are present, an error is
        # raised. Otherwise the present option is used. If none of them is
        # defined, the default value (True) is used.
        has_old_option = hasattr(self, 'requires_model_validation')
        has_new_option = hasattr(self, 'requires_system_checks')

        if has_old_option:
            warnings.warn(
                '"requires_model_validation" is deprecated '
                'in favor of "requires_system_checks".',
                RemovedInDjango19Warning)
        if has_old_option and has_new_option:
            raise ImproperlyConfigured(
                'Command %s defines both "requires_model_validation" '
                'and "requires_system_checks", which is illegal. Use only '
                '"requires_system_checks".' % self.__class__.__name__)

        self.requires_system_checks = (
            self.requires_system_checks if has_new_option else
            self.requires_model_validation if has_old_option else
            True) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:33,代码来源:base.py

示例11: flush_django_migrations_table

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def flush_django_migrations_table(
    database_name: str,
    style: Optional[Style] = None,
) -> None:
    """Flush `django_migrations` table.

    Ensures compability with all supported Django versions.
    `django_migrations` is not "regular" Django model, so its not returned
    by ``ConnectionRouter.get_migratable_models`` which is used e.g. to
    implement sequences reset in ``Django==1.11``.

    """
    style = style or no_style()
    connection = connections[database_name]
    django_migrations_sequences = get_django_migrations_table_sequences(
        connection,
    )
    execute_sql_flush = get_execute_sql_flush_for(connection)
    execute_sql_flush(
        database_name,
        connection.ops.sql_flush(
            style,
            [DJANGO_MIGRATIONS_TABLE_NAME],
            django_migrations_sequences,
            allow_cascade=False,
        ),
    ) 
开发者ID:wemake-services,项目名称:django-test-migrations,代码行数:29,代码来源:sql.py

示例12: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.copied_files = []
        self.symlinked_files = []
        self.unmodified_files = []
        self.post_processed_files = []
        self.storage = staticfiles_storage
        self.style = no_style() 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:10,代码来源:collectstatic.py

示例13: _reset_sequences

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def _reset_sequences(self, db_name):
        conn = connections[db_name]
        if conn.features.supports_sequence_reset:
            sql_list = \
                conn.ops.sequence_reset_by_name_sql(no_style(),
                                                    conn.introspection.sequence_list())
            if sql_list:
                try:
                    cursor = conn.cursor()
                    for sql in sql_list:
                        cursor.execute(sql)
                except Exception:
                    transaction.rollback_unless_managed(using=db_name)
                    raise
                transaction.commit_unless_managed(using=db_name) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:17,代码来源:testcases.py

示例14: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def __init__(self, stdout=None, stderr=None, no_color=False):
        if self.binary_output is True:
            self.stdout = BinaryOutputWrapper(stdout or sys.stdout.buffer)
            self.stderr = BinaryOutputWrapper(stderr or sys.stderr.buffer)
            self.style = no_style()
        else:
            super(BaseCommand, self).__init__(stdout, stderr, no_color=no_color) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:9,代码来源:base.py

示例15: __init__

# 需要导入模块: from django.core.management import color [as 别名]
# 或者: from django.core.management.color import no_style [as 别名]
def __init__(self, *args, **kwargs):
        super(Command, self).__init__(*args, **kwargs)
        self.copied_files = []
        self.symlinked_files = []
        self.unmodified_files = []
        self.post_processed_files = []
        self.storage = staticfiles_storage
        self.style = no_style() 
开发者ID:bpgc-cte,项目名称:python2017,代码行数:10,代码来源:collectstatic.py


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