diff options
author | Aaron LI <aly@aaronly.me> | 2017-08-01 17:35:32 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-08-01 17:35:32 +0800 |
commit | 8c2b947d41346e7374269f729fe65975d6613b6e (patch) | |
tree | d517bb2c69de4b5d523281869ebb740fcee46fcf /fg21sim | |
parent | 55dc0e0b80ce332982ff86a5f5c41beb6086056d (diff) | |
download | fg21sim-8c2b947d41346e7374269f729fe65975d6613b6e.tar.bz2 |
utils/io.py: Fix issue in "_create_dir()" with empty directory path
Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim')
-rw-r--r-- | fg21sim/utils/io.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/fg21sim/utils/io.py b/fg21sim/utils/io.py index c19ef47..1d30b23 100644 --- a/fg21sim/utils/io.py +++ b/fg21sim/utils/io.py @@ -19,9 +19,11 @@ logger = logging.getLogger(__name__) def _create_dir(filepath): """ Check the existence of the target directory, and create it if necessary. + """ dirname = os.path.dirname(filepath) - if not os.path.exists(dirname): + # ``dirname == ""`` if ``filepath`` does not contain directory path + if dirname and not os.path.exists(dirname): os.makedirs(dirname) logger.info("Created output directory: {0}".format(dirname)) |