def process_service( session: Session, service_name: ServiceName, output_path: Path, generate_setup: bool, ) -> ServicePackage: """ Parse and write service package `mypy_boto3_*`. Arguments: session -- boto3 session. service_name -- Target service name. output_path -- Package output path. generate_setup -- Generate ready-to-install or to-use package. Return: Parsed ServicePackage. """ logger = get_logger() logger.debug(f"Parsing {service_name.boto3_name}") service_module = parse_service_package(session, service_name) for typed_dict in service_module.typed_dicts: typed_dict.replace_self_references() logger.debug( f"Writing {service_name.boto3_name} to {NicePath(output_path)}") write_service_package(service_module, output_path=output_path, generate_setup=generate_setup) return service_module
def process_service( session: Session, service_name: ServiceName, output_path: Path, generate_setup: bool, ) -> ServicePackage: """ Parse and write service package `mypy_boto3_*`. Arguments: session -- boto3 session. service_name -- Target service name. output_path -- Package output path. generate_setup -- Whether to generate install or installed package. Return: Parsed ServicePackage. """ logger.debug(f"Parsing {service_name.boto3_name}") service_module = parse_service_package(session, service_name) logger.debug( f"Writing {service_name.boto3_name} to {NicePath(output_path)}") modified_paths = write_service_package(service_module, output_path=output_path, generate_setup=generate_setup) for modified_path in modified_paths: logger.debug(f"Updated {NicePath(modified_path)}") return service_module
def test_parse_boto3_stubs_package(self, ClientExceptionsFactoryMock: MagicMock) -> None: session_mock = MagicMock() service_name_mock = MagicMock() session_mock.resource().meta.service_name = "s3" session_mock.resource().meta.client.meta.service_model.service_name = "s3" service_name_mock.boto3_name = "s3" ClientExceptionsFactoryMock.create_client_exceptions.return_value = [] result = parse_service_package(session_mock, service_name_mock, Boto3StubsPackageData) assert result.service_name == service_name_mock
def process_aiobotocore_service( session: Session, service_name: ServiceName, output_path: Path, generate_setup: bool, service_names: Iterable[ServiceName], version: str, ) -> ServicePackage: """ Parse and write service package `types_aiobotocore_*`. Arguments: session -- boto3 session service_name -- Target service name output_path -- Package output path generate_setup -- Generate ready-to-install or to-use package service_names -- List of known service names version -- Package version Return: Parsed ServicePackage. """ logger = get_logger() logger.debug(f"Parsing {service_name.boto3_name}") service_package = parse_service_package(session, service_name, TypesAioBotocorePackageData) service_package.version = version service_package.extend_literals(service_names) postprocessor = ServicePackagePostprocessor(service_package) postprocessor.generate_docstrings() postprocessor.make_async() postprocessor.add_contextmanager_methods() for typed_dict in service_package.typed_dicts: typed_dict.replace_self_references() logger.debug( f"Writing {service_name.boto3_name} to {NicePath(output_path)}") package_writer = PackageWriter(output_path=output_path, generate_setup=generate_setup) package_writer.write_service_package( service_package, templates_path=TEMPLATES_PATH / "aiobotocore_service", ) return service_package
def process_service_docs( session: Session, service_name: ServiceName, output_path: Path, service_names: Iterable[ServiceName], ) -> ServicePackage: """ Parse and write service package docs. Arguments: session -- boto3 session service_name -- Target service name output_path -- Package output path service_names -- List of known service names Return: Parsed ServicePackage. """ logger = get_logger() logger.debug(f"Parsing {service_name.boto3_name}") service_package = parse_service_package(session, service_name, Boto3StubsPackageData) service_package.extend_literals(service_names) postprocessor = ServicePackagePostprocessor(service_package) postprocessor.generate_docstrings() for typed_dict in service_package.typed_dicts: typed_dict.replace_self_references() logger.debug( f"Writing {service_name.boto3_name} to {NicePath(output_path)}") package_writer = PackageWriter(output_path=output_path) package_writer.write_service_docs( service_package, templates_path=TEMPLATES_PATH / "boto3_service_docs", ) return service_package
def process_service_docs( session: Session, service_name: ServiceName, output_path: Path, ) -> ServicePackage: """ Parse and write service package docs. Arguments: session -- boto3 session. service_name -- Target service name. output_path -- Package output path. Return: Parsed ServicePackage. """ logger = get_logger() logger.debug(f"Parsing {service_name.boto3_name}") service_module = parse_service_package(session, service_name) logger.debug( f"Writing {service_name.boto3_name} to {NicePath(output_path)}") write_service_docs(service_module, output_path=output_path) return service_module