|
56 | 56 |
|
57 | 57 |
|
58 | 58 | def get_decoders():
|
59 |
| - """ |
60 |
| - Returns all available FTP LIST line decoders with their matching regexes. |
61 |
| - """ |
| 59 | + """Return all available FTP LIST line decoders with their matching regexes.""" |
62 | 60 | decoders = [
|
63 | 61 | (RE_LINUX, decode_linux),
|
64 | 62 | (RE_WINDOWSNT, decode_windowsnt),
|
@@ -149,13 +147,34 @@ def _decode_windowsnt_time(mtime):
|
149 | 147 |
|
150 | 148 |
|
151 | 149 | def decode_windowsnt(line, match):
|
152 |
| - """ |
153 |
| - Decodes a Windows NT FTP LIST line like one of these: |
| 150 | + """Decode a Windows NT FTP LIST line. |
| 151 | +
|
| 152 | + Examples: |
| 153 | + Decode a directory line:: |
| 154 | +
|
| 155 | + >>> line = "11-02-18 02:12PM <DIR> images" |
| 156 | + >>> match = RE_WINDOWSNT.match(line) |
| 157 | + >>> pprint(decode_windowsnt(line, match)) |
| 158 | + {'basic': {'is_dir': True, 'name': 'images'}, |
| 159 | + 'details': {'modified': 1518358320.0, 'type': 1}, |
| 160 | + 'ftp': {'ls': '11-02-18 02:12PM <DIR> images'}} |
| 161 | +
|
| 162 | + Decode a file line:: |
| 163 | +
|
| 164 | + >>> line = "11-02-18 03:33PM 9276 logo.gif" |
| 165 | + >>> match = RE_WINDOWSNT.match(line) |
| 166 | + >>> pprint(decode_windowsnt(line, match)) |
| 167 | + {'basic': {'is_dir': False, 'name': 'logo.gif'}, |
| 168 | + 'details': {'modified': 1518363180.0, 'size': 9276, 'type': 2}, |
| 169 | + 'ftp': {'ls': '11-02-18 03:33PM 9276 logo.gif'}} |
| 170 | +
|
| 171 | + Alternatively, the time might also be present in 24-hour format:: |
154 | 172 |
|
155 |
| - `11-02-18 02:12PM <DIR> images` |
156 |
| - `11-02-18 03:33PM 9276 logo.gif` |
| 173 | + >>> line = "11-02-18 15:33 9276 logo.gif" |
| 174 | + >>> match = RE_WINDOWSNT.match(line) |
| 175 | + >>> decode_windowsnt(line, match)["details"]["modified"] |
| 176 | + 1518363180.0 |
157 | 177 |
|
158 |
| - Alternatively, the time (02:12PM) might also be present in 24-hour format (14:12). |
159 | 178 | """
|
160 | 179 | is_dir = match.group("size") == "<DIR>"
|
161 | 180 |
|
|
0 commit comments