osa-filters.py 文件源码

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

项目:openstack-ansible-plugins 作者: openstack 项目源码 文件源码
def get_netorigin(url):
    """Return the netloc from a URL.

    If the input value is not a value URL the method will raise an Ansible
    filter exception.

    :param url: the URL to parse
    :type url: ``str``
    :returns: ``str``
    """
    try:
        parsed_url = urlparse(url)
        netloc = parsed_url.netloc
        scheme = parsed_url.scheme
    except Exception as exp:
        raise errors.AnsibleFilterError(
            'Failed to return the netorigin of: "%s"' % str(exp)
        )
    else:
        return '%s://%s' % (scheme, netloc)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号