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


Python QUrl.isLocalFile方法代码示例

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


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

示例1: search

# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import isLocalFile [as 别名]
    def search(self, description):
        if description.help_ref:
            ref = description.help_ref
        else:
            raise KeyError()

        url = QUrl(self.baseurl).resolved(QUrl(ref))
        if url.isLocalFile():
            path = url.toLocalFile()
            fragment = url.fragment()
            if os.path.isfile(path):
                return url
            elif os.path.isfile("{}.html".format(path)):
                url = QUrl.fromLocalFile("{}.html".format(path))
                url.setFragment(fragment)
                return url
            elif os.path.isdir(path) and \
                    os.path.isfile(os.path.join(path, "index.html")):
                url = QUrl.fromLocalFile(os.path.join(path, "index.html"))
                url.setFragment(fragment)
                return url
            else:
                raise KeyError()
        else:
            if url.scheme() in ["http", "https"]:
                path = url.path()
                if not (path.endswith(".html") or path.endswith("/")):
                    url.setPath(path + ".html")
        return url
开发者ID:Coding4Sec,项目名称:orange3,代码行数:31,代码来源:provider.py

示例2: dropEvent

# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import isLocalFile [as 别名]
 def dropEvent(self, e):
     logger.debug(msg("Drag drop event"))
     file_url = QUrl(e.mimeData().text())
     if file_url.isValid() and file_url.isLocalFile():
         fname = file_url.toLocalFile()
         if fname in self.watcher.files():
             logger.debug(msg("already watching file", fname))
         else:
             self.watch_file(file_url.toLocalFile())
开发者ID:jonathanverner,项目名称:qidle,代码行数:11,代码来源:console.py

示例3: _fetch_inventory

# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import isLocalFile [as 别名]
    def _fetch_inventory(self, url):
        cache_dir = config.cache_dir()
        cache_dir = os.path.join(cache_dir, "help", type(self).__qualname__)

        try:
            os.makedirs(cache_dir)
        except OSError:
            pass

        url = QUrl(self.inventory)
        if not url.isLocalFile():
            # fetch and cache the inventory file.
            manager = QNetworkAccessManager(self)
            cache = QNetworkDiskCache()
            cache.setCacheDirectory(cache_dir)
            manager.setCache(cache)
            req = QNetworkRequest(url)

            self._reply = manager.get(req)
            manager.finished.connect(self._on_finished)
        else:
            self._load_inventory(open(str(url.toLocalFile()), "rb"))
开发者ID:Coding4Sec,项目名称:orange3,代码行数:24,代码来源:provider.py

示例4: dragEnterEvent

# 需要导入模块: from PyQt4.QtCore import QUrl [as 别名]
# 或者: from PyQt4.QtCore.QUrl import isLocalFile [as 别名]
 def dragEnterEvent(self, e):
     file_url = QUrl(e.mimeData().text())
     if file_url.isValid() and file_url.isLocalFile():
         e.acceptProposedAction()
     else:
         e.ignore()
开发者ID:jonathanverner,项目名称:qidle,代码行数:8,代码来源:console.py


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