本文整理汇总了Python中lib.utils.string_utils.StringMethods.convert_list_elements_to_list方法的典型用法代码示例。如果您正苦于以下问题:Python StringMethods.convert_list_elements_to_list方法的具体用法?Python StringMethods.convert_list_elements_to_list怎么用?Python StringMethods.convert_list_elements_to_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.utils.string_utils.StringMethods
的用法示例。
在下文中一共展示了StringMethods.convert_list_elements_to_list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _check_assessments_filtration
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import convert_list_elements_to_list [as 别名]
def _check_assessments_filtration(assessment, cavs, operator,
audit, selenium):
"""Check that filtration of assessments works."""
cads = [Representation.repr_dict_to_obj(cad)
for cad in assessment.custom_attribute_definitions]
filter_exprs = FilterUtils().get_filter_exprs_by_cavs(
cads, cavs, operator)
assessment = Representation.extract_objs_wo_excluded_attrs(
[assessment.repr_ui()],
*(Representation.tree_view_attrs_to_exclude + (
"audit", "assessment_type", "modified_by"))
)[0]
expected_results = [{"filter": filter_expr, "objs": [assessment]}
for filter_expr in filter_exprs]
actual_results = []
for filter_expr in filter_exprs:
result = {
"filter": filter_expr,
"objs": webui_service.AssessmentsService(selenium)
.filter_and_get_list_objs_from_tree_view(audit, filter_expr)
}
actual_results.append(result)
error_message = messages.AssertionMessages.format_err_msg_equal(
[{exp_res["filter"]: [exp_obj.title for exp_obj in exp_res["objs"]]}
for exp_res in expected_results],
[{act_res["filter"]: [act_obj.title for act_obj in act_res["objs"]]}
for act_res in actual_results]
) + messages.AssertionMessages.format_err_msg_equal(
StringMethods.convert_list_elements_to_list(
[exp_res["objs"] for exp_res in expected_results]),
StringMethods.convert_list_elements_to_list(
[act_res["objs"] for act_res in actual_results]))
assert expected_results == actual_results, error_message
示例2: get_attrs_names
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import convert_list_elements_to_list [as 别名]
def get_attrs_names(cls, entity=None):
"""Get list unique entities attributes' names. If 'entity' then get
attributes of one entered entity, else get attributes of all entities.
"""
all_entities_cls = (help_utils.convert_to_list(entity) if entity
else list(Entity.all_entities_classes()))
all_entities_attrs_names = StringMethods.convert_list_elements_to_list(
[entity_cls().__dict__.keys() for entity_cls in all_entities_cls])
return list(set(all_entities_attrs_names))
示例3: generate_snapshots_fixtures
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import convert_list_elements_to_list [as 别名]
def generate_snapshots_fixtures(fixture):
"""Generate, run and return of results for snapshots dynamic fixtures
according to tuple of fixture name.
Example: 'create_audit_with_control__risk_and_update_control'
'create_audit_with_controls'
'create_audit_with_controls_and_update_control'
'create_audit_with_control__risk_and_update_control__risk
"""
global dict_executed_fixtures
if isinstance(fixture, str) and fixture.startswith("create_audit_with_"):
_creation_params = None
_action_params = None
updating_params = []
deleting_params = []
fixture_params = fixture.replace("create_audit_with_", "")
if "_and_" in fixture_params:
_creation_params, _action_params = fixture_params.split("_and_")
if "_and_" not in fixture_params:
_creation_params = fixture_params
creation_params = StringMethods.convert_list_elements_to_list([
"new_{}_rest".format(param) if "_with_cas" not in param else
["new_cas_for_{}_rest".format(objects.get_plural(param.split("_")[0])),
"new_{}_rest".format(param)]
for param in _creation_params.split("__")])
mapping_params = [
"map_new_program_rest_to_new_{}_rest".format(param) for param in
_creation_params.split("__")]
creation_part = (["new_program_rest"] + creation_params +
mapping_params + ["new_audit_rest"])
if _action_params:
if "update" in _action_params:
updating_params = ["update_{}_rest".format(param) for param in
_action_params.replace("update_", "").split("__")]
if "delete" in _action_params:
deleting_params = ["delete_{}_rest".format(param) for param in
_action_params.replace("delete_", "").split("__")]
action_part = (updating_params + deleting_params)
all_manipulations = creation_part + action_part
generate_common_fixtures(*all_manipulations)
executed_snapshots_fixtures = copy.deepcopy(dict_executed_fixtures)
return executed_snapshots_fixtures
示例4: compare_comments
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import convert_list_elements_to_list [as 别名]
def compare_comments(self_comments, other_comments):
"""Compare entities' 'comments' attributes due to specific dictionaries'
format values in list comments.
"""
# pylint: disable=no-else-return
if help_utils.is_multiple_objs(
StringMethods.convert_list_elements_to_list(
[self_comments, other_comments]), (dict, type(None))):
if self_comments and other_comments:
is_comments_equal_list = []
for self_comment, other_comment in zip(self_comments, other_comments):
is_comments_equal = False
if self_comment and other_comment:
is_comments_equal = (
all((Representation.compare_datetime(
self_comment.get("created_at"),
other_comment.get("created_at")
) if (isinstance(_self, datetime) and
isinstance(_other, datetime))else
_self == _other) for _self, _other in zip(
self_comment.iteritems(), other_comment.iteritems())))
# convert datetime to unicode in order to get visible repr
if self_comment.get("created_at"):
self_comment["created_at"] = unicode(
self_comment.get("created_at"))
if other_comment.get("created_at"):
other_comment["created_at"] = unicode(
other_comment.get("created_at"))
else:
is_comments_equal = self_comment == other_comment
is_comments_equal_list.append(is_comments_equal)
return all(is_equal for is_equal in is_comments_equal_list)
else:
return self_comments == other_comments
else:
Representation.attrs_values_types_error(
self_attr=self_comments, other_attr=other_comments,
expected_types=(list.__name__, type(None).__name__))