Skip to content

Refine inline comments #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Refine inline comments
  • Loading branch information
rayluo authored Feb 18, 2021
commit d72ab66a9ab1f2866ca9ef45463a255de3f16fc7
11 changes: 5 additions & 6 deletions msal_extensions/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,19 @@
def _mkdir_p(path):
"""Creates a directory, and any necessary parents.

This implementation based on a Stack Overflow question that can be found here:
https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python

If the path provided is an existing file, this function raises an exception.
:param path: The directory name that should be created.
"""
if not path:
return # NO-OP

if sys.version_info >= (3, 2):
# Can just use the standard Python functionality if it's recent enough (and the
# manual handling below can be dropped altogether when Python 2 support goes)
return os.makedirs(path, exist_ok=True)
os.makedirs(path, exist_ok=True)
return

# This fallback implementation is based on a Stack Overflow question:
# https://stackoverflow.com/questions/600268/mkdir-p-functionality-in-python
# Known issue: it won't work when the path is a root folder like "C:\\"
try:
os.makedirs(path)
except OSError as exp:
Expand Down