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