• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python request.url2pathname函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中urllib.request.url2pathname函数的典型用法代码示例。如果您正苦于以下问题:Python url2pathname函数的具体用法?Python url2pathname怎么用?Python url2pathname使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: path

def path(source, res=''):
    if source:
        res = url2pathname(source.url) + '>>' + res
        path(source.prev, res)
    else:
        res += url2pathname(philosophy)
        print(res)
开发者ID:KowalskiP,项目名称:philosophy,代码行数:7,代码来源:philosophy.py


示例2: play

 def play(self, uri):
     try:
         winsound.PlaySound(None, 0)
         winsound.PlaySound(
             url2pathname(uri[5:]), winsound.SND_FILENAME | winsound.SND_ASYNC)
     except RuntimeError:
         log.error("ERROR: RuntimeError while playing %s." %
                   url2pathname(uri[5:]))
开发者ID:bboutkov,项目名称:pychess,代码行数:8,代码来源:gstreamer.py


示例3: readMedia

 def readMedia(self, media):
     conf = {}
     uuid = ''
     for opt in media:
         if(opt.attrib['name'] == 'uuid'):
             uuid = url.url2pathname(opt.attrib['value'])
         else:
             conf[opt.attrib['name']] = literal_eval(url.url2pathname(opt.attrib['value']))
     return (uuid, conf)
开发者ID:sanfx,项目名称:linux-show-player,代码行数:9,代码来源:xml_reader.py


示例4: identify

    def identify(self, song):
        media = self.instance.media_new(song.path)
        media.parse()
        media.get_meta(vlc.Meta.Album)
        track_info = {}
        try:
            track_info = {
                'track_nb': media.get_meta(vlc.Meta.TrackNumber),
                'title': media.get_meta(vlc.Meta.Title),
                'album': media.get_meta(vlc.Meta.Album),
                'artist': media.get_meta(vlc.Meta.Artist),
                'label': media.get_meta(vlc.Meta.Publisher),
                'date': media.get_meta(vlc.Meta.Date),
                'genre': media.get_meta(vlc.Meta.Genre),
                'artwork': media.get_meta(vlc.Meta.ArtworkURL)
            }
            if track_info['artwork'] is not None:
                track_info['artwork'] = url2pathname(track_info['artwork'][7:])

            print(track_info)

        except:
            # TODO:
            # - clean messed up tags
            # - create empty trackinfos
            pass
        # return track_info
        song.track_info = track_info
开发者ID:jdupl,项目名称:Lune,代码行数:28,代码来源:identifier.py


示例5: drag_data_received

	def drag_data_received(self,widget, drag_context, x, y, selection_data, info, timestamp):
		model = self.treeview.get_model()
		for filename in selection_data.get_uris():
			if len(filename)>8:
				filename = url2pathname(filename)
				filename = filename[7:]
				model.append([filename])
开发者ID:atareao,项目名称:crushing-machine,代码行数:7,代码来源:crushingmachine.py


示例6: drag_data_received

    def drag_data_received(self, widget, context, x, y, sel_data, info, time):
        """
        Handle the standard gtk interface for drag_data_received.

        If the selection data is define, extract the value from sel_data.data,
        and decide if this is a move or a reorder.
        The only data we accept on mediaview is dropping a file, so URI_LIST.
        We assume this is what we obtain
        """
        if not sel_data:
            return
        files = sel_data.get_uris()
        for file in files:
            protocol, site, mfile, j, k, l = urlparse(file)
            if protocol == "file":
                name = url2pathname(mfile)
                mime = get_type(name)
                if not is_valid_type(mime):
                    return
                photo = Media()
                self.uistate.set_busy_cursor(True)
                photo.set_checksum(create_checksum(name))
                self.uistate.set_busy_cursor(False)
                base_dir = str(media_path(self.dbstate.db))
                if os.path.exists(base_dir):
                    name = relative_path(name, base_dir)
                photo.set_path(name)
                photo.set_mime_type(mime)
                basename = os.path.basename(name)
                (root, ext) = os.path.splitext(basename)
                photo.set_description(root)
                with DbTxn(_("Drag Media Object"), self.dbstate.db) as trans:
                    self.dbstate.db.add_media(photo, trans)
        widget.emit_stop_by_name('drag_data_received')
