def from_store_name(bucket_name, region=None):
<EOL>if region is None:<EOL><INDENT>region = os.getenv('<STR_LIT>')<EOL><DEDENT>mostly_ok = _is_mostly_subdomain_compatible(bucket_name)<EOL>if not mostly_ok:<EOL><INDENT>return CallingInfo(<EOL>bucket_name=bucket_name,<EOL>region=region,<EOL>calling_format=connection.OrdinaryCallingFormat,<EOL>ordinary_endpoint=must_resolve(region))<EOL><DEDENT>else:<EOL><INDENT>if '<STR_LIT:.>' in bucket_name:<EOL><INDENT>return CallingInfo(<EOL>bucket_name=bucket_name,<EOL>calling_format=connection.OrdinaryCallingFormat,<EOL>region=region,<EOL>ordinary_endpoint=must_resolve(region))<EOL><DEDENT>else:<EOL><INDENT>return CallingInfo(<EOL>bucket_name=bucket_name,<EOL>calling_format=connection.SubdomainCallingFormat,<EOL>region=region,<EOL>ordinary_endpoint=None)<EOL><DEDENT><DEDENT>assert False<EOL>
Construct a CallingInfo value from a bucket name.

    This is useful to encapsulate the ugliness of setting up S3
    connections, especially with regions and TLS certificates are
    involved.