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


Python request.url2pathname函数代码示例

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


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


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