开发者ID:SNoiraud,项目名称:gramps,代码行数:34,代码来源:mediaview.py


示例7: run

def run(node):
    """
    Primary entry-point for running this module.

    :param node: dict
    {
        "url": "https://some-site.com"
    }

    :return:
    {
        document_url: metadata,
        ...
    }
    :rtype:  dict
    """
    mapper    = lambda x: redis_load(x, r)
    url       = node.get('url', 'http://www.cic.gc.ca')
    pool      = ThreadPool(32)
    docs      = redis_docs(url, r)
    metadata  = pool.map(mapper, docs)
    return {
        url2pathname(k): v
            for k,v in metadata if v
    }
开发者ID:anukat2015,项目名称:linkalytics,代码行数:25,代码来源:tika.py


示例8: get_filename

    def get_filename(self, basename):
        """
        Returns full path to a file, for example:

        get_filename('css/one.css') -> '/full/path/to/static/css/one.css'
        """
        filename = None
        # first try finding the file in the root
        try:
            # call path first so remote storages don't make it to exists,
            # which would cause network I/O
            filename = self.storage.path(basename)
            if not self.storage.exists(basename):
                filename = None
        except NotImplementedError:
            # remote storages don't implement path, access the file locally
            if compressor_file_storage.exists(basename):
                filename = compressor_file_storage.path(basename)
        # secondly try to find it with staticfiles (in debug mode)
        if not filename and self.finders:
            filename = self.finders.find(url2pathname(basename))
        if filename:
            return filename
        # or just raise an exception as the last resort
        raise UncompressableFileError(
            "'%s' could not be found in the COMPRESS_ROOT '%s'%s" %
            (basename, settings.COMPRESS_ROOT,
             self.finders and " or with staticfiles." or "."))
开发者ID:ethirajit,项目名称:onlinepos,代码行数:28,代码来源:base.py


示例9: url_to_file_path

 def url_to_file_path(self, url):
     url_path = urlparse(url).path
     if url_path.endswith('/'):
         url_path += 'index.html'
     if url_path.startswith('/'):
         url_path = url_path[1:]
     return url2pathname(url_path)
开发者ID:vergeldeguzman,项目名称:web-scraper,代码行数:7,代码来源:web_scraper.py


示例10: _url_to_local_path

def _url_to_local_path(url, path):
    """Mirror a url path in a local destination (keeping folder structure)."""
    destination = parse.urlparse(url).path
    # First char should be '/', and it needs to be discarded
    if len(destination) < 2 or destination[0] != '/':
        raise ValueError('Invalid URL')
    destination = os.path.join(path, request.url2pathname(destination)[1:])
    return destination
开发者ID:palday,项目名称:mne-python,代码行数:8,代码来源:fetching.py


示例11: file_uri_to_path

def file_uri_to_path(uri):
    if PathCreateFromUrlW is not None:
        path_len = ctypes.c_uint32(260)
        path = ctypes.create_unicode_buffer(path_len.value)
        PathCreateFromUrlW(uri, path, ctypes.byref(path_len), 0)
        return path.value
    else:
        return url2pathname(urlparse(uri).path)
开发者ID:292388900,项目名称:OmniMarkupPreviewer,代码行数:8,代码来源:RendererManager.py


示例12: nativejoin

def nativejoin(base, path):
    """
    Joins two paths - returning a native file path.

    Given a base path and a relative location, (in posix format)
    return a file path in a (relatively) OS native way.
    """
    return url2pathname(pathjoin(base, path))
开发者ID:JDeuce,项目名称:webassets,代码行数:8,代码来源:urlpath.py


