本文整理匯總了Python中botocore.loaders.create_loader方法的典型用法代碼示例。如果您正苦於以下問題:Python loaders.create_loader方法的具體用法?Python loaders.create_loader怎麽用?Python loaders.create_loader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類botocore.loaders
的用法示例。
在下文中一共展示了loaders.create_loader方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: region_name
# 需要導入模塊: from botocore import loaders [as 別名]
# 或者: from botocore.loaders import create_loader [as 別名]
def region_name(region_id):
region_names, region_ids = {}, {}
from botocore import loaders
for partition_data in loaders.create_loader().load_data("endpoints")["partitions"]:
region_names.update({k: v["description"] for k, v in partition_data["regions"].items()})
region_ids.update({v: k for k, v in region_names.items()})
return region_names[region_id]
示例2: _register_data_loader
# 需要導入模塊: from botocore import loaders [as 別名]
# 或者: from botocore.loaders import create_loader [as 別名]
def _register_data_loader(self):
self._components.lazy_register_component(
'data_loader',
lambda: create_loader(self.get_config_variable('data_path')))
示例3: _get_endpoint_url
# 需要導入模塊: from botocore import loaders [as 別名]
# 或者: from botocore.loaders import create_loader [as 別名]
def _get_endpoint_url(service, region):
data = boto_loader.create_loader().load_data("endpoints")
endpoint_data = boto_regions.EndpointResolver(data).construct_endpoint(
service, region
)
if not endpoint_data:
raise TaskCatException(
f"unable to resolve endpoint for {service} in {region}"
)
return f"https://{service}.{region}.{endpoint_data['dnsSuffix']}"
示例4: register_parser
# 需要導入模塊: from botocore import loaders [as 別名]
# 或者: from botocore.loaders import create_loader [as 別名]
def register_parser(function, parent=None, name=None, **add_parser_args):
def get_aws_profiles(**kwargs):
from botocore.session import Session
return list(Session().full_config["profiles"])
def set_aws_profile(profile_name):
os.environ["AWS_PROFILE"] = profile_name
del os.environ["AWS_DEFAULT_PROFILE"]
def get_region_names(**kwargs):
from botocore.loaders import create_loader
for partition_data in create_loader().load_data("endpoints")["partitions"]:
if partition_data["partition"] == config.partition:
return partition_data["regions"].keys()
def set_aws_region(region_name):
os.environ["AWS_DEFAULT_REGION"] = region_name
def set_endpoint_url(endpoint_url):
from .util.aws._boto3_loader import Loader
Loader.client_kwargs["default"].update(endpoint_url=endpoint_url)
def set_client_kwargs(client_kwargs):
from .util.aws._boto3_loader import Loader
Loader.client_kwargs.update(json.loads(client_kwargs))
if config is None:
initialize()
if parent is None:
parent = parser
parser_name = name or function.__name__
if parent.prog not in _subparsers:
_subparsers[parent.prog] = parent.add_subparsers()
if "description" not in add_parser_args:
func_module = sys.modules[function.__module__]
add_parser_args["description"] = add_parser_args.get("help", function.__doc__ or func_module.__doc__)
if add_parser_args["description"] and "help" not in add_parser_args:
add_parser_args["help"] = add_parser_args["description"].strip().splitlines()[0].rstrip(".")
add_parser_args.setdefault("formatter_class", AegeaHelpFormatter)
subparser = _subparsers[parent.prog].add_parser(parser_name.replace("_", "-"), **add_parser_args)
if "_" in parser_name and USING_PYTHON2:
_subparsers[parent.prog]._name_parser_map[parser_name] = subparser
subparser.add_argument("--max-col-width", "-w", type=int, default=32,
help="When printing tables, truncate column contents to this width. Set to 0 for auto fit.")
subparser.add_argument("--json", action="store_true",
help="Output tabular data as a JSON-formatted list of objects")
subparser.add_argument("--log-level", default=config.get("log_level"),
help=str([logging.getLevelName(i) for i in range(10, 60, 10)]),
choices={logging.getLevelName(i) for i in range(10, 60, 10)})
subparser.add_argument("--profile", help="Profile to use from the AWS CLI credential file",
type=set_aws_profile).completer = get_aws_profiles
subparser.add_argument("--region", help="Region to use (overrides environment variable)",
type=set_aws_region).completer = get_region_names
subparser.add_argument("--endpoint-url", metavar="URL", help="Service endpoint URL to use", type=set_endpoint_url)
subparser.add_argument("--client-kwargs", help=argparse.SUPPRESS, type=set_client_kwargs)
subparser.set_defaults(entry_point=function)
if parent and sys.version_info < (2, 7, 9): # See https://bugs.python.org/issue9351
parent._defaults.pop("entry_point", None)
subparser.set_defaults(**_get_config_for_prog(subparser.prog))
return subparser