當前位置: 首頁>>代碼示例>>Python>>正文


Python text.camel_case_to_spaces方法代碼示例

本文整理匯總了Python中django.utils.text.camel_case_to_spaces方法的典型用法代碼示例。如果您正苦於以下問題:Python text.camel_case_to_spaces方法的具體用法?Python text.camel_case_to_spaces怎麽用?Python text.camel_case_to_spaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.utils.text的用法示例。


在下文中一共展示了text.camel_case_to_spaces方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate_handler_stub

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def generate_handler_stub(router, handler_template=HANDLER_TEMPLATE):
    output = StringIO()
    func_name_to_operation = {}
    for path in router.get_paths():
        for operation in path.get_operations():
            snake_operation_id = camel_case_to_spaces(operation.id).replace(' ', '_')
            func_name_to_operation[snake_operation_id] = operation
    for func_name, operation in sorted(func_name_to_operation.items()):
        parameter_names = [p['name'] for p in operation.parameters]
        handler = handler_template.format(
            func_name=func_name,
            operation_id=operation.id,
            parameters=', '.join(parameter_names),
        )
        output.write(handler)
        output.write('\n\n\n')
    return output.getvalue() 
開發者ID:apinf,項目名稱:ml-rest,代碼行數:19,代碼來源:codegen.py

示例2: _update_from_name

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def _update_from_name(self, name):
        self.name = name
        self.verbose_name = self.verbose_name or camel_case_to_spaces(name)
        self.verbose_name_plural = self.verbose_name_plural or self.verbose_name + 's' 
開發者ID:whyflyru,項目名稱:django-seo,代碼行數:6,代碼來源:options.py

示例3: decamel

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def decamel(value):
    try:
        return camel_case_to_spaces(value)
    except:
        return value 
開發者ID:opentaps,項目名稱:opentaps_seas,代碼行數:7,代碼來源:core_tags.py

示例4: _update_from_name

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def _update_from_name(self, name):
        self.name = name
        self.verbose_name = self.verbose_name or camel_case_to_spaces(name)
        self.verbose_name_plural = (self.verbose_name_plural or
                                    self.verbose_name + 's') 
開發者ID:romansalin,項目名稱:django-seo2,代碼行數:7,代碼來源:options.py

示例5: mutation_parameters

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def mutation_parameters() -> dict:
    dict_params = {
        'login': LoginMutation.Field(),
        'logout': LogoutMutation.Field(),
    }
    dict_params.update((camel_case_to_spaces(n).replace(' ', '_'), mut.Field())
                       for n, mut in registry.forms.items())
    return dict_params 
開發者ID:tr11,項目名稱:wagtail-graphql,代碼行數:10,代碼來源:schema.py

示例6: snake_case

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def snake_case(string):
    return camel_case_to_spaces(string).replace(' ', '_') 
開發者ID:apinf,項目名稱:ml-rest,代碼行數:4,代碼來源:utils.py

示例7: captitle

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def captitle(title):
    return capfirst(camel_case_to_spaces(title)) 
開發者ID:byashimov,項目名稱:django-controlcenter,代碼行數:4,代碼來源:utils.py