示例13: _get_filesystem_path

    def _get_filesystem_path(self, url_path, basedir=settings.MEDIA_ROOT):
        """
        Makes a filesystem path from the specified URL path
        """
        if url_path.startswith(settings.MEDIA_URL):
            # strip media root url
            url_path = url_path[len(settings.MEDIA_URL):]

        return os.path.normpath(os.path.join(basedir, url2pathname(url_path)))
开发者ID:lzanuz,项目名称:django-watermark,代码行数:9,代码来源:watermark.py


示例14: format_uri

 def format_uri(self, uri):
     path = url2pathname(uri) # escape special chars
     path = path.strip('\r\n\x00') # remove \r\n and NULL
     if path.startswith('file:\\\\\\'): # windows
         path = path[8:] # 8 is len('file:///')
     elif path.startswith('file://'): #nautilus, rox
         path = path[7:] # 7 is len('file://')
     elif path.startswith('file:'): # xffm
         path = path[5:] # 5 is len('file:')
     return path
开发者ID:pombredanne,项目名称:linuxtrail,代码行数:10,代码来源:DialogAddSourcesList.py


示例15: urlpath2path

def urlpath2path(url):
    """Like :func:`ur.url2pathname()`, but prefixing with UNC(\\\\?\\) long paths and preserving last slash."""
    import urllib.request as ur

    p = ur.url2pathname(url)
    if _is_dir_regex.search(url) and p[-1] != os.sep:
        p = p + osp.sep
    if len(p) > 200:
        p += _unc_prefix
    return p
开发者ID:ankostis,项目名称:pandalone,代码行数:10,代码来源:utils.py


示例16: repl_relative

def repl_relative(m, base_path, relative_path):
    """ Replace path with relative path """

    RE_WIN_DRIVE_PATH = re.compile(r"(^(?P<drive>[A-Za-z]{1}):(?:\\|/))")
    link = m.group(0)
    try:
        scheme, netloc, path, params, query, fragment, is_url, is_absolute = parse_url(m.group('path')[1:-1])

        if not is_url:
            # Get the absolute path of the file or return
            # if we can't resolve the path
            path = url2pathname(path)
            abs_path = None
            if (not is_absolute):
                # Convert current relative path to absolute
                temp = os.path.normpath(os.path.join(base_path, path))
                if os.path.exists(temp):
                    abs_path = temp.replace("\\", "/")
            elif os.path.exists(path):
                abs_path = path

            if abs_path is not None:
                convert = False
                # Determine if we should convert the relative path
                # (or see if we can realistically convert the path)
                if (sublime.platform() == "windows"):
                    # Make sure basepath starts with same drive location as target
                    # If they don't match, we will stay with absolute path.
                    if (base_path.startswith('//') and base_path.startswith('//')):
                        convert = True
                    else:
                        base_drive = RE_WIN_DRIVE_PATH.match(base_path)
                        path_drive = RE_WIN_DRIVE_PATH.match(abs_path)
                        if (
                            (base_drive and path_drive) and
                            base_drive.group('drive').lower() == path_drive.group('drive').lower()
                        ):
                            convert = True
                else:
                    # OSX and Linux
                    convert = True

                # Convert the path, url encode it, and format it as a link
                if convert:
                    path = pathname2url(os.path.relpath(abs_path, relative_path).replace('\\', '/'))
                else:
                    path = pathname2url(abs_path)
                link = '%s"%s"' % (m.group('name'), urlunparse((scheme, netloc, path, params, query, fragment)))
    except:
        # Parsing crashed an burned; no need to continue.
        pass

    return link
开发者ID:leebivip,项目名称:sublimetext-markdown-preview,代码行数:53,代码来源:MarkdownPreview.py


示例17: local_get

def local_get(url, *args, **kwargs):
    "Fetch a stream from local files."
    from requests import Response

    p_url = urlparse(url)
    if p_url.scheme != "file":
        raise ValueError("Expected file scheme")

    filename = url2pathname(p_url.path)
    response = Response()
    response.status_code = 200
    response.raw = open(filename, "rb")
    return response
