diff options
| author | 2019-09-23 17:34:30 +1000 | |
|---|---|---|
| committer | 2019-09-23 17:34:30 +1000 | |
| commit | 3ea2130d71b69bd733675c43f91d7d081472735c (patch) | |
| tree | 6404b4066c96ea0c887495194a5cd11e7422d2e1 | |
| parent | Improve func name, example, directory management (diff) | |
Use mkdir exists kwarg instead of checking existing ahead of time.
| -rw-r--r-- | bot/utils/persist.py | 6 | 
1 files changed, 2 insertions, 4 deletions
| diff --git a/bot/utils/persist.py b/bot/utils/persist.py index 939a95c9..a60a1219 100644 --- a/bot/utils/persist.py +++ b/bot/utils/persist.py @@ -35,8 +35,7 @@ def make_persistent(file_path: Path) -> Path:      >>>     data = json.load(f)      """      # ensure the persistent data directory exists -    if not DIRECTORY.exists(): -        DIRECTORY.mkdir() +    DIRECTORY.mkdir(exist_ok=True)      if not file_path.is_file():          raise OSError(f"File not found at {file_path}.") @@ -47,8 +46,7 @@ def make_persistent(file_path: Path) -> Path:      if season:          # make sure subdirectory exists first          subdirectory = Path(DIRECTORY, season) -        if not subdirectory.exists(): -            subdirectory.mkdir() +        subdirectory.mkdir(exist_ok=True)          persistent_path = Path(subdirectory, file_path.name) | 
