From 0a0d23f42ec5d1c3040de303d57286bfe339550d Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Tue, 22 Jul 2014 12:13:24 -0300 Subject: [PATCH] avocado.utils: Add path submodule Add a module for path related operations in avocado.utils. Signed-off-by: Lucas Meneghel Rodrigues --- avocado/utils/path.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 avocado/utils/path.py diff --git a/avocado/utils/path.py b/avocado/utils/path.py new file mode 100644 index 00000000..d175265a --- /dev/null +++ b/avocado/utils/path.py @@ -0,0 +1,34 @@ +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See LICENSE for more details. +# +# Copyright: Red Hat Inc. 2013-2014 +# Author: Yiqiao Pu + +""" +Avocado path related functions. +""" + +import os + + +def init_dir(*args): + """ + Wrapper around os.path.join that creates dirs based on the final path. + + :param args: List of dir arguments that will be os.path.joined. + :type directory: list + :return: directory. + :rtype: str + """ + directory = os.path.join(*args) + if not os.path.isdir(directory): + os.makedirs(directory) + return directory -- GitLab