本文整理匯總了Python中misc.Misc.str2bool方法的典型用法代碼示例。如果您正苦於以下問題:Python Misc.str2bool方法的具體用法?Python Misc.str2bool怎麽用?Python Misc.str2bool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類misc.Misc
的用法示例。
在下文中一共展示了Misc.str2bool方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_method
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import str2bool [as 別名]
def create_method(self, restid, resourceid, method, authorizationtype, apikeyreq=False, further_opts=None):
"""
This function creates a method object
:param method: the method that is requested
:type method: basestring
:param restid: the id of the rest api object
:type restid: basestring
:param resourceid: id of a single resource object
:type resourceid: basestring
:param authorizationtype:
:type authorizationtype: basestring
:param apikeyreq: should apikey be required
:type apikeyreq: bool
:param further_opts: This opt passes in json_data fur not mandatory options
:type further_opts: dict
:return: the created method object
"""
if self.dryrun:
logger.info("Dryrun requested no changes will be done")
return None
if isinstance(apikeyreq, bool) is False:
logger.debug("apikey is not boolean, converting")
apikeyreq = Misc.str2bool(apikeyreq)
opts = {'restApiId': restid, 'resourceId': resourceid, 'httpMethod': method,
'authorizationType': authorizationtype, 'apiKeyRequired': apikeyreq}
if 'requestParameters' in further_opts:
opts['requestParameters'] = further_opts['requestParameters']
if 'requestModels' in further_opts:
opts['requestModels'] = further_opts['requestModels']
logger.debug("The opts sent to create method %s" % opts)
resp = self.apigateway_client.put_method(**opts)
super(Apigateway, self).query_information(query=resp)
return resp
示例2: test_str2bool_false
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import str2bool [as 別名]
def test_str2bool_false(self):
self.assertFalse(Misc.str2bool("false"))
self.assertFalse(Misc.str2bool("False"))
self.assertFalse(Misc.str2bool("f"))
self.assertFalse(Misc.str2bool("0"))
self.assertFalse(Misc.str2bool("no"))
self.assertFalse(Misc.str2bool("ILIKECARS"))
示例3: get_all_subnets
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import str2bool [as 別名]
def get_all_subnets(self, filters=None, subnetids=None):
"""
This function returns all subnets, or filters them as requested
:param filters: A dict list with the boto3 filters
:param subnetids: A list of subnetids that should only be returned
:return: A list of subnets that were requested
"""
if subnetids:
response = self.vpc_client.describe_subnets(SubnetIds=subnetids)
elif filters:
response = self.vpc_client.describe_subnets(Filters=filters)
else:
response = self.vpc_client.describe_subnets()
result = []
for s in response['Subnets']:
allowed = Misc.get_value_from_array_hash(dictlist=s.get('Tags'), key="Allowed")
if Misc.str2bool(allowed):
result.append(s)
logger.debug("Allowed az subnets are: %s" % (result,))
return result
示例4: test_str2bool_true
# 需要導入模塊: from misc import Misc [as 別名]
# 或者: from misc.Misc import str2bool [as 別名]
def test_str2bool_true(self):
self.assertTrue(Misc.str2bool("true"))
self.assertTrue(Misc.str2bool("True"))
self.assertTrue(Misc.str2bool("t"))
self.assertTrue(Misc.str2bool("1"))
self.assertTrue(Misc.str2bool("yes"))