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


Python StringMethods.get_bool_value_from_arg方法代码示例

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


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

示例1: _create_list_objs

# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import get_bool_value_from_arg [as 别名]
 def _create_list_objs(self, entity_factory, list_scopes):
   """Create and return list of objects used entity factory and UI data
   (list of scopes UI text elements {"header": "item", ...} remapped to
   list of dicts {"attr": "value", ...}).
   Return list of created objects.
   """
   list_factory_objs = [
       entity_factory().obj_inst() for _ in xrange(len(list_scopes))]
   list_scopes_with_upper_keys = [
       StringMethods.dict_keys_to_upper_case(scope) for scope in list_scopes]
   list_scopes_to_convert = StringMethods.exchange_dicts_items(
       transform_dict=Representation.remap_collection(),
       dicts=list_scopes_with_upper_keys, is_keys_not_values=True)
   # convert and represent values in scopes
   for scope in list_scopes_to_convert:
     # convert u'None', u'No person' to None type
     StringMethods.update_dicts_values(scope, ["None", "No person"], None)
     for key, val in scope.iteritems():
       if val:
         if key in ["mandatory", "verified"]:
           # convert u'false', u'true' like to Boolean
           scope[key] = StringMethods.get_bool_value_from_arg(val)
         if key in ["updated_at", "created_at"]:
           # UI like u'08/20/2017' to date=2017-08-20, timetz=00:00:00
           datetime_val = parser.parse(val)
           if str(datetime_val.time()) != "00:00:00":
             # UI like u'08/20/2017 07:30:45 AM +03:00' to date=2017-08-20,
             # timetz=04:30:45+00:00 if 'tzinfo', else:
             # CSV like u'08-20-2017 04:30:45' to date=2017-08-20,
             # timetz=04:30:45+00:00
             datetime_val = (
                 datetime_val.astimezone(tz=tz.tzutc()) if datetime_val.tzinfo
                 else datetime_val.replace(tzinfo=tz.tzutc()))
           scope[key] = datetime_val
         if (key == "comments" and isinstance(val, list) and
                 all(isinstance(comment, dict) for comment in val)):
           # extract datetime from u'(Creator) 08/20/2017 07:30:45 AM +03:00'
           scope[key] = [
               {k: (parser.parse(re.sub(regex.TEXT_W_PARENTHESES,
                                        Symbols.BLANK, v)
                                 ).astimezone(tz=tz.tzutc())
                    if k == "created_at" else v)
                for k, v in comment.iteritems()} for comment in val]
         # convert multiple values to list of strings and split if need it
         if (key in Representation.people_attrs_names and
            not isinstance(val, list)):
           # split Tree View values if need 'Ex1, Ex2 F' to ['Ex1', 'Ex2 F']
           # Info Widget values will be represent by internal methods
           scope[key] = val.split(", ")
         # convert 'slug' from CSV for snapshoted objects u'*23eb72ac-4d9d'
         if (key == "slug" and
                 (self.obj_name in objects.ALL_SNAPSHOTABLE_OBJS) and
                 Symbols.STAR in val):
           scope[key] = val.replace(Symbols.STAR, Symbols.BLANK)
   return [
       factory_obj.update_attrs(is_allow_none=True, **scope) for
       scope, factory_obj in zip(list_scopes_to_convert, list_factory_objs)]
开发者ID:egorhm,项目名称:ggrc-core,代码行数:59,代码来源:webui_service.py

示例2: _set_custom_attributes_list

# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import get_bool_value_from_arg [as 别名]
 def _set_custom_attributes_list(self):
   """Set custom attributes list with Custom Attribute objects from
   current opened content item.
   """
   for row in selenium_utils.get_when_all_visible(self._driver,
                                                  self._locators.ROW_CSS):
     attrs = [i.text for i in row.find_elements(
         *self._locators.CELL_IN_ROW_CSS)]
     # todo: add PO and getting 'multi_choice_options' via 'Edit' btn
     self.custom_attributes_list.append(
         CustomAttributeDefinitionsFactory().create(
             title=attrs[0], attribute_type=attrs[1],
             mandatory=StringMethods.get_bool_value_from_arg(attrs[2]),
             definition_type=self._item_name, multi_choice_options=None))
开发者ID:,项目名称:,代码行数:16,代码来源:

示例3: get_filter_exprs_by_ca

# 需要导入模块: from lib.utils.string_utils import StringMethods [as 别名]
# 或者: from lib.utils.string_utils.StringMethods import get_bool_value_from_arg [as 别名]
 def get_filter_exprs_by_ca(self, cad, cav, operator):
   """Return all possible filter expressions for CA according to CA type"""
   ca_type = cad.attribute_type
   if ca_type == AdminWidgetCustomAttributes.CHECKBOX:
     value = alias.YES_VAL if StringMethods.get_bool_value_from_arg(
         cav.attribute_value) else alias.NO_VAL
     values_to_filter = StringMethods.get_list_of_all_cases(value)
   elif ca_type == AdminWidgetCustomAttributes.PERSON:
     from lib.service import rest_service
     person = rest_service.ObjectsInfoService().get_obj(
         obj=Representation.repr_dict_to_obj(cav.attribute_object))
     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(cav.attribute_value).date()
     values_to_filter = [date.strftime(_format) for _format in date_formats]
   else:
     values_to_filter = [cav.attribute_value]
   return [self.get_filter_exp(cad.title, operator, [val])
           for val in values_to_filter]
开发者ID:egorhm,项目名称:ggrc-core,代码行数:22,代码来源:filter_utils.py


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