add python27 support by using reduce instead of max

This commit is contained in:
Ronny Pfannschmidt 2018-09-16 14:34:50 +02:00
parent b48e23d54c
commit 2e39fd89d1
1 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,7 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import re import re
from six.moves import reduce
import pytest import pytest
import py import py
@ -24,13 +25,14 @@ def make_numbered_dir(root, prefix):
for i in range(10): for i in range(10):
# try up to 10 times to create the folder # try up to 10 times to create the folder
max_existing = max( max_existing = reduce(
max,
( (
parse_num(x) parse_num(x)
for x in root.iterdir() for x in root.iterdir()
if x.name.lower().startswith(l_prefix) if x.name.lower().startswith(l_prefix)
), ),
default=-1, -1,
) )
new_number = max_existing + 1 new_number = max_existing + 1
new_path = root.joinpath("{}{}".format(prefix, new_number)) new_path = root.joinpath("{}{}".format(prefix, new_number))