本文整理汇总了Python中lib.utils.string_utils.StringMethods.is_subset_of_dicts方法的典型用法代码示例。如果您正苦于以下问题:Python StringMethods.is_subset_of_dicts方法的具体用法?Python StringMethods.is_subset_of_dicts怎么用?Python StringMethods.is_subset_of_dicts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.utils.string_utils.StringMethods
的用法示例。
在下文中一共展示了StringMethods.is_subset_of_dicts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_objs_by_attrs
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import is_subset_of_dicts [as 别名]
def filter_objs_by_attrs(objs, **attrs):
"""Filter objects by attributes' items and return matched according to
plurality.
'objs' - object or list objects;
'**attrs' - items of attributes' names and values.
"""
list_objs = help_utils.convert_to_list(objs)
matched_objs = [
obj for obj in list_objs
if isinstance(obj, Entity.all_entities_classes()) and
StringMethods.is_subset_of_dicts(dict(**attrs), obj.__dict__)]
return (help_utils.get_single_obj(matched_objs)
if not help_utils.is_multiple_objs(matched_objs) else matched_objs)
示例2: compare_cas
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import is_subset_of_dicts [as 别名]
def compare_cas(self_cas, other_cas):
"""Compare entities' 'custom_attributes' attributes."""
if (isinstance(self_cas, (dict, type(None))) and
isinstance(other_cas, (dict, type(None)))):
is_equal = False
if (isinstance(self_cas, dict) and isinstance(other_cas, dict)):
is_equal = StringMethods.is_subset_of_dicts(self_cas, other_cas)
else:
is_equal = self_cas == other_cas
return is_equal
else:
Representation.attrs_values_types_error(
self_attr=self_cas, other_attr=other_cas,
expected_types=(dict.__name__, type(None).__name__))