本文整理汇总了Python中lib.utils.string_utils.StringMethods.get_list_of_all_cases方法的典型用法代码示例。如果您正苦于以下问题:Python StringMethods.get_list_of_all_cases方法的具体用法?Python StringMethods.get_list_of_all_cases怎么用?Python StringMethods.get_list_of_all_cases使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.utils.string_utils.StringMethods
的用法示例。
在下文中一共展示了StringMethods.get_list_of_all_cases方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_filter_exprs_by_ca
# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import get_list_of_all_cases [as 别名]
def get_filter_exprs_by_ca(self, ca_title, ca_val, ca_type, operator):
"""Return all possible filter expressions for CA according to CA type"""
if ca_type == AdminWidgetCustomAttributes.CHECKBOX:
values_to_filter = (
StringMethods.get_list_of_all_cases(alias.YES_VAL) if
StringMethods.get_bool_value_from_arg(ca_val)
else StringMethods.get_list_of_all_cases(alias.NO_VAL))
elif ca_type == AdminWidgetCustomAttributes.PERSON:
from lib.service import rest_service
person = rest_service.ObjectsInfoService().get_obj(
obj=Representation.repr_dict_to_obj(
dict(zip(["type", "id"], ca_val.split(":")))))
values_to_filter = [person.name, person.email]
elif ca_type == AdminWidgetCustomAttributes.DATE:
date_formats = ["%m/%d/%Y", "%m/%Y", "%Y-%m-%d", "%Y-%m", "%Y"]
date = parser.parse(ca_val).date()
values_to_filter = [date.strftime(_format) for _format in date_formats]
else:
values_to_filter = [ca_val]
return [self.get_filter_exp(ca_title, operator, [val])
for val in values_to_filter]