Utilities/FtpUtilities.py

changeset 2965
d133c7edd88a
parent 2302
f29e9405c851
child 2997
7f0ef975da9e
equal deleted inserted replaced
2964:84b65fb9e780 2965:d133c7edd88a
16 16
17 class FtpDirLineParserError(Exception): 17 class FtpDirLineParserError(Exception):
18 """ 18 """
19 Exception class raised, if a parser issue was detected. 19 Exception class raised, if a parser issue was detected.
20 """ 20 """
21 pass
21 22
22 23
23 class FtpDirLineParser(QObject): 24 class FtpDirLineParser(QObject):
24 """ 25 """
25 Class to parse lines returned by a FTP LIST command. 26 Class to parse lines returned by a FTP LIST command.
151 lastModified = QDateTime(QDate(year, month, day), QTime(hour, minute)) 152 lastModified = QDateTime(QDate(year, month, day), QTime(hour, minute))
152 urlInfo.setLastModified(lastModified) 153 urlInfo.setLastModified(lastModified)
153 154
154 def __splitUnixLine(self, line): 155 def __splitUnixLine(self, line):
155 """ 156 """
156 Split a line of a Unix like directory listing into meta data, 157 Private method to split a line of a Unix like directory listing.
157 number of links, user, group, size, month, day, year or time 158
158 and name. 159 It splits the line into meta data, number of links, user, group, size,
159 160 month, day, year or time and name.
161
162 @param line directory line to split (string)
160 @return tuple of nine strings giving the meta data, 163 @return tuple of nine strings giving the meta data,
161 number of links, user, group, size, month, day, year or time 164 number of links, user, group, size, month, day, year or time
162 and name 165 and name
163 @exception FtpDirLineParserError Raised if the line is not of a 166 @exception FtpDirLineParserError Raised if the line is not of a
164 recognized Unix format. 167 recognized Unix format.
190 """ 193 """
191 Private method to parse a Unix style directory listing line. 194 Private method to parse a Unix style directory listing line.
192 195
193 @param line directory line to be parsed (string) 196 @param line directory line to be parsed (string)
194 @return URL info object containing the valid data (E5UrlInfo) 197 @return URL info object containing the valid data (E5UrlInfo)
195 @exception FtpDirLineParserError Raised if the line is not of a
196 recognized Unix format.
197 """ 198 """
198 modeString, nlink, user, group, size, month, day, \ 199 modeString, nlink, user, group, size, month, day, \
199 yearOrTime, name = self.__splitUnixLine(line) 200 yearOrTime, name = self.__splitUnixLine(line)
200 201
201 if name in [".", ".."]: 202 if name in [".", ".."]:
304 listings. It tries Unix style first and if that fails switches 305 listings. It tries Unix style first and if that fails switches
305 to Windows style. If that fails as well, an exception is raised. 306 to Windows style. If that fails as well, an exception is raised.
306 307
307 @param line directory line to be parsed (string) 308 @param line directory line to be parsed (string)
308 @return URL info object containing the valid data (E5UrlInfo) 309 @return URL info object containing the valid data (E5UrlInfo)
309 @exception FtpDirLineParserError Raised if the line is not of a
310 recognized format.
311 """ 310 """
312 if self.__ignoreLine(line): 311 if self.__ignoreLine(line):
313 return None 312 return None
314 313
315 try: 314 try:

eric ide

mercurial