当前位置: 首页>>代码示例>>Python>>正文


Python parse.urljoin方法代码示例

本文整理汇总了Python中django.utils.six.moves.urllib.parse.urljoin方法的典型用法代码示例。如果您正苦于以下问题:Python parse.urljoin方法的具体用法?Python parse.urljoin怎么用?Python parse.urljoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.utils.six.moves.urllib.parse的用法示例。


在下文中一共展示了parse.urljoin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_files

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def get_files(root_path, cur_path, allow_types=[]):
    files = []
    items = os.listdir(cur_path)
    for item in items:
        item_fullname = os.path.join(
            root_path, cur_path, item).replace("\\", "/")
        if os.path.isdir(item_fullname):
            files.extend(get_files(root_path, item_fullname, allow_types))
        else:
            ext = os.path.splitext(item_fullname)[1]
            is_allow_list = (len(allow_types) == 0) or (ext in allow_types)
            if is_allow_list:
                files.append({
                    "url": urljoin(
                        USettings.gSettings.MEDIA_URL,
                        os.path.join(
                            os.path.relpath(cur_path, root_path), item
                            ).replace("\\", "/")),
                    "mtime": os.path.getmtime(item_fullname)
                })

    return files 
开发者ID:jeeyshe,项目名称:ishare,代码行数:24,代码来源:views.py

示例2: render_ui

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def render_ui(self, editorID):
        """         创建button的js代码:        """
        return """
            var btn = new UE.ui.Button({
                name: uiName,
                title: "%(title)s",
                cssRules: "background-image:url('%(icon)s')!important;",
                onclick: function() {
                    %(onclick)s
                }
            });
            return btn
        """ % {
            "icon": urljoin(USettings.gSettings.MEDIA_URL, self.icon),
            "onclick": self.onClick(),
            "title": self.title
        } 
开发者ID:jeeyshe,项目名称:ishare,代码行数:19,代码来源:commands.py

示例3: absolute_path

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def absolute_path(self, path, prefix=None):
        if path.startswith(('http://', 'https://', '/')):
            return path
        if prefix is None:
            if settings.STATIC_URL is None:
                # backwards compatibility
                prefix = settings.MEDIA_URL
            else:
                prefix = settings.STATIC_URL
        return urljoin(prefix, path) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:12,代码来源:widgets.py

示例4: handle_simple

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def handle_simple(cls, path):
        return urljoin(PrefixNode.handle_simple("STATIC_URL"), path) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:4,代码来源:static.py

示例5: url

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def url(self, name):
        if self.base_url is None:
            raise ValueError("This file is not accessible via a URL.")
        return urljoin(self.base_url, filepath_to_uri(name)) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:6,代码来源:storage.py

示例6: handle_simple

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def handle_simple(cls, path):
        if apps.is_installed('django.contrib.staticfiles'):
            from django.contrib.staticfiles.storage import staticfiles_storage
            return staticfiles_storage.url(path)
        else:
            return urljoin(PrefixNode.handle_simple("STATIC_URL"), quote(path)) 
开发者ID:Yeah-Kun,项目名称:python,代码行数:8,代码来源:static.py

示例7: _handle_redirects

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def _handle_redirects(self, response, **extra):
        "Follows any redirects by requesting responses from the server using GET."

        response.redirect_chain = []
        while response.status_code in (301, 302, 303, 307):
            response_url = response.url
            redirect_chain = response.redirect_chain
            redirect_chain.append((response_url, response.status_code))

            url = urlsplit(response_url)
            if url.scheme:
                extra['wsgi.url_scheme'] = url.scheme
            if url.hostname:
                extra['SERVER_NAME'] = url.hostname
            if url.port:
                extra['SERVER_PORT'] = str(url.port)

            # Prepend the request path to handle relative path redirects
            path = url.path
            if not path.startswith('/'):
                path = urljoin(response.request['PATH_INFO'], path)

            response = self.get(path, QueryDict(url.query), follow=False, **extra)
            response.redirect_chain = redirect_chain

            if redirect_chain[-1] in redirect_chain[:-1]:
                # Check that we're not redirecting to somewhere we've already
                # been to, to prevent loops.
                raise RedirectCycleError("Redirect loop detected.", last_response=response)
            if len(redirect_chain) > 20:
                # Such a lengthy chain likely also means a loop, but one with
                # a growing path, changing view, or changing query argument;
                # 20 is the value of "network.http.redirection-limit" from Firefox.
                raise RedirectCycleError("Too many redirects.", last_response=response)

        return response 
开发者ID:Yeah-Kun,项目名称:python,代码行数:38,代码来源:client.py

示例8: get_link

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def get_link(self, path, method, base_url):
        fields = self.get_path_fields(path, method)
        fields += self.get_serializer_fields(path, method)
        fields += self.get_pagination_fields(path, method)
        fields += self.get_filter_fields(path, method)

        manual_fields = self.get_manual_fields(path, method)
        fields = self.update_fields(fields, manual_fields)

        if fields and any([field.location in ('form', 'body') for field in fields]):
            encoding = self.get_encoding(path, method)
        else:
            encoding = None

        description = self.get_description(path, method)

        if base_url and path.startswith('/'):
            path = path[1:]

        return coreapi.Link(
            url=urlparse.urljoin(base_url, path),
            action=method.lower(),
            encoding=encoding,
            fields=fields,
            description=description
        ) 
开发者ID:BeanWei,项目名称:Dailyfresh-B2C,代码行数:28,代码来源:inspectors.py

示例9: get_images_url

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def get_images_url(self):
        return urljoin(self.url, self.IMAGE_LIST_URI) 
开发者ID:erigones,项目名称:esdc-ce,代码行数:4,代码来源:imagestore.py

示例10: get_image_manifest_url

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def get_image_manifest_url(self, uuid):
        return urljoin(self.url, self.IMAGE_URI % uuid) 
开发者ID:erigones,项目名称:esdc-ce,代码行数:4,代码来源:imagestore.py

示例11: url

# 需要导入模块: from django.utils.six.moves.urllib import parse [as 别名]
# 或者: from django.utils.six.moves.urllib.parse import urljoin [as 别名]
def url(self, name):
        if self._base_url is None:
            raise ValueError("This file is not accessible via a URL.")
        return urlparse.urljoin(self._base_url, name).replace('\\', '/') 
开发者ID:jimmy201602,项目名称:webterminal,代码行数:6,代码来源:sftpstorage.py


注:本文中的django.utils.six.moves.urllib.parse.urljoin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。