python类urljoin()的实例源码

storage_qiniu.py 文件源码 项目:YouPBX 作者: JoneXiong 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def _normalize_name(self, name):
        """
        Normalizes the name so that paths like /path/to/ignored/../foo.txt
        work. We check to make sure that the path pointed to is not outside
        the directory specified by the LOCATION setting.
        """

        base_path = force_text(self.location)
        base_path = base_path.rstrip('/')

        final_path = urljoin(base_path.rstrip('/') + "/", name)

        base_path_len = len(base_path)
        if (not final_path.startswith(base_path) or
                final_path[base_path_len:base_path_len + 1] not in ('', '/')):
            raise SuspiciousOperation("Attempted access to '%s' denied." %
                                      name)
        return final_path.lstrip('/')
base.py 文件源码 项目:python-anticaptcha 作者: ad-m 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def createTask(self, task):
        request = {"clientKey": self.client_key,
                   "task": task.serialize(),
                   "softId": self.SOFT_ID,
                   "languagePool": self.language_pool,
                   }
        response = self.session.post(urljoin(self.base_url, self.CREATE_TASK_URL), json=request).json()
        self._check_response(response)
        return Job(self, response['taskId'])
base.py 文件源码 项目:python-anticaptcha 作者: ad-m 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def getTaskResult(self, task_id):
        request = {"clientKey": self.client_key,
                   "taskId": task_id}
        response = self.session.post(urljoin(self.base_url, self.TASK_RESULT_URL), json=request).json()
        self._check_response(response)
        return response
base.py 文件源码 项目:python-anticaptcha 作者: ad-m 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def getBalance(self):
        request = {"clientKey": self.client_key}
        response = self.session.post(urljoin(self.base_url, self.BALANCE_URL), json=request).json()
        self._check_response(response)
        return response['balance']
storage_qiniu.py 文件源码 项目:YouPBX 作者: JoneXiong 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def full_url(self, name):
        name = self._normalize_name(self._clean_name(name))
        name = filepath_to_uri(name)
        full_url = urlparse.urljoin(settings.REMOTE_MEDIA_URL, name)
        log.info('>>> QiniuStorage full_url: %s'%name)
        return full_url
test_six.py 文件源码 项目:obsoleted-vpduserv 作者: InfraSIM 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_import_moves_error_1():
    from six.moves.urllib.parse import urljoin
    from six import moves
    # In 1.4.1: AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urljoin'
    assert moves.urllib.parse.urljoin
test_six.py 文件源码 项目:obsoleted-vpduserv 作者: InfraSIM 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_import_moves_error_2():
    from six import moves
    assert moves.urllib.parse.urljoin
    # In 1.4.1: ImportError: cannot import name urljoin
    from six.moves.urllib.parse import urljoin
test_six.py 文件源码 项目:obsoleted-vpduserv 作者: InfraSIM 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_import_moves_error_3():
    from six.moves.urllib.parse import urljoin
    # In 1.4.1: ImportError: cannot import name urljoin
    from six.moves.urllib_parse import urljoin
test_six.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_import_moves_error_1():
    from six.moves.urllib.parse import urljoin
    from six import moves
    # In 1.4.1: AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urljoin'
    assert moves.urllib.parse.urljoin
test_six.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_import_moves_error_2():
    from six import moves
    assert moves.urllib.parse.urljoin
    # In 1.4.1: ImportError: cannot import name urljoin
    from six.moves.urllib.parse import urljoin
test_six.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_import_moves_error_3():
    from six.moves.urllib.parse import urljoin
    # In 1.4.1: ImportError: cannot import name urljoin
    from six.moves.urllib_parse import urljoin
test_six.py 文件源码 项目:six 作者: benjaminp 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_import_moves_error_1():
    from six.moves.urllib.parse import urljoin
    from six import moves
    # In 1.4.1: AttributeError: 'Module_six_moves_urllib_parse' object has no attribute 'urljoin'
    assert moves.urllib.parse.urljoin
test_six.py 文件源码 项目:six 作者: benjaminp 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_import_moves_error_2():
    from six import moves
    assert moves.urllib.parse.urljoin
    # In 1.4.1: ImportError: cannot import name urljoin
    from six.moves.urllib.parse import urljoin
test_six.py 文件源码 项目:six 作者: benjaminp 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_import_moves_error_3():
    from six.moves.urllib.parse import urljoin
    # In 1.4.1: ImportError: cannot import name urljoin
    from six.moves.urllib_parse import urljoin
api.py 文件源码 项目:valohai-cli 作者: valohai 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def prepare_request(self, request):
        url_netloc = urlparse(request.url).netloc
        if not url_netloc:
            request.url = urljoin(self.base_url, request.url)
        return super(APISession, self).prepare_request(request)


问题


面经


文章

微信
公众号

扫码关注公众号