eric6/Helpviewer/Network/FileAccessHandler.py

branch
maintenance
changeset 7286
7eb04391adf7
parent 7226
babe80d84a3e
parent 7285
1ff497f33f31
child 7287
1c17f2191bdd
equal deleted inserted replaced
7226:babe80d84a3e 7286:7eb04391adf7
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2012 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a scheme access handler for file.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import QFileInfo
13 from PyQt5.QtNetwork import QNetworkAccessManager
14
15 from .SchemeAccessHandler import SchemeAccessHandler
16
17
18 class FileAccessHandler(SchemeAccessHandler):
19 """
20 Class implementing a scheme access handler for FTP.
21 """
22 def __init__(self, parent=None):
23 """
24 Constructor
25
26 @param parent reference to the parent object (QObject)
27 """
28 super(FileAccessHandler, self).__init__(parent)
29
30 def createRequest(self, op, request, outgoingData=None):
31 """
32 Public method to create a request.
33
34 @param op the operation to be performed
35 (QNetworkAccessManager.Operation)
36 @param request reference to the request object (QNetworkRequest)
37 @param outgoingData reference to an IODevice containing data to be sent
38 (QIODevice)
39 @return reference to the created reply object (QNetworkReply)
40 """
41 if op == QNetworkAccessManager.GetOperation:
42 fileInfo = QFileInfo(request.url().toLocalFile())
43 if not fileInfo.isDir() or \
44 not fileInfo.isReadable() or \
45 not fileInfo.exists():
46 return None
47 from .FileReply import FileReply
48 return FileReply(request.url(), self.parent())
49 else:
50 return None

eric ide

mercurial