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


Python StringMethods.random_list_strings方法代码示例

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


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

示例1: _update_ca_attrs_values

# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import random_list_strings [as 别名]
 def _update_ca_attrs_values(self, obj, **attrs):
   """Update CA's (obj) attributes values according to dictionary of
   arguments (key = value). Restrictions: 'multi_choice_options' is a
   mandatory attribute for Dropdown CA and 'placeholder' is a attribute that
   exists only for Text and Rich Text CA.
   Generated data - 'obj', entered data - '**arguments'.
   """
   # fix generated data
   if attrs.get("attribute_type"):
     obj.title = self.generate_ca_title(attrs["attribute_type"])
   if (obj.multi_choice_options and
           obj.attribute_type == AdminWidgetCustomAttributes.DROPDOWN and
           attrs.get("attribute_type") !=
           AdminWidgetCustomAttributes.DROPDOWN):
     obj.multi_choice_options = None
   # fix entered data
   if (attrs.get("multi_choice_options") and
           attrs.get("attribute_type") !=
           AdminWidgetCustomAttributes.DROPDOWN):
     attrs["multi_choice_options"] = None
   if (attrs.get("placeholder") and attrs.get("attribute_type") not in
       (AdminWidgetCustomAttributes.TEXT,
        AdminWidgetCustomAttributes.RICH_TEXT)):
     attrs["placeholder"] = None
   # extend entered data
   if (attrs.get("attribute_type") ==
           AdminWidgetCustomAttributes.DROPDOWN and not
           obj.multi_choice_options):
     obj.multi_choice_options = StringMethods.random_list_strings()
   return obj.update_attrs(**attrs)
开发者ID:egorhm,项目名称:ggrc-core,代码行数:32,代码来源:entities_factory.py

示例2: generate_cad

# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import random_list_strings [as 别名]
 def generate_cad(cls, **attrs):
   """Creates multi-choice dropdown CAD for asmt template."""
   multi_choice_opts = {"file": "2", "url": "4", "comment": "1",
                        "file_url": "6", "url_comment": "5",
                        "file_comment": "3", "file_url_comment": "7",
                        "nothing": "0"}
   dropdown_types_list = attrs["dropdown_types_list"]
   cad_factory = CustomAttributeDefinitionsFactory()
   cad = cad_factory.create(
       attribute_type=AdminWidgetCustomAttributes.DROPDOWN,
       definition_type="",
       multi_choice_mandatory=(",".join(
           multi_choice_opts[dropdown_type]
           for dropdown_type in dropdown_types_list)),
       multi_choice_options=(
           StringMethods.random_list_strings(
               list_len=len(dropdown_types_list))))
   return cad_factory.generate_cads_for_asmt_tmpls([cad])[0]
开发者ID:,项目名称:,代码行数:20,代码来源:

示例3: _create_random_obj

# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import random_list_strings [as 别名]
 def _create_random_obj(self, is_add_rest_attrs):
   """Create Custom Attribute entity with randomly and predictably filled
   fields, if 'is_add_rest_attrs' then add attributes for REST."""
   ca_obj_attr_type = unicode(random.choice(
       AdminWidgetCustomAttributes.ALL_CA_TYPES))
   ca_obj = self.obj_inst().update_attrs(
       title=self.generate_ca_title(ca_obj_attr_type),
       attribute_type=ca_obj_attr_type,
       multi_choice_options=(
           StringMethods.random_list_strings()
           if ca_obj_attr_type == AdminWidgetCustomAttributes.DROPDOWN
           else None),
       definition_type=unicode(objects.get_singular(
           random.choice(objects.ALL_CA_OBJS))), mandatory=False)
   if is_add_rest_attrs:
     ca_obj.update_attrs(
         modal_title="Add Attribute to type {}".format(
             ca_obj.definition_type.title()))
   return ca_obj
开发者ID:egorhm,项目名称:ggrc-core,代码行数:21,代码来源:entities_factory.py

示例4: create_asmt_template_w_dropdown

# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import random_list_strings [as 别名]
def create_asmt_template_w_dropdown(audit, dropdown_types_list):
  """Create assessment template with dropdown custom attribute."""
  multi_choice_mandatory = {"file": "2", "url": "4", "comment": "1",
                            "file_url": "6", "url_comment": "5",
                            "file_comment": "3", "file_url_comment": "7",
                            "nothing": "0"}
  ca_definitions_factory = CustomAttributeDefinitionsFactory()
  custom_attribute_definitions = [ca_definitions_factory.create(
      title=(ca_definitions_factory.generate_ca_title(
          AdminWidgetCustomAttributes.DROPDOWN)),
      attribute_type=AdminWidgetCustomAttributes.DROPDOWN,
      definition_type=AdminWidgetCustomAttributes.DROPDOWN,
      multi_choice_mandatory=(",".join(
          multi_choice_mandatory[dropdown_type]
          for dropdown_type in dropdown_types_list)),
      multi_choice_options=(
          StringMethods.random_list_strings(
              list_len=len(dropdown_types_list))))]
  custom_attribute_definitions = (ca_definitions_factory.
                                  generate_ca_defenitions_for_asmt_tmpls(
                                      custom_attribute_definitions))
  return create_asmt_template(
      audit, custom_attribute_definitions=custom_attribute_definitions)
开发者ID:egorhm,项目名称:ggrc-core,代码行数:25,代码来源:rest_facade.py

示例5: create

# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import random_list_strings [as 别名]
 def create(self, is_add_rest_attrs=False, **attrs):
   """Create random Custom Attribute object's instance, if
   'is_add_rest_attrs' then add attributes for REST, if 'attrs' then update
   attributes accordingly.
   """
   attrs = copy.deepcopy(attrs)
   attrs.setdefault("attribute_type",
                    random.choice(AdminWidgetCustomAttributes.ALL_CA_TYPES))
   attrs.setdefault("definition_type",
                    objects.get_singular(random.choice(objects.ALL_CA_OBJS)))
   attrs.setdefault("title",
                    self.generate_ca_title(attrs["attribute_type"]))
   if attrs["attribute_type"] == AdminWidgetCustomAttributes.DROPDOWN:
     attrs.setdefault("multi_choice_options",
                      StringMethods.random_list_strings())
   else:
     attrs["multi_choice_options"] = None
   attrs.setdefault("mandatory", False)
   obj = self.obj_inst()
   obj.update_attrs(is_allow_none=False, **attrs)
   if is_add_rest_attrs:
     obj.modal_title = "Add Attribute to type {}".format(
         obj.definition_type.title())
   return obj
开发者ID:,项目名称:,代码行数:26,代码来源:


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