OSC2.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pyOSC3 作者: Qirky 项目源码 文件源码
def getOSCTarget(self, address):
        """Returns the OSCTarget matching the given address as a ((host, port), [prefix, filters]) tuple.
        'address' can be a (host, port) tuple, or a 'host' (string), in which case the first matching OSCTarget is returned
        Returns (None, ['',{}]) if address not found.
        """
        if type(address) in types.StringTypes:
            address = self._searchHostAddr(address) 

        if (type(address) == types.TupleType): 
            (host, port) = address[:2]
            try:
                host = socket.gethostbyname(host)
            except socket.error:
                pass
            address = (host, port)

            if (address in self.targets.keys()):
                try:
                    (host, _, _) = socket.gethostbyaddr(host)
                except socket.error:
                    pass

                return ((host, port), self.targets[address])

        return (None, ['',{}])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号