From 95c6fbb0545db3ce268b986b91d6fbfccedd164a Mon Sep 17 00:00:00 2001 From: gneiss15 <36615981+gneiss15@users.noreply.github.com> Date: Fri, 9 Jul 2021 12:09:33 +0200 Subject: [PATCH] Make mkdir.py work under python3 versions below 3.5 (#8194) * Make mkdir.py work unter python3 versions below 3.5 Because early versions of python3 did not have the optional arg "exist_ok" for "pathlib.Path(...).mkdir(...)" a build under this versions will abort with an error message. This PR will modify the python script so that it works even under python 3.4 (and below). --- tools/mkdir.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/mkdir.py b/tools/mkdir.py index 13fb26326..c4e6756f7 100755 --- a/tools/mkdir.py +++ b/tools/mkdir.py @@ -12,7 +12,10 @@ def main(): parser.add_argument('dir', action='store', nargs='+') ns = parser.parse_args() for p in ns.dir: - pathlib.Path(p).mkdir(parents=ns.parents, exist_ok=True) + try: + pathlib.Path(p).mkdir(parents=ns.parents) + except FileExistsError: + pass return 0 if __name__ == '__main__':