开发者ID:MichelJuillard,项目名称:dlstats,代码行数:13,代码来源:test_esri.py


示例18: repl_absolute

def repl_absolute(m, base_path):
    """ Replace path with absolute path """
    link = m.group(0)
    scheme, netloc, path, params, query, fragment, is_url, is_absolute = parse_url(m.group("path")[1:-1])

    path = url2pathname(path)

    if not is_absolute and not is_url:
        temp = os.path.normpath(os.path.join(base_path, path))
        if os.path.exists(temp):
            path = pathname2url(temp.replace("\\", "/"))
            link = '%s"%s"' % (m.group("name"), urlunparse((scheme, netloc, path, params, query, fragment)))

    return link
开发者ID:kinjo1506,项目名称:sublimetext-markdown-preview,代码行数:14,代码来源:MarkdownPreview.py


示例19: handle

    def handle(self, options):
        self.console = component.get('ConsoleUI')

        t_options = {}
        if options.path:
            t_options['download_location'] = os.path.abspath(os.path.expanduser(options.path))

        def on_success(result):
            if not result:
                self.console.write('{!error!}Torrent was not added: Already in session')
            else:
                self.console.write('{!success!}Torrent added!')

        def on_fail(result):
            self.console.write('{!error!}Torrent was not added: %s' % result)

        # Keep a list of deferreds to make a DeferredList
        deferreds = []
        for torrent in options.torrents:
            if not torrent.strip():
                continue
            if deluge.common.is_url(torrent):
                self.console.write('{!info!}Attempting to add torrent from url: %s' % torrent)
                deferreds.append(client.core.add_torrent_url(torrent, t_options).addCallback(on_success).addErrback(
                    on_fail))
            elif deluge.common.is_magnet(torrent):
                self.console.write('{!info!}Attempting to add torrent from magnet uri: %s' % torrent)
                deferreds.append(client.core.add_torrent_magnet(torrent, t_options).addCallback(on_success).addErrback(
                    on_fail))
            else:
                # Just a file
                if urlparse(torrent).scheme == 'file':
                    torrent = url2pathname(urlparse(torrent).path)
                path = os.path.abspath(os.path.expanduser(torrent))
                if not os.path.exists(path):
                    self.console.write('{!error!}%s does not exist!' % path)
                    continue
                if not os.path.isfile(path):
                    self.console.write('{!error!}This is a directory!')
                    continue
                self.console.write('{!info!}Attempting to add torrent: %s' % path)
                filename = os.path.split(path)[-1]
                with open(path, 'rb') as _file:
                    filedump = base64.encodestring(_file.read())
                deferreds.append(client.core.add_torrent_file(filename, filedump, t_options).addCallback(
                    on_success).addErrback(on_fail))

        return defer.DeferredList(deferreds)
开发者ID:deluge-torrent,项目名称:deluge,代码行数:48,代码来源:add.py


示例20: get_url

 def get_url(self):
     """
     :returns: BZR URL of the branch (output of bzr info command), or None if it cannot be determined
     """
     result = None
     if self.detect_presence():
         cmd = 'bzr info %s' % self._path
         _, output, _ = run_shell_command(cmd, shell=True, us_env=True)
         matches = [l for l in output.splitlines() if l.startswith('  parent branch: ')]
         if matches:
             ppath = url2pathname(matches[0][len('  parent branch: '):])
             # when it can, bzr substitues absolute path for relative paths
             if (ppath is not None and os.path.isdir(ppath) and not os.path.isabs(ppath)):
                 result = os.path.abspath(os.path.join(os.getcwd(), ppath))
             else:
                 result = ppath
     return result
开发者ID:btubbs,项目名称:vcstools,代码行数:17,代码来源:bzr.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python request.urlopen函数代码示例发布时间:2022-05-27
下一篇:
Python request.unquote函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap