From 8c2b947d41346e7374269f729fe65975d6613b6e Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 1 Aug 2017 17:35:32 +0800 Subject: utils/io.py: Fix issue in "_create_dir()" with empty directory path Signed-off-by: Aaron LI --- fg21sim/utils/io.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'fg21sim') 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)) -- cgit v1.2.2