Skip to content

Commit c04ff0a

Browse files
author
atollk
committed
Re-merged two functions in fs._ftp_parse.
See #439 (review) for details. The function `_find_suitable_format` was inlined into `_parse_time`.
1 parent 89d0919 commit c04ff0a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

fs/_ftp_parse.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,16 @@ def _find_suitable_format(t, formats):
9595

9696

9797
def _parse_time(t, formats):
98-
frmt = _find_suitable_format(t, formats)
99-
if frmt is None:
98+
_t = None
99+
for frmt in formats:
100+
try:
101+
_t = time.strptime(t, frmt)
102+
if t:
103+
break
104+
except ValueError:
105+
continue
106+
if not _t:
100107
return None
101-
_t = time.strptime(t, frmt)
102108

103109
year = _t.tm_year if _t.tm_year != 1900 else time.localtime().tm_year
104110
month = _t.tm_mon

0 commit comments

Comments
 (0)