示例8: contribute_to_class

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def contribute_to_class(self, cls, name):
        from django.db import connection
        from django.db.backends.utils import truncate_name

        cls._meta = self
        self.model = cls
        # First, construct the default values for these options.
        self.object_name = cls.__name__
        self.model_name = self.object_name.lower()
        self.verbose_name = camel_case_to_spaces(self.object_name)

        # Store the original user-defined values for each option,
        # for use when serializing the model definition
        self.original_attrs = {}

        # Next, apply any overridden values from 'class Meta'.
        if self.meta:
            meta_attrs = self.meta.__dict__.copy()
            for name in self.meta.__dict__:
                # Ignore any private attributes that Django doesn't care about.
                # NOTE: We can't modify a dictionary's contents while looping
                # over it, so we loop over the *original* dictionary instead.
                if name.startswith('_'):
                    del meta_attrs[name]
            for attr_name in DEFAULT_NAMES:
                if attr_name in meta_attrs:
                    setattr(self, attr_name, meta_attrs.pop(attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)
                elif hasattr(self.meta, attr_name):
                    setattr(self, attr_name, getattr(self.meta, attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)

            ut = meta_attrs.pop('unique_together', self.unique_together)
            self.unique_together = normalize_together(ut)

            it = meta_attrs.pop('index_together', self.index_together)
            self.index_together = normalize_together(it)

            # verbose_name_plural is a special case because it uses a 's'
            # by default.
            if self.verbose_name_plural is None:
                self.verbose_name_plural = string_concat(self.verbose_name, 's')

            # Any leftover attributes must be invalid.
            if meta_attrs != {}:
                raise TypeError("'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()))
        else:
            self.verbose_name_plural = string_concat(self.verbose_name, 's')
        del self.meta

        # If the db_table wasn't provided, use the app_label + model_name.
        if not self.db_table:
            self.db_table = "%s_%s" % (self.app_label, self.model_name)
            self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:56,代碼來源:options.py

示例9: contribute_to_class

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def contribute_to_class(self, cls, name):
        from django.db import connection
        from django.db.backends.utils import truncate_name

        cls._meta = self
        self.model = cls
        # First, construct the default values for these options.
        self.object_name = cls.__name__
        self.model_name = self.object_name.lower()
        self.verbose_name = camel_case_to_spaces(self.object_name)

        # Store the original user-defined values for each option,
        # for use when serializing the model definition
        self.original_attrs = {}

        # Next, apply any overridden values from 'class Meta'.
        if self.meta:
            meta_attrs = self.meta.__dict__.copy()
            for name in self.meta.__dict__:
                # Ignore any private attributes that Django doesn't care about.
                # NOTE: We can't modify a dictionary's contents while looping
                # over it, so we loop over the *original* dictionary instead.
                if name.startswith('_'):
                    del meta_attrs[name]
            for attr_name in DEFAULT_NAMES:
                if attr_name in meta_attrs:
                    setattr(self, attr_name, meta_attrs.pop(attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)
                elif hasattr(self.meta, attr_name):
                    setattr(self, attr_name, getattr(self.meta, attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)

            self.unique_together = normalize_together(self.unique_together)
            self.index_together = normalize_together(self.index_together)

            # verbose_name_plural is a special case because it uses a 's'
            # by default.
            if self.verbose_name_plural is None:
                self.verbose_name_plural = format_lazy('{}s', self.verbose_name)

            # order_with_respect_and ordering are mutually exclusive.
            self._ordering_clash = bool(self.ordering and self.order_with_respect_to)

            # Any leftover attributes must be invalid.
            if meta_attrs != {}:
                raise TypeError("'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs))
        else:
            self.verbose_name_plural = format_lazy('{}s', self.verbose_name)
        del self.meta

        # If the db_table wasn't provided, use the app_label + model_name.
        if not self.db_table:
            self.db_table = "%s_%s" % (self.app_label, self.model_name)
            self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:56,代碼來源:options.py

示例10: contribute_to_class

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def contribute_to_class(self, cls, name):
        from django.db import connection
        from django.db.backends.utils import truncate_name

        cls._meta = self
        self.model = cls
        # First, construct the default values for these options.
        self.object_name = cls.__name__
        self.model_name = self.object_name.lower()
        self.verbose_name = camel_case_to_spaces(self.object_name)

        # Store the original user-defined values for each option,
        # for use when serializing the model definition
        self.original_attrs = {}

        # Next, apply any overridden values from 'class Meta'.
        if self.meta:
            meta_attrs = self.meta.__dict__.copy()
            for name in self.meta.__dict__:
                # Ignore any private attributes that Django doesn't care about.
                # NOTE: We can't modify a dictionary's contents while looping
                # over it, so we loop over the *original* dictionary instead.
                if name.startswith('_'):
                    del meta_attrs[name]
            for attr_name in DEFAULT_NAMES:
                if attr_name in meta_attrs:
                    setattr(self, attr_name, meta_attrs.pop(attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)
                elif hasattr(self.meta, attr_name):
                    setattr(self, attr_name, getattr(self.meta, attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)

            self.unique_together = normalize_together(self.unique_together)
            self.index_together = normalize_together(self.index_together)

            # verbose_name_plural is a special case because it uses a 's'
            # by default.
            if self.verbose_name_plural is None:
                self.verbose_name_plural = format_lazy('{}s', self.verbose_name)

            # order_with_respect_and ordering are mutually exclusive.
            self._ordering_clash = bool(self.ordering and self.order_with_respect_to)

            # Any leftover attributes must be invalid.
            if meta_attrs != {}:
                raise TypeError("'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()))
        else:
            self.verbose_name_plural = format_lazy('{}s', self.verbose_name)
        del self.meta

        # If the db_table wasn't provided, use the app_label + model_name.
        if not self.db_table:
            self.db_table = "%s_%s" % (self.app_label, self.model_name)
            self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:56,代碼來源:options.py

示例11: contribute_to_class

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def contribute_to_class(self, cls, name):
        from django.db import connection
        from django.db.backends.utils import truncate_name

        cls._meta = self
        self.model = cls
        # First, construct the default values for these options.
        self.object_name = cls.__name__
        self.model_name = self.object_name.lower()
        self.verbose_name = camel_case_to_spaces(self.object_name)

        # Store the original user-defined values for each option,
        # for use when serializing the model definition
        self.original_attrs = {}

        # Next, apply any overridden values from 'class Meta'.
        if self.meta:
            meta_attrs = self.meta.__dict__.copy()
            for name in self.meta.__dict__:
                # Ignore any private attributes that Django doesn't care about.
                # NOTE: We can't modify a dictionary's contents while looping
                # over it, so we loop over the *original* dictionary instead.
                if name.startswith('_'):
                    del meta_attrs[name]
            for attr_name in DEFAULT_NAMES:
                if attr_name in meta_attrs:
                    setattr(self, attr_name, meta_attrs.pop(attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)
                elif hasattr(self.meta, attr_name):
                    setattr(self, attr_name, getattr(self.meta, attr_name))
                    self.original_attrs[attr_name] = getattr(self, attr_name)

            self.unique_together = normalize_together(self.unique_together)
            self.index_together = normalize_together(self.index_together)

            # verbose_name_plural is a special case because it uses a 's'
            # by default.
            if self.verbose_name_plural is None:
                self.verbose_name_plural = string_concat(self.verbose_name, 's')

            # order_with_respect_and ordering are mutually exclusive.
            self._ordering_clash = bool(self.ordering and self.order_with_respect_to)

            # Any leftover attributes must be invalid.
            if meta_attrs != {}:
                raise TypeError("'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()))
        else:
            self.verbose_name_plural = string_concat(self.verbose_name, 's')
        del self.meta

        # If the db_table wasn't provided, use the app_label + model_name.
        if not self.db_table:
            self.db_table = "%s_%s" % (self.app_label, self.model_name)
            self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) 
開發者ID:drexly,項目名稱:openhgsenti,代碼行數:56,代碼來源:options.py

示例12: _add_form

# 需要導入模塊: from django.utils import text [as 別名]
# 或者: from django.utils.text import camel_case_to_spaces [as 別名]
def _add_form(cls: Type[AbstractForm], node: str, dict_params: dict) -> Type[graphene.Mutation]:
    if node in registry.forms:  # pragma: no cover
        return registry.forms[node]

    registry.page_prefetch_fields.add(cls.__name__.lower())
    dict_params['Meta'].interfaces += (Page,)
    dict_params['form_fields'] = graphene.List(FormField)

    def form_fields(self, _info):
        return list(FormField(name=field_.clean_name, field_type=field_.field_type,
                              label=field_.label, required=field_.required,
                              help_text=field_.help_text, choices=field_.choices,
                              default_value=field_.default_value)
                    for field_ in self.form_fields.all())

    dict_params['resolve_form_fields'] = form_fields
    registry.pages[cls] = type(node, (DjangoObjectType,), dict_params)

    args = type("Arguments", (), {'values': GenericScalar(),
                                  "url": graphene.String(required=True)})
    _node = node

    def mutate(_self, info, url, values):
        url_prefix = url_prefix_for_site(info)
        query = wagtailPage.objects.filter(url_path=url_prefix + url.rstrip('/') + '/')
        instance = with_page_permissions(
            info.context,
            query.specific()
        ).live().first()
        user = info.context.user
        # convert camelcase to dashes
        values = {camel_case_to_spaces(k).replace(' ', '-'): v for k, v in values.items()}
        form = instance.get_form(values, None, page=instance, user=user)
        if form.is_valid():
            # form_submission
            instance.process_form_submission(form)
            return registry.forms[_node](result="OK")
        else:
            return registry.forms[_node](result="FAIL", errors=[FormError(*err) for err in form.errors.items()])

    dict_params = {
        "Arguments": args,
        "mutate": mutate,
        "result": graphene.String(),
        "errors": graphene.List(FormError),
    }
    tp = type(node + "Mutation", (graphene.Mutation,), dict_params)  # type: Type[graphene.Mutation]
    registry.forms[node] = tp
    return tp 
開發者ID:tr11,項目名稱:wagtail-graphql,代碼行數:51,代碼來源:actions.py


注:本文中的django.utils.text.camel_case_to_spaces方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。