Skip to content

Commit 3bbbc48

Browse files
author
atollk
committed
Adding to the previous commit, performed minor changes according to suggestions from a code review.
1 parent 19e4387 commit 3bbbc48

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

fs/_ftp_parse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,11 @@ def decode_linux(line, match):
145145
return raw_info
146146

147147

148-
def _decode_windowsnt_time(date, time):
149-
while len(time.split(":")[0]) < 2:
150-
time = "0" + time
148+
def _decode_windowsnt_time(mdate, mtime):
149+
if len(mtime.split(":")[0]) == 1:
150+
mtime = "0" + mtime
151151
return _parse_time(
152-
date + " " + time, formats=["%d-%m-%y %I:%M%p", "%d-%m-%y %H:%M"]
152+
mdate + " " + mtime, formats=["%d-%m-%y %I:%M%p", "%d-%m-%y %H:%M"]
153153
)
154154

155155

tests/test_ftp_parse.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ def test_decode_windowsnt(self, mock_localtime):
173173
05-11-20 22:11 <DIR> src
174174
11-02-17 01:23 1 12
175175
11-02-17 4:54 0 icon.bmp
176+
11-02-17 4:54AM 0 icon.gif
177+
11-02-17 4:54PM 0 icon.png
178+
11-02-17 16:54 0 icon.jpg
176179
"""
177180
expected = [
178181
{
@@ -210,6 +213,21 @@ def test_decode_windowsnt(self, mock_localtime):
210213
"details": {"modified": 1486788840.0, "size": 0, "type": 2},
211214
"ftp": {"ls": "11-02-17 4:54 0 icon.bmp"},
212215
},
216+
{
217+
"basic": {"is_dir": False, "name": "icon.gif"},
218+
"details": {"modified": 1486788840.0, "size": 0, "type": 2},
219+
"ftp": {"ls": "11-02-17 4:54AM 0 icon.gif"},
220+
},
221+
{
222+
"basic": {"is_dir": False, "name": "icon.png"},
223+
"details": {"modified": 1486832040.0, "size": 0, "type": 2},
224+
"ftp": {"ls": "11-02-17 4:54PM 0 icon.png"},
225+
},
226+
{
227+
"basic": {"is_dir": False, "name": "icon.jpg"},
228+
"details": {"modified": 1486832040.0, "size": 0, "type": 2},
229+
"ftp": {"ls": "11-02-17 16:54 0 icon.jpg"},
230+
},
213231
]
214232

215233
parsed = ftp_parse.parse(directory.splitlines())

0 commit comments

Comments
 (0)