summaryrefslogtreecommitdiff
path: root/sphinx/cmd/quickstart.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-11-16 05:01:54 -0800
committerJon Dufresne <jon.dufresne@gmail.com>2018-11-20 18:37:05 -0800
commit77849f0ef6d80fc636f457c2d8925c4932c406c9 (patch)
tree270f19661ab4fdcf3a53f122688532018262744d /sphinx/cmd/quickstart.py
parent2cbc921946c20e072965f746090003fe41f5ddf1 (diff)
downloadsphinx-git-77849f0ef6d80fc636f457c2d8925c4932c406c9.tar.gz
Simplify ensuredir() with Python3 stdlib features
- Simplify ensuredir() to equivalent os.makedir(name, exist_ok=True) - Do not check if a directory exists before calling ensuredir() (ensuredir() already handles it) - Add exist_ok argument to path.makedirs() to follow same pattern - Drop unnecessary .exists() check immediately before .isdir() - Add tests for ensuredir
Diffstat (limited to 'sphinx/cmd/quickstart.py')
-rw-r--r--sphinx/cmd/quickstart.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py
index 934f47b2a..6d2211720 100644
--- a/sphinx/cmd/quickstart.py
+++ b/sphinx/cmd/quickstart.py
@@ -109,7 +109,7 @@ class ValidationError(Exception):
def is_path(x):
# type: (unicode) -> unicode
x = path.expanduser(x)
- if path.exists(x) and not path.isdir(x):
+ if not path.isdir(x):
raise ValidationError(__("Please enter a valid path name."))
return x
@@ -405,8 +405,7 @@ def generate(d, overwrite=True, silent=False, templatedir=None):
'version', 'release', 'master'):
d[key + '_str'] = d[key].replace('\\', '\\\\').replace("'", "\\'")
- if not path.isdir(d['path']):
- ensuredir(d['path'])
+ ensuredir(d['path'])
srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']