Retrieve extension for the given protocol

        :param protocol: name of the protocol
        :type protocol: string
        :raises NoProtocolError: no extension registered for protocol
488260
def get_extension(self, protocol):
        
        if protocol not in self.registry:
            raise NoProtocolError("No protocol for %s" % protocol)
        index = self.registry[protocol]
        return self.extensions[index]
634192
def _registerExtension(self, extension, rtiRegItem):
        
        check_is_a_string(extension)
        check_class(rtiRegItem, RtiRegItem)

        logger.debug("  Registering extension {!r} for {}".format(extension, rtiRegItem))

        # TODO: type checking
        if extension in self._extensionMap:
            logger.info("Overriding extension {!r}: old={}, new={}"
                        .format(extension, self._extensionMap[extension], rtiRegItem))
        self._extensionMap[extension] = rtiRegItem
601752
def get_extension(media):
    """"""

    # Photos are always compressed as .jpg by Telegram
    if isinstance(media, (types.UserProfilePhoto,
                          types.ChatPhoto, types.MessageMediaPhoto)):
        return '.jpg'

    # Documents will come with a mime type
    if isinstance(media, types.MessageMediaDocument):
        media = media.document
    if isinstance(media, (
            types.Document, types.WebDocument, types.WebDocumentNoProxy)):
        if media.mime_type == 'application/octet-stream':
            # Octet stream are just bytes, which have no default extension
            return ''
        else:
            return guess_extension(media.mime_type) or ''

    return ''
1150997
def validate_protocol(protocol):
    ''''''
    if not re.match(PROTOCOL_REGEX, protocol):
        raise ValueError(f'invalid protocol: {protocol}')
    return protocol.lower()
538221
ProtocolVersion selectProtocolVersion(ProtocolVersion protocolVersion) {
        if (activeProtocols == null) {
            activeProtocols = getActiveProtocols();
        }

        return activeProtocols.selectProtocolVersion(protocolVersion);
    }
434228
def has_protocol(self, name):
    """"""

    return self.query(Protocol).filter(Protocol.name==name).count() != 0
55060
public static Protocol getProtocol(byte code) {
        Protocol protocol = TYPE_PROTOCOL_MAP.get(code);
        if (protocol == null) {
            throw new SofaRpcRuntimeException("Extension Not Found :\"" + code + "\"!");
        }
        return protocol;
    }
1148310
def get(self, name_or_klass):
        
        if not isinstance(name_or_klass, str):
            name_or_klass = name_or_klass.__name__
        return self._extensions[name_or_klass]
886376
def runGetInfo(self, request):
        
        return protocol.toJson(protocol.GetInfoResponse(
            protocol_version=protocol.version))
299013
def bind(self, extension: Extension) -> 'DictMentor':
        
        if not Extension.is_valid_extension(extension):
            raise ValueError("Cannot bind extension due to missing interface requirements")
        self._extensions.append(extension)

        return self
918028
def get_protocols(self, device):
        """"""
        return self._reg.device_builder(device, self._rv).protocols
1049966
def get_protocol_from_name(name):
    
    cls = protocol_map.get(name)
    if not cls:
        raise ValueError('Unsupported protocol "%s".' % name)
    return cls
848754
def get(value: str) -> 'Protocol':
        

        for pktype in PublicKeyType:
            if value in (pktype.ver_type, pktype.authn_type):
                return pktype
        return None
354126
def get_protocols(self, protocol):
        
        if isinstance(protocol, packet_base.PacketBase):
            protocol = protocol.__class__
        assert issubclass(protocol, packet_base.PacketBase)
        return [p for p in self.protocols if isinstance(p, protocol)]
450794
def resolve_ssl_version(candidate):
    
    if candidate is None:
        return PROTOCOL_SSLv23

    if isinstance(candidate, str):
        res = getattr(ssl, candidate, None)
        if res is None:
            res = getattr(ssl, 'PROTOCOL_' + candidate)
        return res

    return candidate
307767
async def get_protocol_version(self):
        
        value = await self.core.get_protocol_version()
        if value:
            reply = json.dumps({"method": "protocol_version_reply", "params": value})
        else:
            reply = json.dumps({"method": "protocol_version_reply", "params": "Unknown"})
        await self.websocket.send(reply)
981525
public static SerializeHandler getHandlerByProtocal(String protocol)
            throws InvalidProtocolException {
        SerializeHandler handler = HANDLER_MAP.get(protocol);
        if (handler != null) {
            return handler;
        }
        throw new InvalidProtocolException("rpc protocol not supported for " + protocol);
    }