|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Utilities.FtpUtilities</title> |
|
4 <meta charset="UTF-8"> |
|
5 <link rel="stylesheet" href="styles.css"> |
|
6 </head> |
|
7 <body> |
|
8 <a NAME="top" ID="top"></a> |
|
9 <h1>eric7.Utilities.FtpUtilities</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing some FTP related utilities. |
|
13 </p> |
|
14 <h3>Global Attributes</h3> |
|
15 |
|
16 <table> |
|
17 <tr><td>None</td></tr> |
|
18 </table> |
|
19 <h3>Classes</h3> |
|
20 |
|
21 <table> |
|
22 |
|
23 <tr> |
|
24 <td><a href="#FtpDirLineParser">FtpDirLineParser</a></td> |
|
25 <td>Class to parse lines returned by a FTP LIST command.</td> |
|
26 </tr> |
|
27 <tr> |
|
28 <td><a href="#FtpDirLineParserError">FtpDirLineParserError</a></td> |
|
29 <td>Exception class raised, if a parser issue was detected.</td> |
|
30 </tr> |
|
31 </table> |
|
32 <h3>Functions</h3> |
|
33 |
|
34 <table> |
|
35 <tr><td>None</td></tr> |
|
36 </table> |
|
37 <hr /> |
|
38 <hr /> |
|
39 <a NAME="FtpDirLineParser" ID="FtpDirLineParser"></a> |
|
40 <h2>FtpDirLineParser</h2> |
|
41 |
|
42 <p> |
|
43 Class to parse lines returned by a FTP LIST command. |
|
44 </p> |
|
45 <h3>Derived from</h3> |
|
46 QObject |
|
47 <h3>Class Attributes</h3> |
|
48 |
|
49 <table> |
|
50 <tr><td>MonthnamesNumbers</td></tr> |
|
51 </table> |
|
52 <h3>Class Methods</h3> |
|
53 |
|
54 <table> |
|
55 <tr><td>None</td></tr> |
|
56 </table> |
|
57 <h3>Methods</h3> |
|
58 |
|
59 <table> |
|
60 |
|
61 <tr> |
|
62 <td><a href="#FtpDirLineParser.__init__">FtpDirLineParser</a></td> |
|
63 <td>Constructor</td> |
|
64 </tr> |
|
65 <tr> |
|
66 <td><a href="#FtpDirLineParser.__ignoreLine">__ignoreLine</a></td> |
|
67 <td>Private method to check, if the line should be ignored.</td> |
|
68 </tr> |
|
69 <tr> |
|
70 <td><a href="#FtpDirLineParser.__parseUnixLine">__parseUnixLine</a></td> |
|
71 <td>Private method to parse a Unix style directory listing line.</td> |
|
72 </tr> |
|
73 <tr> |
|
74 <td><a href="#FtpDirLineParser.__parseUnixMode">__parseUnixMode</a></td> |
|
75 <td>Private method to parse a Unix mode string modifying the given URL info object.</td> |
|
76 </tr> |
|
77 <tr> |
|
78 <td><a href="#FtpDirLineParser.__parseUnixTime">__parseUnixTime</a></td> |
|
79 <td>Private method to parse a Unix date and time indication modifying the given URL info object.</td> |
|
80 </tr> |
|
81 <tr> |
|
82 <td><a href="#FtpDirLineParser.__parseWindowsLine">__parseWindowsLine</a></td> |
|
83 <td>Private method to parse a Windows style directory listing line.</td> |
|
84 </tr> |
|
85 <tr> |
|
86 <td><a href="#FtpDirLineParser.__parseWindowsTime">__parseWindowsTime</a></td> |
|
87 <td>Private method to parse a Windows date and time indication modifying the given URL info object.</td> |
|
88 </tr> |
|
89 <tr> |
|
90 <td><a href="#FtpDirLineParser.__splitUnixLine">__splitUnixLine</a></td> |
|
91 <td>Private method to split a line of a Unix like directory listing.</td> |
|
92 </tr> |
|
93 <tr> |
|
94 <td><a href="#FtpDirLineParser.parseLine">parseLine</a></td> |
|
95 <td>Public method to parse a directory listing line.</td> |
|
96 </tr> |
|
97 </table> |
|
98 <h3>Static Methods</h3> |
|
99 |
|
100 <table> |
|
101 <tr><td>None</td></tr> |
|
102 </table> |
|
103 |
|
104 <a NAME="FtpDirLineParser.__init__" ID="FtpDirLineParser.__init__"></a> |
|
105 <h4>FtpDirLineParser (Constructor)</h4> |
|
106 <b>FtpDirLineParser</b>(<i>parent=None</i>) |
|
107 |
|
108 <p> |
|
109 Constructor |
|
110 </p> |
|
111 <dl> |
|
112 |
|
113 <dt><i>parent</i></dt> |
|
114 <dd> |
|
115 reference to the parent object (QObject) |
|
116 </dd> |
|
117 </dl> |
|
118 <a NAME="FtpDirLineParser.__ignoreLine" ID="FtpDirLineParser.__ignoreLine"></a> |
|
119 <h4>FtpDirLineParser.__ignoreLine</h4> |
|
120 <b>__ignoreLine</b>(<i>line</i>) |
|
121 |
|
122 <p> |
|
123 Private method to check, if the line should be ignored. |
|
124 </p> |
|
125 <dl> |
|
126 |
|
127 <dt><i>line</i></dt> |
|
128 <dd> |
|
129 to check (string) |
|
130 </dd> |
|
131 </dl> |
|
132 <dl> |
|
133 <dt>Return:</dt> |
|
134 <dd> |
|
135 flag indicating to ignore the line (boolean) |
|
136 </dd> |
|
137 </dl> |
|
138 <a NAME="FtpDirLineParser.__parseUnixLine" ID="FtpDirLineParser.__parseUnixLine"></a> |
|
139 <h4>FtpDirLineParser.__parseUnixLine</h4> |
|
140 <b>__parseUnixLine</b>(<i>line</i>) |
|
141 |
|
142 <p> |
|
143 Private method to parse a Unix style directory listing line. |
|
144 </p> |
|
145 <dl> |
|
146 |
|
147 <dt><i>line</i></dt> |
|
148 <dd> |
|
149 directory line to be parsed (string) |
|
150 </dd> |
|
151 </dl> |
|
152 <dl> |
|
153 <dt>Return:</dt> |
|
154 <dd> |
|
155 URL info object containing the valid data (EricUrlInfo) |
|
156 </dd> |
|
157 </dl> |
|
158 <a NAME="FtpDirLineParser.__parseUnixMode" ID="FtpDirLineParser.__parseUnixMode"></a> |
|
159 <h4>FtpDirLineParser.__parseUnixMode</h4> |
|
160 <b>__parseUnixMode</b>(<i>modeString, urlInfo</i>) |
|
161 |
|
162 <p> |
|
163 Private method to parse a Unix mode string modifying the |
|
164 given URL info object. |
|
165 </p> |
|
166 <dl> |
|
167 |
|
168 <dt><i>modeString</i></dt> |
|
169 <dd> |
|
170 mode string to be parsed (string) |
|
171 </dd> |
|
172 <dt><i>urlInfo</i></dt> |
|
173 <dd> |
|
174 reference to the URL info object (EricUrlInfo) |
|
175 </dd> |
|
176 </dl> |
|
177 <dl> |
|
178 |
|
179 <dt>Raises <b>FtpDirLineParserError</b>:</dt> |
|
180 <dd> |
|
181 Raised if the mode cannot be parsed. |
|
182 </dd> |
|
183 </dl> |
|
184 <a NAME="FtpDirLineParser.__parseUnixTime" ID="FtpDirLineParser.__parseUnixTime"></a> |
|
185 <h4>FtpDirLineParser.__parseUnixTime</h4> |
|
186 <b>__parseUnixTime</b>(<i>monthAbbreviation, day, yearOrTime, urlInfo</i>) |
|
187 |
|
188 <p> |
|
189 Private method to parse a Unix date and time indication modifying |
|
190 the given URL info object. |
|
191 </p> |
|
192 <p> |
|
193 |
|
194 </p> |
|
195 <p> |
|
196 Date time strings in Unix-style directory listings typically |
|
197 have one of these formats: |
|
198 <ul> |
|
199 <li>"Nov 23 02:33" (month name, day of month, time)</li> |
|
200 <li>"May 26 2005" (month name, day of month, year)</li> |
|
201 </ul> |
|
202 </p> |
|
203 <dl> |
|
204 |
|
205 <dt><i>monthAbbreviation</i></dt> |
|
206 <dd> |
|
207 abbreviation of the month name (string) |
|
208 </dd> |
|
209 <dt><i>day</i></dt> |
|
210 <dd> |
|
211 day of the month (string) |
|
212 </dd> |
|
213 <dt><i>yearOrTime</i></dt> |
|
214 <dd> |
|
215 string giving the year or a time (string) |
|
216 </dd> |
|
217 <dt><i>urlInfo</i></dt> |
|
218 <dd> |
|
219 reference to the URL info object (EricUrlInfo) |
|
220 </dd> |
|
221 </dl> |
|
222 <dl> |
|
223 |
|
224 <dt>Raises <b>FtpDirLineParserError</b>:</dt> |
|
225 <dd> |
|
226 Raised if the month abbreviation is |
|
227 not recognized. |
|
228 </dd> |
|
229 </dl> |
|
230 <a NAME="FtpDirLineParser.__parseWindowsLine" ID="FtpDirLineParser.__parseWindowsLine"></a> |
|
231 <h4>FtpDirLineParser.__parseWindowsLine</h4> |
|
232 <b>__parseWindowsLine</b>(<i>line</i>) |
|
233 |
|
234 <p> |
|
235 Private method to parse a Windows style directory listing line. |
|
236 </p> |
|
237 <dl> |
|
238 |
|
239 <dt><i>line</i></dt> |
|
240 <dd> |
|
241 directory line to be parsed (string) |
|
242 </dd> |
|
243 </dl> |
|
244 <dl> |
|
245 <dt>Return:</dt> |
|
246 <dd> |
|
247 URL info object containing the valid data (EricUrlInfo) |
|
248 </dd> |
|
249 </dl> |
|
250 <dl> |
|
251 |
|
252 <dt>Raises <b>FtpDirLineParserError</b>:</dt> |
|
253 <dd> |
|
254 Raised if the line is not of a |
|
255 recognized Windows format. |
|
256 </dd> |
|
257 </dl> |
|
258 <a NAME="FtpDirLineParser.__parseWindowsTime" ID="FtpDirLineParser.__parseWindowsTime"></a> |
|
259 <h4>FtpDirLineParser.__parseWindowsTime</h4> |
|
260 <b>__parseWindowsTime</b>(<i>date, time, urlInfo</i>) |
|
261 |
|
262 <p> |
|
263 Private method to parse a Windows date and time indication modifying |
|
264 the given URL info object. |
|
265 </p> |
|
266 <p> |
|
267 Date time strings in Windows-style directory listings typically |
|
268 have the format "10-23-12 03:25PM" (month-day_of_month-two_digit_year, |
|
269 hour:minute, am/pm). |
|
270 </p> |
|
271 <dl> |
|
272 |
|
273 <dt><i>date</i></dt> |
|
274 <dd> |
|
275 date string (string) |
|
276 </dd> |
|
277 <dt><i>time</i></dt> |
|
278 <dd> |
|
279 time string (string) |
|
280 </dd> |
|
281 <dt><i>urlInfo</i></dt> |
|
282 <dd> |
|
283 reference to the URL info object (EricUrlInfo) |
|
284 </dd> |
|
285 </dl> |
|
286 <dl> |
|
287 |
|
288 <dt>Raises <b>FtpDirLineParserError</b>:</dt> |
|
289 <dd> |
|
290 Raised if either of the strings is not |
|
291 recognized. |
|
292 </dd> |
|
293 </dl> |
|
294 <a NAME="FtpDirLineParser.__splitUnixLine" ID="FtpDirLineParser.__splitUnixLine"></a> |
|
295 <h4>FtpDirLineParser.__splitUnixLine</h4> |
|
296 <b>__splitUnixLine</b>(<i>line</i>) |
|
297 |
|
298 <p> |
|
299 Private method to split a line of a Unix like directory listing. |
|
300 </p> |
|
301 <p> |
|
302 It splits the line into meta data, number of links, user, group, size, |
|
303 month, day, year or time and name. |
|
304 </p> |
|
305 <dl> |
|
306 |
|
307 <dt><i>line</i></dt> |
|
308 <dd> |
|
309 directory line to split (string) |
|
310 </dd> |
|
311 </dl> |
|
312 <dl> |
|
313 <dt>Return:</dt> |
|
314 <dd> |
|
315 tuple of nine strings giving the meta data, |
|
316 number of links, user, group, size, month, day, year or time |
|
317 and name |
|
318 </dd> |
|
319 </dl> |
|
320 <dl> |
|
321 |
|
322 <dt>Raises <b>FtpDirLineParserError</b>:</dt> |
|
323 <dd> |
|
324 Raised if the line is not of a |
|
325 recognized Unix format. |
|
326 </dd> |
|
327 </dl> |
|
328 <a NAME="FtpDirLineParser.parseLine" ID="FtpDirLineParser.parseLine"></a> |
|
329 <h4>FtpDirLineParser.parseLine</h4> |
|
330 <b>parseLine</b>(<i>line</i>) |
|
331 |
|
332 <p> |
|
333 Public method to parse a directory listing line. |
|
334 </p> |
|
335 <p> |
|
336 This implementation support Unix and Windows style directory |
|
337 listings. It tries Unix style first and if that fails switches |
|
338 to Windows style. If that fails as well, an exception is raised. |
|
339 </p> |
|
340 <dl> |
|
341 |
|
342 <dt><i>line</i></dt> |
|
343 <dd> |
|
344 directory line to be parsed (string) |
|
345 </dd> |
|
346 </dl> |
|
347 <dl> |
|
348 <dt>Return:</dt> |
|
349 <dd> |
|
350 URL info object containing the valid data (EricUrlInfo) |
|
351 </dd> |
|
352 </dl> |
|
353 <div align="right"><a href="#top">Up</a></div> |
|
354 <hr /> |
|
355 <hr /> |
|
356 <a NAME="FtpDirLineParserError" ID="FtpDirLineParserError"></a> |
|
357 <h2>FtpDirLineParserError</h2> |
|
358 |
|
359 <p> |
|
360 Exception class raised, if a parser issue was detected. |
|
361 </p> |
|
362 <h3>Derived from</h3> |
|
363 Exception |
|
364 <h3>Class Attributes</h3> |
|
365 |
|
366 <table> |
|
367 <tr><td>None</td></tr> |
|
368 </table> |
|
369 <h3>Class Methods</h3> |
|
370 |
|
371 <table> |
|
372 <tr><td>None</td></tr> |
|
373 </table> |
|
374 <h3>Methods</h3> |
|
375 |
|
376 <table> |
|
377 <tr><td>None</td></tr> |
|
378 </table> |
|
379 <h3>Static Methods</h3> |
|
380 |
|
381 <table> |
|
382 <tr><td>None</td></tr> |
|
383 </table> |
|
384 |
|
385 <div align="right"><a href="#top">Up</a></div> |
|
386 <hr /> |
|
387 </body></html> |