diff --git a/blivet/util.py b/blivet/util.py index 56d0aee76..6de35e264 100644 --- a/blivet/util.py +++ b/blivet/util.py @@ -213,6 +213,21 @@ def notify_kernel(path, action="change"): f.write("%s\n" % action) f.close() +def normalize_path_slashes(path): + """ Normalize the slashes in a filesystem path. + Does not actually examine the filesystme in any way. + """ + while "//" in path: + path = path.replace("//", "/") + return path + +def join_paths(*paths): + """ Joins filesystem paths without any consiration of slashes or + whatnot and then normalizes repeated slashes. + """ + if len(paths) == 1 and hasattr(paths[0], "__iter__"): + return join_paths(*paths[0]) + return normalize_path_slashes('/'.join(paths)) def get_sysfs_attr(path, attr): if not attr: diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py index da6c424e1..0185add5f 100644 --- a/tests/devicelibs_test/edd_test.py +++ b/tests/devicelibs_test/edd_test.py @@ -55,7 +55,7 @@ def setUp(self): edd.log.addHandler(self.log_handler) self.td_log_handler = logging.FileHandler("%s/%s" % - (ws, "blivet-edd-testdata.log")) + (ws, "blivet-edd-testdata.log")) self.td_log_handler.setLevel(logging.DEBUG) formatter = logging.Formatter("%(asctime)s %(levelname)s %(name)s: %(message)s") self.td_log_handler.setFormatter(formatter)