1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00
esp8266/tools/mkdir.py
gneiss15 95c6fbb054
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).
2021-07-09 12:09:33 +02:00

23 lines
622 B
Python
Executable File

#!/usr/bin/env python3
# Platform-independent `mkdir`
import argparse
import pathlib
import sys
def main():
parser = argparse.ArgumentParser(description='Platform-independent `mkdir`')
parser.add_argument('-p', '--parents', action='store_true', required=False, help='no error if existing, make parent directories as needed')
parser.add_argument('dir', action='store', nargs='+')
ns = parser.parse_args()
for p in ns.dir:
try:
pathlib.Path(p).mkdir(parents=ns.parents)
except FileExistsError:
pass
return 0
if __name__ == '__main__':
sys.exit(main())