def generate_hub_key(resolver_id, hub_id, repository_id, entity_type, entity_id=None):
parsed = urlparse(resolver_id)<EOL>if not parsed.scheme:<EOL><INDENT>parsed = parsed._replace(scheme=PROTOCOL, netloc=idna_encode(parsed.path.lower()), path=u'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>parsed = parsed._replace(netloc=idna_encode(parsed.netloc.lower()))<EOL><DEDENT>resolver_id = urlunparse(parsed)<EOL>hub_id = url_quote(hub_id.lower())<EOL>if not entity_id:<EOL><INDENT>entity_id = str(uuid.uuid4()).replace('<STR_LIT:->', '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>match_part(entity_id, '<STR_LIT>')<EOL><DEDENT>match_part(resolver_id, '<STR_LIT>')<EOL>match_part(hub_id, '<STR_LIT>')<EOL>match_part(repository_id, '<STR_LIT>')<EOL>match_part(entity_type, '<STR_LIT>')<EOL>hub_key = SEPARATOR.join(<EOL>[resolver_id, SCHEMA, hub_id, repository_id, entity_type, entity_id])<EOL>return hub_key<EOL>
Create and return an array of hub keys
    :param resolver_id: the service that can resolve this key
    :param hub_id: the unique id of the hub
    :param repository_id: the type of id that the provider recognises
    :param entity_type: the type of the entity to which the key refers.
    :param entity_id: ID of entity (UUID)
    :returns: a hub key
    :raises:
    :AttributeError: if a parameter has a bad value
    :TypeError: if a parameter has a bad value
    :ValueError: if a parameter has a bad value