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


Python QUrl.startswith方法代码示例

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


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

示例1: handle_url

# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import startswith [as 别名]
def handle_url(path, style, url, for_import=False):
    if ((url.startswith('"') and url.endswith('"')) or
            (url.startswith("'") and url.endswith("'"))):
        url = url[1:-1]

    # Make a QUrl.
    url = QUrl(url.decode('unicode_escape'))

    if url.scheme() == 'data':
        return data_url(url)

    # If it's relative, build an absolute URL. If not, return.
    if not url.isRelative():
        return

    url = url.toLocalFile()
    if url.startswith('/'):
        url = url[1:]
    else:
        url = style.path.join(path, url)

    if for_import:
        return url

    return find_url(style, url)
开发者ID:apt-shansen,项目名称:siding,代码行数:27,代码来源:qss.py

示例2: _qss_url

# 需要导入模块: from PySide.QtCore import QUrl [as 别名]
# 或者: from PySide.QtCore.QUrl import startswith [as 别名]
   def _qss_url(self, path, url, allow_inheritance=True, _suppress=False,
                for_import=False):
       """
       Process a url() and return an absolute URL, or None if the URL isn't
       valid.
       """
       if (url.startswith('"') and url.endswith('"')) or \
               (url.startswith("'") and url.endswith("'")):
           url = url[1:-1]
 
       # Make a QUrl.
       url = QUrl(url.decode('unicode_escape'))
 
       # Is it a data uri?
       if url.scheme() == 'data':
           # Extract the useful information from the path.
           format, sep, data = url.path().partition(',')
           if not sep and not data:
               data = format
               format = ''
 
           mimetype, _, format = format.partition(';')
           if not mimetype:
               ext = 'txt'
           else:
               _, _, ext = mimetype.rpartition('/')
           if not format:
               format = 'charset=US-ASCII'
 
           # Build the filename.
           fn = os.path.join(profile.cache_path, u'data-uris',
                   '%s.%s' % (hashlib.md5(data).hexdigest(), ext))
 
           # Ensure the path exists and write the file.
           try:
               if not os.path.exists(os.path.dirname(fn)):
                   os.makedirs(os.path.dirname(fn))
               with open(fn, 'wb') as f:
                   if format == 'base64':
                       f.write(base64.b64decode(data))
                   elif format.startswith('charset='):
                       data = urllib.unquote(data).encode('latin1')
                       cs = format[8:]
                       if cs and cs.lower() not in ('utf-8','utf8'):
                           data = data.decode(cs).encode('utf-8')
                       f.write(data)
                   else:
                       return
           except (ValueError, OSError, IOError, TypeError):
               log.debug('Error parsing data URI.', exc_info=1)
               return
 
           # Substitute the right / on Windows, and return the path.
           if os.name == 'nt':
               fn = fn.replace('\\', '/')
           return fn
 
       # If it's relative, build an absolute URL. If not, return.
       if not url.isRelative():
           return
 
       url = url.toLocalFile()
       if url.startswith('/'):
           url = url[1:]
       else:
           url = profile.join(path, url)
 
       # If we're dealing with import, return a relative path.
       if for_import:
           return url
 
       return self.get_path(url, allow_inheritance, False, _suppress)
开发者ID:mornhuang,项目名称:study,代码行数:74,代码来源:style.py


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