Skip to content

Commit

Permalink
build-dummy-ini-files: Be safe for Python 2
Browse files Browse the repository at this point in the history
There's still some environments where Python 2 is the default, and
Python 3 is not available.  Make the build-dummy-ini-files.py script
be friendly to both Python 2 and Python 3.

Signed-off-by: Jeff Squyres <[email protected]>
(cherry picked from commit 9d10b45)
  • Loading branch information
jsquyres authored and rhc54 committed Sep 15, 2023
1 parent 6e431d5 commit 7ea28ae
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/docs/show-help-files/build-dummy-ini-files.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
#
# Copyright 2023 Jeffrey M. Squyres. All rights reserved.
#
Expand Down Expand Up @@ -66,12 +66,14 @@
# Use older form of os.mkdirs (without the exist_ok param) to make
# this script runnable in as many environments as possible.
try:
os.makedirs(full_outdir)
except FileExistsError:
os.makedirs(full_outdir, exists_ok=True)
except Exception:
pass

# Write the output file
with open(outfile, 'w') as fp:
for section in sections:
fp.write(f"""[{section}]
This help section is empty because PRRTE was built without Sphinx.\n""")
# Use Python 2-friendly formatting for environments where
# we don't have Python 3 (!).
fp.write("""[{}]
This help section is empty because PRRTE was built without Sphinx.\n""".format(section))

0 comments on commit 7ea28ae

Please sign in to comment.