本文整理匯總了Python中region.Region.extend方法的典型用法代碼示例。如果您正苦於以下問題:Python Region.extend方法的具體用法?Python Region.extend怎麽用?Python Region.extend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類region.Region
的用法示例。
在下文中一共展示了Region.extend方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: find
# 需要導入模塊: from region import Region [as 別名]
# 或者: from region.Region import extend [as 別名]
def find(**kwargs):
"""Find VPCs by name or ID across all regions."""
vpc_ids = kwargs.get("ids", list())
vpc_names = kwargs.get("names", list())
vpcs = list()
if type(vpc_ids) == str:
vpc_ids = [vpc_ids]
if type(vpc_names) == str:
vpc_names = [vpc_names]
for vpc_name in vpc_names:
n_list = vpc_name.split("-")
if len(n_list) != 4:
raise NameError, "Invalid VPC name: " + vpc_name
(reg, env) = ("-".join(n_list[:3]), n_list[3])
res = Region(name=reg).find_vpcs(env=env)
for v in res:
if not v in vpcs:
vpcs.append(v)
for vpc_id in vpc_ids:
for region in get_regions():
res = region.find_vpcs(id=vpc_id)
if res:
for v in res:
if not v in vpcs:
vpcs.append(v)
break
if not vpc_id and not vpc_ids:
for region in get_regions():
res.extend(region.find_vpcs())
return vpcs