|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a class replacing QUrlInfo. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import QDateTime |
|
13 |
|
14 |
|
15 class E5UrlInfo(object): |
|
16 """ |
|
17 Class implementing a replacement for QUrlInfo. |
|
18 """ |
|
19 ReadOwner = 0o0400 |
|
20 WriteOwner = 0o0200 |
|
21 ExeOwner = 0o0100 |
|
22 ReadGroup = 0o0040 |
|
23 WriteGroup = 0o0020 |
|
24 ExeGroup = 0o0010 |
|
25 ReadOther = 0o0004 |
|
26 WriteOther = 0o0002 |
|
27 ExeOther = 0o0001 |
|
28 |
|
29 def __init__(self): |
|
30 """ |
|
31 Constructor |
|
32 """ |
|
33 self.__valid = False |
|
34 |
|
35 self.__permissions = 0 |
|
36 self.__size = 0 |
|
37 self.__isDir = False |
|
38 self.__isFile = True |
|
39 self.__isSymlink = False |
|
40 self.__isWritable = True |
|
41 self.__isReadable = True |
|
42 self.__isExecutable = False |
|
43 self.__name = "" |
|
44 self.__owner = "" |
|
45 self.__group = "" |
|
46 self.__lastModified = QDateTime() |
|
47 self.__lastRead = QDateTime() |
|
48 |
|
49 def isValid(self): |
|
50 """ |
|
51 Public method to check the validity of the object. |
|
52 |
|
53 @return flag indicating validity (boolean) |
|
54 """ |
|
55 return self.__valid |
|
56 |
|
57 def setName(self, name): |
|
58 """ |
|
59 Public method to set the name. |
|
60 |
|
61 @param name name to be set (string) |
|
62 """ |
|
63 self.__name = name |
|
64 self.__valid = True |
|
65 |
|
66 def setPermissions(self, permissions): |
|
67 """ |
|
68 Public method to set the permissions. |
|
69 |
|
70 @param permissions permissions to be set (integer) |
|
71 """ |
|
72 self.__permissions = permissions |
|
73 self.__valid = True |
|
74 |
|
75 def setDir(self, isDir): |
|
76 """ |
|
77 Public method to indicate a directory. |
|
78 |
|
79 @param isDir flag indicating a directory (boolean) |
|
80 """ |
|
81 self.__isDir = isDir |
|
82 self.__valid = True |
|
83 |
|
84 def setFile(self, isFile): |
|
85 """ |
|
86 Public method to indicate a file. |
|
87 |
|
88 @param isFile flag indicating a file (boolean) |
|
89 """ |
|
90 self.__isFile = isFile |
|
91 self.__valid = True |
|
92 |
|
93 def setSymLink(self, isSymLink): |
|
94 """ |
|
95 Public method to indicate a symbolic link. |
|
96 |
|
97 @param isSymLink flag indicating a symbolic link (boolean) |
|
98 """ |
|
99 self.__isSymLink = isSymLink |
|
100 self.__valid = True |
|
101 |
|
102 def setOwner(self, owner): |
|
103 """ |
|
104 Public method to set the owner. |
|
105 |
|
106 @param owner owner to be set (string) |
|
107 """ |
|
108 self.__owner = owner |
|
109 self.__valid = True |
|
110 |
|
111 def setGroup(self, group): |
|
112 """ |
|
113 Public method to set the group. |
|
114 |
|
115 @param group group to be set (string) |
|
116 """ |
|
117 self.__group = group |
|
118 self.__valid = True |
|
119 |
|
120 def setSize(self, size): |
|
121 """ |
|
122 Public method to set the size. |
|
123 |
|
124 @param size size to be set (integer) |
|
125 """ |
|
126 self.__size = size |
|
127 self.__valid = True |
|
128 |
|
129 def setWritable(self, isWritable): |
|
130 """ |
|
131 Public method to a writable entry. |
|
132 |
|
133 @param isWritable flag indicating a writable entry (boolean) |
|
134 """ |
|
135 self.__isWritable = isWritable |
|
136 self.__valid = True |
|
137 |
|
138 def setReadable(self, isReadable): |
|
139 """ |
|
140 Public method to a readable entry. |
|
141 |
|
142 @param isReadable flag indicating a readable entry (boolean) |
|
143 """ |
|
144 self.__isReadable = isReadable |
|
145 self.__valid = True |
|
146 |
|
147 def setLastModified(self, dt): |
|
148 """ |
|
149 Public method to set the last modified date and time. |
|
150 |
|
151 @param dt date and time to set (QDateTime) |
|
152 """ |
|
153 self.__lastModified = QDateTime(dt) |
|
154 self.__valid = True |
|
155 |
|
156 def setLastRead(self, dt): |
|
157 """ |
|
158 Public method to set the last read date and time. |
|
159 |
|
160 @param dt date and time to set (QDateTime) |
|
161 """ |
|
162 self.__lastRead = QDateTime(dt) |
|
163 self.__valid = True |
|
164 |
|
165 def name(self): |
|
166 """ |
|
167 Public method to get the name. |
|
168 |
|
169 @return name (string) |
|
170 """ |
|
171 return self.__name |
|
172 |
|
173 def permissions(self): |
|
174 """ |
|
175 Public method to get the permissions. |
|
176 |
|
177 @return permissions (integer) |
|
178 """ |
|
179 return self.__permissions |
|
180 |
|
181 def owner(self): |
|
182 """ |
|
183 Public method to get the owner. |
|
184 |
|
185 @return owner (string) |
|
186 """ |
|
187 return self.__owner |
|
188 |
|
189 def group(self): |
|
190 """ |
|
191 Public method to get the group. |
|
192 |
|
193 @return group (string) |
|
194 """ |
|
195 return self.__group |
|
196 |
|
197 def size(self): |
|
198 """ |
|
199 Public method to get the size. |
|
200 |
|
201 @return size (integer) |
|
202 """ |
|
203 return self.__size |
|
204 |
|
205 def lastModified(self): |
|
206 """ |
|
207 Public method to get the last modified date and time. |
|
208 |
|
209 @return last modified date and time (QDateTime) |
|
210 """ |
|
211 return QDateTime(self.__lastModified) |
|
212 |
|
213 def lastRead(self): |
|
214 """ |
|
215 Public method to get the last read date and time. |
|
216 |
|
217 @return last read date and time (QDateTime) |
|
218 """ |
|
219 return QDateTime(self.__lastRead) |
|
220 |
|
221 def isDir(self): |
|
222 """ |
|
223 Public method to test, if the entry is a directory. |
|
224 |
|
225 @return flag indicating a directory (boolean) |
|
226 """ |
|
227 return self.__isDir |
|
228 |
|
229 def isFile(self): |
|
230 """ |
|
231 Public method to test, if the entry is a file. |
|
232 |
|
233 @return flag indicating a file (boolean) |
|
234 """ |
|
235 return self.__isFile |
|
236 |
|
237 def isSymLink(self): |
|
238 """ |
|
239 Public method to test, if the entry is a symbolic link. |
|
240 |
|
241 @return flag indicating a symbolic link (boolean) |
|
242 """ |
|
243 return self.__isSymlink |
|
244 |
|
245 def isWritable(self): |
|
246 """ |
|
247 Public method to test, if the entry is writable. |
|
248 |
|
249 @return flag indicating writable (boolean) |
|
250 """ |
|
251 return self.__isWritable |
|
252 |
|
253 def isReadable(self): |
|
254 """ |
|
255 Public method to test, if the entry is readable. |
|
256 |
|
257 @return flag indicating readable (boolean) |
|
258 """ |
|
259 return self.__isReadable |
|
260 |
|
261 def isExecutable(self): |
|
262 """ |
|
263 Public method to test, if the entry is executable. |
|
264 |
|
265 @return flag indicating executable (boolean) |
|
266 """ |
|
267 return self.__isExecutable |